aboutsummaryrefslogtreecommitdiff
path: root/keys.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-04-18 15:35:07 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-04-18 15:35:07 +0200
commit1f6f9ea5c7e59ee711892a800562b57b3c105a7a (patch)
treeef117cce1b12e62ab4a2c5e513533299cab2fff5 /keys.go
parent577e10e99d90503f75f14ee2398d9ea0e87c8434 (diff)
...
Diffstat (limited to 'keys.go')
-rw-r--r--keys.go9
1 files changed, 6 insertions, 3 deletions
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 {