aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/key.go
diff options
context:
space:
mode:
authorGustav Simonsson <gustav.simonsson@gmail.com>2015-04-15 19:24:12 +0800
committerGustav Simonsson <gustav.simonsson@gmail.com>2015-05-12 23:19:39 +0800
commit29a5a92d13cad45794c6e42cb97260a9ab9900ab (patch)
treebfd1ce21673be3610f188a639518bd8e331a8d2e /crypto/key.go
parentac3371bcb69b090fa9b5a8da96916fa0aa15ed0f (diff)
downloaddexon-29a5a92d13cad45794c6e42cb97260a9ab9900ab.tar.gz
dexon-29a5a92d13cad45794c6e42cb97260a9ab9900ab.tar.zst
dexon-29a5a92d13cad45794c6e42cb97260a9ab9900ab.zip
Add key header to encrypted keys
* Add key header containing key version, kdf and kdf params * Store key header as JSON in the key file * Read in KDF params from key header * Include key header in MAC calculation and MAC verification
Diffstat (limited to 'crypto/key.go')
-rw-r--r--crypto/key.go23
1 files changed, 19 insertions, 4 deletions
diff --git a/crypto/key.go b/crypto/key.go
index 5e1f3637e..067a5a294 100644
--- a/crypto/key.go
+++ b/crypto/key.go
@@ -48,17 +48,32 @@ type plainKeyJSON struct {
PrivateKey []byte
}
+type encryptedKeyJSON struct {
+ Id []byte
+ Address []byte
+ Crypto cipherJSON
+}
+
type cipherJSON struct {
MAC []byte
Salt []byte
IV []byte
+ KeyHeader keyHeaderJSON
CipherText []byte
}
-type encryptedKeyJSON struct {
- Id []byte
- Address []byte
- Crypto cipherJSON
+type keyHeaderJSON struct {
+ Version string
+ Kdf string
+ KdfParams scryptParamsJSON // TODO: make more generic?
+}
+
+type scryptParamsJSON struct {
+ N int
+ R int
+ P int
+ DkLen int
+ SaltLen int
}
func (k *Key) MarshalJSON() (j []byte, err error) {