aboutsummaryrefslogtreecommitdiff
path: root/keys.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-04-14 18:20:37 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-04-14 18:20:37 +0200
commite9b8a2ef2b5faf2a251665868074e1dc99f01eb5 (patch)
treecb55c98c2f5417699c8dbe413d3f3b90a963d8f9 /keys.go
parent7cf2ddaa85197a694c9a44d2bd7d71862d5d5887 (diff)
fix keyout
Diffstat (limited to 'keys.go')
-rw-r--r--keys.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/keys.go b/keys.go
index 0fcfee9..0248a4b 100644
--- a/keys.go
+++ b/keys.go
@@ -4,6 +4,8 @@ import (
"bytes"
"crypto/sha512"
+ "dim13.org/signify/bhash"
+
"golang.org/x/crypto/ed25519"
)
@@ -43,7 +45,13 @@ func xor(text, key []byte) {
}
}
-func (v *EncKey) IsValid() bool {
+func (v *EncKey) IsValid(pass []byte) bool {
+ if v.KDFRounds > 0 {
+ key := bhash.Pbkdf(pass, v.Salt[:], int(v.KDFRounds), len(v.SecKey))
+ for x := range key {
+ v.SecKey[x] ^= key[x]
+ }
+ }
sum := sha512.Sum512(v.SecKey[:])
- return bytes.Equal(sum[:8], v.Checksum[:])
+ return bytes.Equal(sum[:len(v.Checksum)], v.Checksum[:])
}