mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
rand.read > io.readFull
This commit is contained in:
parent
31f81ddee0
commit
248155eea0
1 changed files with 4 additions and 4 deletions
|
|
@ -159,9 +159,9 @@ func (s *AESEncryptedStorage) writeEncryptedStorage(creds map[string]storedCrede
|
|||
return nil
|
||||
}
|
||||
|
||||
func randBytes(size int) (blk []byte, err error) {
|
||||
blk = make([]byte, size)
|
||||
_, err = rand.Read(blk)
|
||||
func (s *AESEncryptedStorage) randBytes() (nonce []byte, err error) {
|
||||
nonce = make([]byte, s.gcmNS)
|
||||
_, err = io.ReadFull(rand.Reader, nonce)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -173,7 +173,7 @@ func (s *AESEncryptedStorage) encrypt(plaintext []byte, additionalData []byte) (
|
|||
// key because of the risk of a repeat.
|
||||
var n []byte
|
||||
|
||||
if n, err = randBytes(s.gcmNS); err != nil {
|
||||
if n, err = s.randBytes(); err != nil {
|
||||
return
|
||||
}
|
||||
return append(n, s.gcm.Seal(nil, n, plaintext, additionalData)...), n, nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue