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
This commit is contained in:
@ -48,19 +48,34 @@ type plainKeyJSON struct {
|
||||
PrivateKey []byte
|
||||
}
|
||||
|
||||
type cipherJSON struct {
|
||||
MAC []byte
|
||||
Salt []byte
|
||||
IV []byte
|
||||
CipherText []byte
|
||||
}
|
||||
|
||||
type encryptedKeyJSON struct {
|
||||
Id []byte
|
||||
Address []byte
|
||||
Crypto cipherJSON
|
||||
}
|
||||
|
||||
type cipherJSON struct {
|
||||
MAC []byte
|
||||
Salt []byte
|
||||
IV []byte
|
||||
KeyHeader keyHeaderJSON
|
||||
CipherText []byte
|
||||
}
|
||||
|
||||
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) {
|
||||
jStruct := plainKeyJSON{
|
||||
k.Id,
|
||||
|
Reference in New Issue
Block a user