aboutsummaryrefslogtreecommitdiff
path: root/bhash
diff options
context:
space:
mode:
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]
}