From dffca582d57491e946582f2ac86e2c21ac5d6b74 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Fri, 14 Apr 2017 02:11:13 +0200 Subject: ... --- bhash.go | 40 ++++++++++++++++++++++++++++++++++++++++ pbkdf.go | 8 +++----- 2 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 bhash.go diff --git a/bhash.go b/bhash.go new file mode 100644 index 0000000..19c1ee8 --- /dev/null +++ b/bhash.go @@ -0,0 +1,40 @@ +package main + +import ( + "hash" + + "golang.org/x/crypto/blowfish" +) + +var magic = []byte("OxychromaticBlowfishSwatDynamite") + +// blowfish hash +type digest struct { + c *blowfish.Cipher +} + +func (d *digest) Write(p []byte) (n int, err error) { + panic("not implemented") +} + +func (d *digest) Sum(b []byte) []byte { + panic("not implemented") +} + +func (d *digest) Reset() { + panic("not implemented") +} + +func (d *digest) Size() int { + panic("not implemented") +} + +func (d *digest) BlockSize() int { + return d.c.BlockSize() +} + +func NewBHash() hash.Hash { + d := &digest{} + d.Reset() + return d +} diff --git a/pbkdf.go b/pbkdf.go index 6a88fc1..9b868e4 100644 --- a/pbkdf.go +++ b/pbkdf.go @@ -1,15 +1,13 @@ package main import ( - "hash" + "crypto/sha512" "golang.org/x/crypto/pbkdf2" ) // bcrypt_pbkdf -const magic = "OxychromaticBlowfishSwatDynamite" - -func Key(password, salt []byte, iter, keyLen int, h func() hash.Hash) []byte { - return pbkdf2.Key(password, salt, iter, keyLen, h) +func Key(password, salt []byte, iter, keyLen int) []byte { + return pbkdf2.Key(password, salt, iter, keyLen, sha512.New) } -- cgit v1.2.3