mirror of
https://github.com/golang/go
synced 2024-11-20 03:04:40 -07:00
crypto/ecdsa, crypto/rsa: use io.ReadFull to read from random source.
R=golang-dev, agl1 CC=golang-dev https://golang.org/cl/4316057
This commit is contained in:
parent
db99a784c2
commit
9f1394d270
@ -37,7 +37,7 @@ var one = new(big.Int).SetInt64(1)
|
|||||||
// curve using the procedure given in [NSA] A.2.1.
|
// curve using the procedure given in [NSA] A.2.1.
|
||||||
func randFieldElement(c *elliptic.Curve, rand io.Reader) (k *big.Int, err os.Error) {
|
func randFieldElement(c *elliptic.Curve, rand io.Reader) (k *big.Int, err os.Error) {
|
||||||
b := make([]byte, c.BitSize/8+8)
|
b := make([]byte, c.BitSize/8+8)
|
||||||
_, err = rand.Read(b)
|
_, err = io.ReadFull(rand, b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ func nonZeroRandomBytes(s []byte, rand io.Reader) (err os.Error) {
|
|||||||
|
|
||||||
for i := 0; i < len(s); i++ {
|
for i := 0; i < len(s); i++ {
|
||||||
for s[i] == 0 {
|
for s[i] == 0 {
|
||||||
_, err = rand.Read(s[i : i+1])
|
_, err = io.ReadFull(rand, s[i:i+1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user