From e9b8a2ef2b5faf2a251665868074e1dc99f01eb5 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Fri, 14 Apr 2017 18:20:37 +0200 Subject: fix keyout --- bhash/bhash.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'bhash/bhash.go') 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] } -- cgit v1.2.3