diff --git a/internal/sm2ec/p256_asm_s390x.s b/internal/sm2ec/p256_asm_s390x.s index a82bc55..cd9a6d8 100644 --- a/internal/sm2ec/p256_asm_s390x.s +++ b/internal/sm2ec/p256_asm_s390x.s @@ -328,7 +328,6 @@ loop_select: #define ZER V6 #define SEL1 V7 -#define SEL2 V8 #define CAR1 V9 #define CAR2 V10 #define RED1 V11 @@ -345,8 +344,7 @@ TEXT ·p256FromMont(SB), NOSPLIT, $0 MOVD $p256<>+0x00(SB), CPOOL VL 16(CPOOL), PL VL 0(CPOOL), PH - VL 48(CPOOL), SEL2 - VL 64(CPOOL), SEL1 + VL 48(CPOOL), SEL1 VL (0*16)(x_ptr), T0 VPDI $0x4, T0, T0, T0 @@ -449,7 +447,6 @@ TEXT ·p256FromMont(SB), NOSPLIT, $0 #undef TT1 #undef ZER #undef SEL1 -#undef SEL2 #undef CAR1 #undef CAR2 #undef RED1 diff --git a/internal/sm2ec/sm2p256_asm_s390x_test.go b/internal/sm2ec/sm2p256_asm_s390x_test.go index b0baef8..aacc61f 100644 --- a/internal/sm2ec/sm2p256_asm_s390x_test.go +++ b/internal/sm2ec/sm2p256_asm_s390x_test.go @@ -66,7 +66,7 @@ func testP256OrderReduce(v, expected *big.Int, t *testing.T) { fromBig((*[4]uint64)(val), v) p256OrdReduce(val) if ordElmToBigInt(val).Cmp(expected) != 0 { - t.Errorf("p256OrdReduce failed for %x", v.Bytes()) + t.Errorf("p256OrdReduce failed for %x, expected %x", v.Bytes(), expected.Bytes()) } } @@ -75,9 +75,12 @@ func TestP256OrderReduce(t *testing.T) { for i := 0; i < 20; i++ { bigVal := big.NewInt(int64(i)) testP256OrderReduce(bigVal, bigVal, t) - bigVal = new(big.Int).Sub(p, big.NewInt(int64(i))) - testP256OrderReduce(bigVal, bigVal, t) bigVal = new(big.Int).Add(p, big.NewInt(int64(i))) testP256OrderReduce(bigVal, big.NewInt(int64(i)), t) } + testP256OrderReduce(p, big.NewInt(0), t) + for i := 1; i < 20; i++ { + bigVal := new(big.Int).Sub(p, big.NewInt(int64(i))) + testP256OrderReduce(bigVal, bigVal, t) + } }