tolerate zero-padded scalars in generic implementation

This commit is contained in:
Emman 2022-04-08 11:18:45 +08:00
parent bfdb74af01
commit dc34e17797

View File

@ -57,7 +57,7 @@ func p256GetScalar(out *[32]byte, in []byte) {
n := new(big.Int).SetBytes(in) n := new(big.Int).SetBytes(in)
var scalarBytes []byte var scalarBytes []byte
if n.Cmp(p256.N) >= 0 { if n.Cmp(p256.N) >= 0 || len(in) > len(out) {
n.Mod(n, p256.N) n.Mod(n, p256.N)
scalarBytes = n.Bytes() scalarBytes = n.Bytes()
} else { } else {