Skip to content

Commit

Permalink
Fix SM2_AMD64
Browse files Browse the repository at this point in the history
  • Loading branch information
guanzhi committed May 25, 2024
1 parent cde0065 commit 0d1ef16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/sm2_z256.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ const uint64_t SM2_Z256_NEG_N[4] = {
0xac440bf6c62abedd, 0x8dfc2094de39fad4, 0x0000000000000000, 0x0000000100000000,
};

#if !defined(ENABLE_SM2_ARM64) && !defined(ENABLE_SM2_AMD64)
#if !defined(ENABLE_SM2_ARM64)
void sm2_z256_modn_add(sm2_z256_t r, const sm2_z256_t a, const sm2_z256_t b)
{
uint64_t c;
Expand Down Expand Up @@ -868,7 +868,7 @@ const uint64_t *sm2_z256_order_minus_one(void) {
const uint64_t *SM2_Z256_MODN_MONT_ONE = SM2_Z256_NEG_N;


#if !defined(ENABLE_SM2_ARM64) && !defined(ENABLE_SM2_AMD64)
#if !defined(ENABLE_SM2_ARM64)
void sm2_z256_modn_mont_mul(sm2_z256_t r, const sm2_z256_t a, const sm2_z256_t b)
{
sm2_z512_t z;
Expand Down Expand Up @@ -917,7 +917,7 @@ void sm2_z256_modn_mul(sm2_z256_t r, const sm2_z256_t a, const sm2_z256_t b)
sm2_z256_modn_from_mont(r, r);
}

#if !defined(ENABLE_SM2_ARM64) && !defined(ENABLE_SM2_AMD64)
#if !defined(ENABLE_SM2_ARM64)
void sm2_z256_modn_mont_sqr(sm2_z256_t r, const sm2_z256_t a)
{
sm2_z256_modn_mont_mul(r, a, a);
Expand Down Expand Up @@ -1020,7 +1020,7 @@ void sm2_z256_modn_inv(sm2_z256_t r, const sm2_z256_t a)
}


#if !defined(ENABLE_SM2_ARM64) && !defined(ENABLE_SM2_AMD64)
#if !defined(ENABLE_SM2_ARM64)

// mont(mont(a), 1) = aR * 1 * R^-1 (mod n) = a (mod p)
void sm2_z256_modn_from_mont(sm2_z256_t r, const sm2_z256_t a)
Expand Down
7 changes: 5 additions & 2 deletions src/sm2_z256_amd64.S
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,10 @@ func(sm2_z256_modp_neg):

.p2align 5
func(sm2_z256_modp_to_mont):
// FIXME: swap arg1 arg2
// swap(arg1, arg2)
movq %rdi, %rax
movq %rsi, %rdi
movq %rax, %rsi
leaq L$RR(%rip),%rdx
jmp L$mul_mont

Expand Down Expand Up @@ -637,7 +640,7 @@ __ecp_sm2z256_mul_montq:
.globl func(sm2_z256_modp_mont_sqr)

.p2align 5
func(sm2_z256_modp_mont_mul):
func(sm2_z256_modp_mont_sqr):
pushq %rbp
pushq %rbx
pushq %r12
Expand Down

0 comments on commit 0d1ef16

Please sign in to comment.