mirror of
https://github.com/golang/go
synced 2024-11-18 06:14:46 -07:00
crypto/{ecdsa,rsa}: always use io.ReadFull with crypto/rand.Reader.
crypto/rand.Reader doesn't ensure that short reads don't happen. This change contains a couple of fixups where io.ReadFull wasn't being used with it. Change-Id: I3855b81f5890f2e703112eeea804aeba07b6a6b8 Reviewed-on: https://go-review.googlesource.com/7645 Reviewed-by: Minux Ma <minux@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org>
This commit is contained in:
parent
e14339d34c
commit
123b38e105
@ -140,7 +140,7 @@ func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err err
|
||||
entropylen = 32
|
||||
}
|
||||
entropy := make([]byte, entropylen)
|
||||
_, err = rand.Read(entropy)
|
||||
_, err = io.ReadFull(rand, entropy)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ func (priv *PrivateKey) Decrypt(rand io.Reader, ciphertext []byte, opts crypto.D
|
||||
case *PKCS1v15DecryptOptions:
|
||||
if l := opts.SessionKeyLen; l > 0 {
|
||||
plaintext = make([]byte, l)
|
||||
if _, err := rand.Read(plaintext); err != nil {
|
||||
if _, err := io.ReadFull(rand, plaintext); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := DecryptPKCS1v15SessionKey(rand, priv, ciphertext, plaintext); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user