From 3daccb3fcc5b189d6d4bcde4c27d9c5c4353e158 Mon Sep 17 00:00:00 2001 From: "[GGSuchao]" <[1500062807@pku.edu.cn]> Date: Thu, 6 Jul 2017 19:00:22 +0800 Subject: [PATCH] add sm2 --- crypto/sm2/sm2_standard_exch.c | 4 ++-- crypto/sm2/sm2_standard_sign.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crypto/sm2/sm2_standard_exch.c b/crypto/sm2/sm2_standard_exch.c index 3209daf8..f9065df7 100644 --- a/crypto/sm2/sm2_standard_exch.c +++ b/crypto/sm2/sm2_standard_exch.c @@ -62,7 +62,7 @@ int SM2_w(big n) n1 = mirvar(0); w = logb2(para_n); //approximate integer log to the base 2 of para_n expb2(w, n1); //n1 = 2^w - if (compare(para_n, n1) == 1) + if (mr_compare(para_n, n1) == 1) w++; if ((w % 2) == 0) w = w / 2 - 1; @@ -440,7 +440,7 @@ int SM2_standard_keyex_selftest() RB = epoint_init(); V = epoint_init(); - SM2_init(); + SM2_standard_init(); bytes_to_big(SM2_NUMWORD, std_priKeyA, dA); bytes_to_big(SM2_NUMWORD, std_priKeyB, dB); diff --git a/crypto/sm2/sm2_standard_sign.c b/crypto/sm2/sm2_standard_sign.c index 9e1ca1ef..2469bf8a 100644 --- a/crypto/sm2/sm2_standard_sign.c +++ b/crypto/sm2/sm2_standard_sign.c @@ -59,7 +59,7 @@ int Test_Zero(big x) { big zero; zero = mirvar(0); - if (compare(x, zero) == 0) + if (mr_compare(x, zero) == 0) return 1; else return 0; @@ -70,7 +70,7 @@ int Test_Zero(big x) int Test_n(big x) { //bytes_to_big(32, SM2_n, n); - if (compare(x, para_n) == 0) + if (mr_compare(x, para_n) == 0) return 1; else return 0; @@ -88,7 +88,7 @@ int Test_Range(big x) convert(1, one); 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 0; } @@ -279,7 +279,7 @@ int SM2_standard_verify(unsigned char *message, int len, unsigned char ZA[], uns divide(RR, para_n, rem); free(M); - if (compare(RR, r) == 0) + if (mr_compare(RR, r) == 0) return 0; else return ERR_DATA_MEMCMP;