From 1f6f9ea5c7e59ee711892a800562b57b3c105a7a Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 18 Apr 2017 15:35:07 +0200 Subject: ... --- keys.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'keys.go') diff --git a/keys.go b/keys.go index 1e52ef1..85675e2 100644 --- a/keys.go +++ b/keys.go @@ -10,6 +10,8 @@ import ( "golang.org/x/crypto/ed25519" ) +const DefaultRounds = 42 + var ( PKAlg = [2]byte{'E', 'd'} KDFAlg = [2]byte{'B', 'K'} @@ -69,14 +71,15 @@ func (v *EncKey) IsValid() bool { return bytes.Equal(sum[:len(v.Checksum)], v.Checksum[:]) } -func (e *EncKey) Kdf(pass string) { - if e.KDFRounds == 0 { +func (e *EncKey) Kdf(pass string, rounds int) { + if rounds == 0 { return } - xorkey := bhash.Pbkdf([]byte(pass), e.Salt[:], int(e.KDFRounds), len(e.SecKey)) + xorkey := bhash.Pbkdf([]byte(pass), e.Salt[:], rounds, len(e.SecKey)) for i := range xorkey { e.SecKey[i] ^= xorkey[i] } + e.KDFRounds = uint32(rounds) } func Unmarshal(b []byte, v interface{}) error { -- cgit v1.2.3