diff --git a/include/gmssl/sm9_z256.h b/include/gmssl/sm9_z256.h index 3ea20564..5a1bf7ea 100644 --- a/include/gmssl/sm9_z256.h +++ b/include/gmssl/sm9_z256.h @@ -190,7 +190,6 @@ typedef struct { void sm9_z256_point_from_hex(SM9_Z256_POINT *R, const char hex[65 * 2]); int sm9_z256_point_is_at_infinity(const SM9_Z256_POINT *P); void sm9_z256_point_set_infinity(SM9_Z256_POINT *R); -void sm9_z256_point_copy(SM9_Z256_POINT *R, const SM9_Z256_POINT *P); void sm9_z256_point_get_xy(const SM9_Z256_POINT *P, sm9_z256_t x, sm9_z256_t y); int sm9_z256_point_equ(const SM9_Z256_POINT *P, const SM9_Z256_POINT *Q); int sm9_z256_point_is_on_curve(const SM9_Z256_POINT *P); @@ -211,8 +210,6 @@ typedef struct { sm9_z256_fp2 Z; } SM9_Z256_TWIST_POINT; -//#define sm9_z256_twist_point_copy(R, P) memcpy((R), (P), sizeof(SM9_Z256_TWIST_POINT)) - int sm9_z256_twist_point_to_uncompressed_octets(const SM9_Z256_TWIST_POINT *P, uint8_t octets[129]); int sm9_z256_twist_point_from_uncompressed_octets(SM9_Z256_TWIST_POINT *P, const uint8_t octets[129]); diff --git a/src/sm9_z256_alg.c b/src/sm9_z256_alg.c index abff4f20..30725632 100644 --- a/src/sm9_z256_alg.c +++ b/src/sm9_z256_alg.c @@ -1738,11 +1738,6 @@ void sm9_z256_point_set_infinity(SM9_Z256_POINT *R) sm9_z256_set_zero(R->Z); } -void sm9_z256_point_copy(SM9_Z256_POINT *R, const SM9_Z256_POINT *P) -{ - *R = *P; -} - // xy from this function are still mont void sm9_z256_point_get_xy(const SM9_Z256_POINT *P, sm9_z256_t x, sm9_z256_t y) { @@ -1815,7 +1810,7 @@ void sm9_z256_point_dbl(SM9_Z256_POINT *R, const SM9_Z256_POINT *P) sm9_z256_t X3, Y3, Z3, T1, T2, T3; if (sm9_z256_point_is_at_infinity(P)) { - sm9_z256_point_copy(R, P); + *R = *P; return; } @@ -1853,11 +1848,11 @@ void sm9_z256_point_add(SM9_Z256_POINT *R, const SM9_Z256_POINT *P, const SM9_Z2 sm9_z256_t X3, Y3, Z3, T1, T2, T3, T4; if (sm9_z256_point_is_at_infinity(Q)) { - sm9_z256_point_copy(R, P); + *R = *P; return; } if (sm9_z256_point_is_at_infinity(P)) { - sm9_z256_point_copy(R, Q); + *R = *Q; return; } @@ -1929,7 +1924,7 @@ void sm9_z256_point_mul(SM9_Z256_POINT *R, const sm9_z256_t k, const SM9_Z256_PO int i; // T[i] = (i + 1) * P - sm9_z256_point_copy(&T[0], P); + T[0] = *P; sm9_z256_point_dbl(&T[2-1], &T[1-1]); sm9_z256_point_dbl(&T[4-1], &T[2-1]); diff --git a/tests/sm9test.c b/tests/sm9test.c index d8f2bd4f..c4bb2be6 100644 --- a/tests/sm9test.c +++ b/tests/sm9test.c @@ -659,7 +659,8 @@ int test_sm9_z256_ciphertext() size_t len = 0; int j = 1; - sm9_z256_point_copy(&C1, P1); + C1 = *P1; + if (sm9_ciphertext_to_der(&C1, c2, sizeof(c2), c3, &p, &len) != 1) goto err; ++j; //printf("SM9_Z256_MAX_CIPHERTEXT_SIZE %zu\n", len);