mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-27 20:56:18 +08:00
internal/sm2ec: add boundary test
This commit is contained in:
parent
ca474a67ba
commit
c813a1fb65
@ -51,6 +51,13 @@ func p256MulTest(t *testing.T, x, y, p, r *big.Int) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestP256MulPMinus1(t *testing.T) {
|
||||
p, _ := new(big.Int).SetString("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF", 16)
|
||||
r, _ := new(big.Int).SetString("10000000000000000000000000000000000000000000000000000000000000000", 16)
|
||||
pMinus1 := new(big.Int).Sub(p, big.NewInt(1))
|
||||
p256MulTest(t, pMinus1, pMinus1, p, r)
|
||||
}
|
||||
|
||||
func TestFuzzyP256Mul(t *testing.T) {
|
||||
p, _ := new(big.Int).SetString("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF", 16)
|
||||
r, _ := new(big.Int).SetString("10000000000000000000000000000000000000000000000000000000000000000", 16)
|
||||
@ -95,6 +102,13 @@ func p256SqrTest(t *testing.T, x, p, r *big.Int) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestP256SqrPMinus1(t *testing.T) {
|
||||
p, _ := new(big.Int).SetString("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF", 16)
|
||||
r, _ := new(big.Int).SetString("10000000000000000000000000000000000000000000000000000000000000000", 16)
|
||||
pMinus1 := new(big.Int).Sub(p, big.NewInt(1))
|
||||
p256SqrTest(t, pMinus1, p, r)
|
||||
}
|
||||
|
||||
func TestFuzzyP256Sqr(t *testing.T) {
|
||||
p, _ := new(big.Int).SetString("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF", 16)
|
||||
r, _ := new(big.Int).SetString("10000000000000000000000000000000000000000000000000000000000000000", 16)
|
||||
|
@ -90,7 +90,7 @@ TEXT gfpMulInternal(SB),NOSPLIT,$8
|
||||
ADDQ mul0, acc4
|
||||
ADCQ $0, acc5
|
||||
|
||||
// [t3, t2, t1, t0] * acc5
|
||||
// [t3, t2, t1, t0] * acc6
|
||||
MOVQ acc6, mul1
|
||||
MULXQ t0, mul0, hlp
|
||||
ADDQ mul0, acc2
|
||||
|
Loading…
x
Reference in New Issue
Block a user