mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
signer/storage fix storage to pass all tests
This commit is contained in:
parent
2f6298765d
commit
6835af0aa0
1 changed files with 10 additions and 0 deletions
|
|
@ -63,6 +63,11 @@ func (s *Storage) Get(key string) (string, error) {
|
|||
return "", err
|
||||
}
|
||||
|
||||
if len(s.key) == 0 {
|
||||
// if there is no key for decryption, just store the value
|
||||
return data, nil
|
||||
}
|
||||
|
||||
cred := StoredCredential{}
|
||||
if err = json.Unmarshal([]byte(data), &cred); err != nil {
|
||||
log.Warn("Failed to unmarshal encrypted credential", "err", err)
|
||||
|
|
@ -85,6 +90,11 @@ func (s *Storage) Put(key, value string) error {
|
|||
return ErrZeroKey
|
||||
}
|
||||
|
||||
if len(s.key) == 0 {
|
||||
// if there is no key for encryption, just store the value
|
||||
return s.api.Put(key, value)
|
||||
}
|
||||
|
||||
ciphertext, iv, err := Encrypt(s.key, []byte(value), []byte(key))
|
||||
if err != nil {
|
||||
log.Warn("Failed to encrypt entry", "err", err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue