From 29a5a92d13cad45794c6e42cb97260a9ab9900ab Mon Sep 17 00:00:00 2001 From: Gustav Simonsson Date: Wed, 15 Apr 2015 13:24:12 +0200 Subject: 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 --- crypto/key.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'crypto/key.go') 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) { -- cgit v1.2.3