aboutsummaryrefslogtreecommitdiff
path: root/keys.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-10-23 18:47:36 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-10-23 18:47:36 +0200
commit5b1f187c7a3515a8335a134364929f6e0bbef1f5 (patch)
tree168c353969c87772468d70d7c35aca9b59ccf026 /keys.go
parentbb4dbe34df4907c123bae0f34eb3786d244b4480 (diff)
Simplify interface
Diffstat (limited to 'keys.go')
-rw-r--r--keys.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/keys.go b/keys.go
new file mode 100644
index 0000000..d96d999
--- /dev/null
+++ b/keys.go
@@ -0,0 +1,35 @@
+package main
+
+import (
+ "bytes"
+ "crypto/sha512"
+
+ "github.com/agl/ed25519"
+)
+
+type Sig struct {
+ PKAlg [2]byte
+ KeyNum [KeyNumLen]byte
+ Sig [ed25519.SignatureSize]byte
+}
+
+type PubKey struct {
+ PKAlg [2]byte
+ KeyNum [KeyNumLen]byte
+ PubKey [ed25519.PublicKeySize]byte
+}
+
+type EncKey struct {
+ PKAlg [2]byte
+ KDFAlg [2]byte
+ KDFRounds uint32 // network byte order
+ Salt [16]byte
+ Checksum [8]byte
+ KeyNum [KeyNumLen]byte
+ SecKey [ed25519.PrivateKeySize]byte
+}
+
+func (v *EncKey) Valid() bool {
+ sum := sha512.Sum512(v.SecKey[:])
+ return bytes.Equal(sum[:len(v.Checksum)], v.Checksum[:])
+}