aboutsummaryrefslogtreecommitdiff
path: root/keys.go
diff options
context:
space:
mode:
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[:])
}