crypto/ecdsa: draw a fixed amount of entropy while signing

This commit is contained in:
Emman 2021-12-15 08:47:04 +08:00
parent 54ee9c6f5e
commit b2713b5e0d

View File

@ -569,12 +569,9 @@ func Sign(rand io.Reader, priv *ecdsa.PrivateKey, hash []byte) (r, s *big.Int, e
}
maybeReadByte(rand)
// Get min(log2(q) / 2, 256) bits of entropy from rand.
entropylen := (priv.Curve.Params().BitSize + 7) / 16
if entropylen > 32 {
entropylen = 32
}
entropy := make([]byte, entropylen)
// Get 256 bits of entropy from rand.
entropy := make([]byte, 32)
_, err = io.ReadFull(rand, entropy)
if err != nil {
return