aboutsummaryrefslogtreecommitdiff
path: root/bhash
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-04-14 18:20:37 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-04-14 18:20:37 +0200
commite9b8a2ef2b5faf2a251665868074e1dc99f01eb5 (patch)
treecb55c98c2f5417699c8dbe413d3f3b90a963d8f9 /bhash
parent7cf2ddaa85197a694c9a44d2bd7d71862d5d5887 (diff)
fix keyout
Diffstat (limited to 'bhash')
-rw-r--r--bhash/bhash.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/bhash/bhash.go b/bhash/bhash.go
index bc4bfe8..307d31d 100644
--- a/bhash/bhash.go
+++ b/bhash/bhash.go
@@ -49,7 +49,7 @@ func Pbkdf(pass, salt []byte, iter, keyLen int) []byte {
numBlocks := (keyLen + hashLen - 1) / hashLen
out := make([]byte, hashLen)
- buf := new(bytes.Buffer)
+ key := make([]byte, hashLen*numBlocks)
for n := 1; n <= numBlocks; n++ {
// first round, salt is salt
@@ -67,7 +67,11 @@ func Pbkdf(pass, salt []byte, iter, keyLen int) []byte {
out[x] ^= tmp[x]
}
}
- buf.Write(out)
+ // pbkdf2 deviation: output the key material non-linearly
+ for x := range out {
+ dst := x*numBlocks + (n - 1)
+ key[dst] = out[x]
+ }
}
- return buf.Bytes()[:keyLen]
+ return key[:keyLen]
}