mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-26 04:06:18 +08:00
tolerate zero-padded scalars in generic implementation
This commit is contained in:
parent
bfdb74af01
commit
dc34e17797
@ -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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user