mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-26 04:06:18 +08:00
crypto/ecdsa: draw a fixed amount of entropy while signing
This commit is contained in:
parent
54ee9c6f5e
commit
b2713b5e0d
@ -569,12 +569,9 @@ func Sign(rand io.Reader, priv *ecdsa.PrivateKey, hash []byte) (r, s *big.Int, e
|
|||||||
}
|
}
|
||||||
maybeReadByte(rand)
|
maybeReadByte(rand)
|
||||||
|
|
||||||
// Get min(log2(q) / 2, 256) bits of entropy from rand.
|
// Get 256 bits of entropy from rand.
|
||||||
entropylen := (priv.Curve.Params().BitSize + 7) / 16
|
entropy := make([]byte, 32)
|
||||||
if entropylen > 32 {
|
|
||||||
entropylen = 32
|
|
||||||
}
|
|
||||||
entropy := make([]byte, entropylen)
|
|
||||||
_, err = io.ReadFull(rand, entropy)
|
_, err = io.ReadFull(rand, entropy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user