mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-08-07 21:53:41 +08:00
add sm2
This commit is contained in:
@@ -62,7 +62,7 @@ int SM2_w(big n)
|
|||||||
n1 = mirvar(0);
|
n1 = mirvar(0);
|
||||||
w = logb2(para_n); //approximate integer log to the base 2 of para_n
|
w = logb2(para_n); //approximate integer log to the base 2 of para_n
|
||||||
expb2(w, n1); //n1 = 2^w
|
expb2(w, n1); //n1 = 2^w
|
||||||
if (compare(para_n, n1) == 1)
|
if (mr_compare(para_n, n1) == 1)
|
||||||
w++;
|
w++;
|
||||||
if ((w % 2) == 0)
|
if ((w % 2) == 0)
|
||||||
w = w / 2 - 1;
|
w = w / 2 - 1;
|
||||||
@@ -440,7 +440,7 @@ int SM2_standard_keyex_selftest()
|
|||||||
RB = epoint_init();
|
RB = epoint_init();
|
||||||
V = epoint_init();
|
V = epoint_init();
|
||||||
|
|
||||||
SM2_init();
|
SM2_standard_init();
|
||||||
|
|
||||||
bytes_to_big(SM2_NUMWORD, std_priKeyA, dA);
|
bytes_to_big(SM2_NUMWORD, std_priKeyA, dA);
|
||||||
bytes_to_big(SM2_NUMWORD, std_priKeyB, dB);
|
bytes_to_big(SM2_NUMWORD, std_priKeyB, dB);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ int Test_Zero(big x)
|
|||||||
{
|
{
|
||||||
big zero;
|
big zero;
|
||||||
zero = mirvar(0);
|
zero = mirvar(0);
|
||||||
if (compare(x, zero) == 0)
|
if (mr_compare(x, zero) == 0)
|
||||||
return 1;
|
return 1;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
@@ -70,7 +70,7 @@ int Test_Zero(big x)
|
|||||||
int Test_n(big x)
|
int Test_n(big x)
|
||||||
{
|
{
|
||||||
//bytes_to_big(32, SM2_n, n);
|
//bytes_to_big(32, SM2_n, n);
|
||||||
if (compare(x, para_n) == 0)
|
if (mr_compare(x, para_n) == 0)
|
||||||
return 1;
|
return 1;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
@@ -88,7 +88,7 @@ int Test_Range(big x)
|
|||||||
convert(1, one);
|
convert(1, one);
|
||||||
decr(para_n, 1, decr_n);
|
decr(para_n, 1, decr_n);
|
||||||
|
|
||||||
if ((compare(x, one) < 0) | (compare(x, decr_n) > 0))
|
if ((mr_compare(x, one) < 0) | (compare(x, decr_n) > 0))
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -279,7 +279,7 @@ int SM2_standard_verify(unsigned char *message, int len, unsigned char ZA[], uns
|
|||||||
divide(RR, para_n, rem);
|
divide(RR, para_n, rem);
|
||||||
|
|
||||||
free(M);
|
free(M);
|
||||||
if (compare(RR, r) == 0)
|
if (mr_compare(RR, r) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return ERR_DATA_MEMCMP;
|
return ERR_DATA_MEMCMP;
|
||||||
|
|||||||
Reference in New Issue
Block a user