mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-08-07 21:53:41 +08:00
speed-update
This commit is contained in:
286
apps/speed.c
286
apps/speed.c
@@ -148,7 +148,7 @@
|
|||||||
#define BUFSIZE (1024*16+1)
|
#define BUFSIZE (1024*16+1)
|
||||||
#define MAX_MISALIGNMENT 63
|
#define MAX_MISALIGNMENT 63
|
||||||
|
|
||||||
#define ALGOR_NUM 34
|
#define ALGOR_NUM 33
|
||||||
#define SIZE_NUM 6
|
#define SIZE_NUM 6
|
||||||
#define PRIME_NUM 3
|
#define PRIME_NUM 3
|
||||||
#define RSA_NUM 7
|
#define RSA_NUM 7
|
||||||
@@ -202,6 +202,7 @@ typedef struct loopargs_st {
|
|||||||
#ifndef OPENSSL_NO_SM9
|
#ifndef OPENSSL_NO_SM9
|
||||||
SM9PublicParameters *sm9mpk[SM9_NUM];
|
SM9PublicParameters *sm9mpk[SM9_NUM];
|
||||||
SM9PrivateKey *sm9sk[SM9_NUM];
|
SM9PrivateKey *sm9sk[SM9_NUM];
|
||||||
|
SM9MasterSecret *sm9mst[SM9_NUM];
|
||||||
#endif
|
#endif
|
||||||
EVP_CIPHER_CTX *ctx;
|
EVP_CIPHER_CTX *ctx;
|
||||||
HMAC_CTX *hctx;
|
HMAC_CTX *hctx;
|
||||||
@@ -297,7 +298,7 @@ static const char *names[ALGOR_NUM] = {
|
|||||||
"camellia-128 cbc", "camellia-192 cbc", "camellia-256 cbc",
|
"camellia-128 cbc", "camellia-192 cbc", "camellia-256 cbc",
|
||||||
"evp", "sha256", "sha512", "whirlpool",
|
"evp", "sha256", "sha512", "whirlpool",
|
||||||
"aes-128 ige", "aes-192 ige", "aes-256 ige", "ghash",
|
"aes-128 ige", "aes-192 ige", "aes-256 ige", "ghash",
|
||||||
"sm3", "sms4 cbc", "zuc", "zuc256"
|
"sm3", "sms4 cbc", "zuc"
|
||||||
};
|
};
|
||||||
|
|
||||||
static double results[ALGOR_NUM][SIZE_NUM];
|
static double results[ALGOR_NUM][SIZE_NUM];
|
||||||
@@ -483,7 +484,6 @@ OPTIONS speed_options[] = {
|
|||||||
#define D_SM3 30
|
#define D_SM3 30
|
||||||
#define D_CBC_SMS4 31
|
#define D_CBC_SMS4 31
|
||||||
#define D_ZUC 32
|
#define D_ZUC 32
|
||||||
#define D_ZUC256 33
|
|
||||||
static OPT_PAIR doit_choices[] = {
|
static OPT_PAIR doit_choices[] = {
|
||||||
#ifndef OPENSSL_NO_MD2
|
#ifndef OPENSSL_NO_MD2
|
||||||
{"md2", D_MD2},
|
{"md2", D_MD2},
|
||||||
@@ -562,7 +562,6 @@ static OPT_PAIR doit_choices[] = {
|
|||||||
#endif
|
#endif
|
||||||
#ifndef OPENSSL_NO_ZUC
|
#ifndef OPENSSL_NO_ZUC
|
||||||
{"zuc", D_ZUC},
|
{"zuc", D_ZUC},
|
||||||
{"zuc256", D_ZUC256},
|
|
||||||
#endif
|
#endif
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
@@ -1124,23 +1123,91 @@ static long sm9sign_c[SM9_NUM][2];
|
|||||||
|
|
||||||
static int SM9_sign_loop(void *args)
|
static int SM9_sign_loop(void *args)
|
||||||
{
|
{
|
||||||
return 1;
|
loopargs_t *tempargs = *(loopargs_t **)args;
|
||||||
|
unsigned char *buf = tempargs->buf;
|
||||||
|
SM9PrivateKey **sm9 = tempargs->sm9sk;
|
||||||
|
unsigned char *sm9sig = tempargs->buf2;
|
||||||
|
unsigned int *sm9siglen = &tempargs->siglen;
|
||||||
|
int ret, count;
|
||||||
|
for (count = 0; COND(sm9sign_c[testnum][0]); count++) {
|
||||||
|
ret = SM9_sign(NID_sm3, buf, 32, sm9sig, sm9siglen, sm9[testnum]);
|
||||||
|
if (ret == 0) {
|
||||||
|
BIO_printf(bio_err, "SM9 sign failure\n");
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
count = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char* sm9verify_id = "sm9_verify";
|
||||||
|
static size_t sm9verify_idlen = 10;
|
||||||
static int SM9_verify_loop(void *args)
|
static int SM9_verify_loop(void *args)
|
||||||
{
|
{
|
||||||
return 1;
|
loopargs_t *tempargs = *(loopargs_t **)args;
|
||||||
|
unsigned char *buf = tempargs->buf;
|
||||||
|
SM9PublicParameters **sm9 = tempargs->sm9mpk;
|
||||||
|
unsigned char *sm9sig = tempargs->buf2;
|
||||||
|
unsigned int sm9siglen = tempargs->siglen;
|
||||||
|
int ret, count;
|
||||||
|
for (count = 0; COND(sm9sign_c[testnum][1]); count++) {
|
||||||
|
ret = SM9_verify(NID_sm3, buf, 32, sm9sig, sm9siglen, sm9[testnum], sm9verify_id, sm9verify_idlen);
|
||||||
|
if (ret != 1) {
|
||||||
|
BIO_printf(bio_err, "SM9 verify failure\n");
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
count = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static long sm9enc_c[SM9_NUM][2];
|
static long sm9enc_c[SM9_NUM][2];
|
||||||
|
static char* sm9enc_id = "sm9_enc";
|
||||||
|
static size_t sm9enc_idlen = 7;
|
||||||
static int SM9_encrypt_loop(void *args)
|
static int SM9_encrypt_loop(void *args)
|
||||||
{
|
{
|
||||||
return 1;
|
loopargs_t *tempargs = *(loopargs_t **)args;
|
||||||
|
unsigned char *buf = tempargs->buf;
|
||||||
|
SM9PublicParameters **sm9 = tempargs->sm9mpk;
|
||||||
|
unsigned char *sm9cipher = tempargs->buf2;
|
||||||
|
size_t *sm9cipherlen = &tempargs->cipherlen;
|
||||||
|
int ret, count;
|
||||||
|
for (count = 0; COND(sm9enc_c[testnum][0]); count++) {
|
||||||
|
*sm9cipherlen = BUFSIZE;
|
||||||
|
ret = SM9_encrypt(NID_sm3, buf, 32, sm9cipher,
|
||||||
|
sm9cipherlen, sm9[testnum], sm9enc_id, sm9enc_idlen);
|
||||||
|
if (ret == 0) {
|
||||||
|
BIO_printf(bio_err, "SM9 encrypt failure\n");
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
count = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SM9_decrypt_loop(void *args)
|
static int SM9_decrypt_loop(void *args)
|
||||||
{
|
{
|
||||||
return 1;
|
loopargs_t *tempargs = *(loopargs_t **)args;
|
||||||
|
unsigned char *buf = tempargs->buf;
|
||||||
|
SM9PrivateKey **sm9 = tempargs->sm9sk;
|
||||||
|
unsigned char *sm9cipher = tempargs->buf2;
|
||||||
|
size_t sm9cipherlen = tempargs->cipherlen;
|
||||||
|
int ret, count;
|
||||||
|
for (count = 0; COND(sm9enc_c[testnum][0]); count++) {
|
||||||
|
size_t len = sm9cipherlen;
|
||||||
|
ret = SM9_decrypt(NID_sm3, sm9cipher, sm9cipherlen,
|
||||||
|
buf, &len, sm9[testnum]);
|
||||||
|
if (ret == 0) {
|
||||||
|
BIO_printf(bio_err, "SM9 decrypt failure\n");
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
count = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1506,7 +1573,6 @@ int speed_main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
#ifndef OPENSSL_NO_ZUC
|
#ifndef OPENSSL_NO_ZUC
|
||||||
ZUC_KEY zuc_ks;
|
ZUC_KEY zuc_ks;
|
||||||
ZUC256_KEY zuc256_ks;
|
|
||||||
#endif
|
#endif
|
||||||
#ifndef OPENSSL_NO_BF
|
#ifndef OPENSSL_NO_BF
|
||||||
BF_KEY bf_ks;
|
BF_KEY bf_ks;
|
||||||
@@ -1642,6 +1708,12 @@ int speed_main(int argc, char **argv)
|
|||||||
static const int test_sm9_curves_bits[SM9_NUM] = {
|
static const int test_sm9_curves_bits[SM9_NUM] = {
|
||||||
256,
|
256,
|
||||||
};
|
};
|
||||||
|
static const int test_sm9_scheme[SM9_NUM] = {
|
||||||
|
NID_sm9sign,
|
||||||
|
};
|
||||||
|
static const int test_sm9_hash1[SM9_NUM] = {
|
||||||
|
NID_sm9hash1_with_sm3,
|
||||||
|
};
|
||||||
int sm9sign_doit[SM9_NUM] = { 0 };
|
int sm9sign_doit[SM9_NUM] = { 0 };
|
||||||
int sm9enc_doit[SM9_NUM] = { 0 };
|
int sm9enc_doit[SM9_NUM] = { 0 };
|
||||||
#endif
|
#endif
|
||||||
@@ -2001,7 +2073,6 @@ int speed_main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
#ifndef OPENSSL_NO_ZUC
|
#ifndef OPENSSL_NO_ZUC
|
||||||
ZUC_set_key(&zuc_ks, key16, iv);
|
ZUC_set_key(&zuc_ks, key16, iv);
|
||||||
ZUC256_set_key(&zuc256_ks, key32, iv);
|
|
||||||
#endif
|
#endif
|
||||||
#ifndef OPENSSL_NO_RC4
|
#ifndef OPENSSL_NO_RC4
|
||||||
RC4_set_key(&rc4_ks, 16, key16);
|
RC4_set_key(&rc4_ks, 16, key16);
|
||||||
@@ -2064,7 +2135,6 @@ int speed_main(int argc, char **argv)
|
|||||||
c[D_SM3][0] = count;
|
c[D_SM3][0] = count;
|
||||||
c[D_CBC_SMS4][0] = count;
|
c[D_CBC_SMS4][0] = count;
|
||||||
c[D_ZUC][0] = count;
|
c[D_ZUC][0] = count;
|
||||||
c[D_ZUC256][0] = count;
|
|
||||||
|
|
||||||
for (i = 1; i < SIZE_NUM; i++) {
|
for (i = 1; i < SIZE_NUM; i++) {
|
||||||
long l0, l1;
|
long l0, l1;
|
||||||
@@ -2107,7 +2177,6 @@ int speed_main(int argc, char **argv)
|
|||||||
c[D_IGE_256_AES][i] = c[D_IGE_256_AES][i - 1] * l0 / l1;
|
c[D_IGE_256_AES][i] = c[D_IGE_256_AES][i - 1] * l0 / l1;
|
||||||
c[D_CBC_SMS4][i] = c[D_CBC_SMS4][i - 1] * l0 / l1;
|
c[D_CBC_SMS4][i] = c[D_CBC_SMS4][i - 1] * l0 / l1;
|
||||||
c[D_ZUC][i] = c[D_ZUC][i - 1] * l0 / l1;
|
c[D_ZUC][i] = c[D_ZUC][i - 1] * l0 / l1;
|
||||||
c[D_ZUC256][i] = c[D_ZUC256][i - 1] * l0 / l1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifndef OPENSSL_NO_RSA
|
# ifndef OPENSSL_NO_RSA
|
||||||
@@ -2627,22 +2696,6 @@ int speed_main(int argc, char **argv)
|
|||||||
print_result(D_ZUC, testnum, count, d);
|
print_result(D_ZUC, testnum, count, d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (doit[D_ZUC256]) {
|
|
||||||
if (async_jobs > 0) {
|
|
||||||
BIO_printf(bio_err, "Async mode is not supported with %s\n",
|
|
||||||
names[D_ZUC256]);
|
|
||||||
doit[D_ZUC256] = 0;
|
|
||||||
}
|
|
||||||
for (testnum = 0; testnum < SIZE_NUM && async_init == 0; testnum++) {
|
|
||||||
print_message(names[D_ZUC256], c[D_ZUC256][testnum], lengths[testnum]);
|
|
||||||
Time_F(START);
|
|
||||||
for (count = 0, run = 1; COND(c[D_ZUC256][testnum]); count++)
|
|
||||||
ZUC256_generate_keystream(&zuc256_ks, lengths[testnum]/4,
|
|
||||||
(unsigned int *)loopargs[0].buf);
|
|
||||||
d = Time_F(STOP);
|
|
||||||
print_result(D_ZUC256, testnum, count, d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#ifndef OPENSSL_NO_RC2
|
#ifndef OPENSSL_NO_RC2
|
||||||
if (doit[D_CBC_RC2]) {
|
if (doit[D_CBC_RC2]) {
|
||||||
@@ -3281,7 +3334,181 @@ int speed_main(int argc, char **argv)
|
|||||||
#endif /* OPENSSL_NO_SM2 */
|
#endif /* OPENSSL_NO_SM2 */
|
||||||
#ifndef OPENSSL_NO_SM9
|
#ifndef OPENSSL_NO_SM9
|
||||||
|
|
||||||
//FIXME: this is the core code,
|
if (RAND_status() != 1) {
|
||||||
|
RAND_seed(rnd_seed, sizeof rnd_seed);
|
||||||
|
}
|
||||||
|
for (testnum = 0; testnum < SM9_NUM; testnum++) {
|
||||||
|
int st = 1;
|
||||||
|
|
||||||
|
if (!sm9sign_doit[testnum])
|
||||||
|
continue; /* Ignore Curve */
|
||||||
|
for (i = 0; i < loopargs_len; i++) {
|
||||||
|
loopargs[i].sm9mst[testnum] = SM9_generate_master_secret(test_sm9_curves[testnum],
|
||||||
|
test_sm9_scheme[testnum], test_sm9_hash1[testnum]);
|
||||||
|
if (loopargs[i].sm9mst[testnum] == NULL) {
|
||||||
|
st = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (st == 0) {
|
||||||
|
BIO_printf(bio_err, "SM9 failure.\n");
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
rsa_count = 1;
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < loopargs_len; i++) {
|
||||||
|
/* Perform SM9 signature test */
|
||||||
|
loopargs[i].sm9sk[testnum] = SM9_extract_private_key(loopargs[i].sm9mst[testnum], sm9verify_id, sm9verify_idlen);
|
||||||
|
st = SM9_sign(NID_sm3, loopargs[i].buf, 32, loopargs[i].buf2,
|
||||||
|
&loopargs[i].siglen, loopargs[i].sm9sk[testnum]);
|
||||||
|
if (st == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (st == 0) {
|
||||||
|
BIO_printf(bio_err,
|
||||||
|
"SM9 sign failure. No SM9 sign will be done.\n");
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
rsa_count = 1;
|
||||||
|
} else {
|
||||||
|
pkey_print_message("sign", "sm9",
|
||||||
|
sm9sign_c[testnum][0],
|
||||||
|
test_sm9_curves_bits[testnum], ECDSA_SECONDS);
|
||||||
|
Time_F(START);
|
||||||
|
count = run_benchmark(async_jobs, SM9_sign_loop, loopargs);
|
||||||
|
d = Time_F(STOP);
|
||||||
|
|
||||||
|
BIO_printf(bio_err,
|
||||||
|
mr ? "+R7:%ld:%d:%.2f\n" :
|
||||||
|
"%ld %d bit SM9 signs in %.2fs \n",
|
||||||
|
count, test_sm9_curves_bits[testnum], d);
|
||||||
|
sm9sign_results[testnum][0] = d / (double)count;
|
||||||
|
rsa_count = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Perform SM9 verification test */
|
||||||
|
for (i = 0; i < loopargs_len; i++) {
|
||||||
|
loopargs[i].sm9mpk[testnum] = SM9_extract_public_parameters(loopargs[i].sm9mst[testnum]);
|
||||||
|
st = SM9_verify(NID_sm3, loopargs[i].buf, 32, loopargs[i].buf2,
|
||||||
|
loopargs[i].siglen, loopargs[i].sm9mpk[testnum], sm9verify_id, sm9verify_idlen);
|
||||||
|
if (st != 1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (st != 1) {
|
||||||
|
BIO_printf(bio_err,
|
||||||
|
"SM9 verify failure. No SM9 verify will be done.\n");
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
sm9sign_doit[testnum] = 0;
|
||||||
|
} else {
|
||||||
|
pkey_print_message("verify", "sm9",
|
||||||
|
sm9sign_c[testnum][1],
|
||||||
|
test_sm9_curves_bits[testnum], ECDSA_SECONDS);
|
||||||
|
Time_F(START);
|
||||||
|
count = run_benchmark(async_jobs, SM9_verify_loop, loopargs);
|
||||||
|
d = Time_F(STOP);
|
||||||
|
BIO_printf(bio_err,
|
||||||
|
mr ? "+R8:%ld:%d:%.2f\n"
|
||||||
|
: "%ld %d bit SM9 verify in %.2fs\n",
|
||||||
|
count, test_sm9_curves_bits[testnum], d);
|
||||||
|
sm9sign_results[testnum][1] = d / (double)count;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rsa_count <= 1) {
|
||||||
|
/* if longer than 10s, don't do any more */
|
||||||
|
for (testnum++; testnum < SM9_NUM; testnum++)
|
||||||
|
sm9sign_doit[testnum] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (RAND_status() != 1) {
|
||||||
|
RAND_seed(rnd_seed, sizeof rnd_seed);
|
||||||
|
}
|
||||||
|
for (testnum = 0; testnum < SM9_NUM; testnum++) {
|
||||||
|
int st = 1;
|
||||||
|
|
||||||
|
if (!sm9enc_doit[testnum])
|
||||||
|
continue;
|
||||||
|
for (i = 0; i < loopargs_len; i++) {
|
||||||
|
loopargs[i].sm9mst[testnum] = SM9_generate_master_secret(test_sm9_curves[testnum],
|
||||||
|
test_sm9_scheme[testnum], test_sm9_hash1[testnum]);
|
||||||
|
if (loopargs[i].sm9mst[testnum] == NULL) {
|
||||||
|
st = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (st == 0) {
|
||||||
|
BIO_printf(bio_err, "SM9 failure.\n");
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
rsa_count = 1;
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < loopargs_len; i++) {
|
||||||
|
/* these 2 lines should be modified ? */
|
||||||
|
/*if (!nopre)
|
||||||
|
EC_KEY_precompute_mult(loopargs[i].sm9[testnum], NULL);*/
|
||||||
|
/* Perform SM9 encryption test */
|
||||||
|
loopargs[i].sm9mpk[testnum] = SM9_extract_public_parameters(loopargs[i].sm9mst[testnum]);
|
||||||
|
loopargs[i].cipherlen = BUFSIZE;
|
||||||
|
st = SM9_encrypt(NID_sm3, loopargs[i].buf, 32, loopargs[i].buf2,
|
||||||
|
&loopargs[i].cipherlen, loopargs[i].sm9mpk[testnum], sm9enc_id, sm9enc_idlen);
|
||||||
|
if (st == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (st == 0) {
|
||||||
|
BIO_printf(bio_err,
|
||||||
|
"SM9 encryption failure. No SM9 encryption will be done.\n");
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
rsa_count = 1;
|
||||||
|
} else {
|
||||||
|
pkey_print_message("encrypt", "sm9",
|
||||||
|
sm9enc_c[testnum][0],
|
||||||
|
test_sm9_curves_bits[testnum], ECDSA_SECONDS);
|
||||||
|
Time_F(START);
|
||||||
|
count = run_benchmark(async_jobs, SM9_encrypt_loop, loopargs);
|
||||||
|
d = Time_F(STOP);
|
||||||
|
|
||||||
|
BIO_printf(bio_err,
|
||||||
|
mr ? "+R7:%ld:%d:%.2f\n" :
|
||||||
|
"%ld %d bit SM9 encrypt in %.2fs \n",
|
||||||
|
count, test_sm9_curves_bits[testnum], d);
|
||||||
|
sm9enc_results[testnum][0] = d / (double)count;
|
||||||
|
rsa_count = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Perform SM9 verification test */
|
||||||
|
for (i = 0; i < loopargs_len; i++) {
|
||||||
|
loopargs[i].sm9sk[testnum] = SM9_extract_private_key(loopargs[i].sm9mst[testnum], sm9enc_id, sm9enc_idlen);
|
||||||
|
size_t len = loopargs[i].cipherlen;
|
||||||
|
st = SM9_decrypt(NID_sm3, loopargs[i].buf2, loopargs[i].cipherlen,
|
||||||
|
loopargs[i].buf, &len, loopargs[i].sm9sk[testnum]);
|
||||||
|
if (st == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (st != 1) {
|
||||||
|
BIO_printf(bio_err,
|
||||||
|
"SM9 decrypt failure. No SM9 decrypt will be done.\n");
|
||||||
|
ERR_print_errors(bio_err);
|
||||||
|
sm9enc_doit[testnum] = 0;
|
||||||
|
} else {
|
||||||
|
pkey_print_message("decrypt", "sm9",
|
||||||
|
sm9enc_c[testnum][1],
|
||||||
|
test_sm9_curves_bits[testnum], ECDSA_SECONDS);
|
||||||
|
Time_F(START);
|
||||||
|
count = run_benchmark(async_jobs, SM9_decrypt_loop, loopargs);
|
||||||
|
d = Time_F(STOP);
|
||||||
|
BIO_printf(bio_err,
|
||||||
|
mr ? "+R8:%ld:%d:%.2f\n"
|
||||||
|
: "%ld %d bit SM9 decrypt in %.2fs\n",
|
||||||
|
count, test_sm9_curves_bits[testnum], d);
|
||||||
|
sm9enc_results[testnum][1] = d / (double)count;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rsa_count <= 1) {
|
||||||
|
/* if longer than 10s, don't do any more */
|
||||||
|
for (testnum++; testnum < SM9_NUM; testnum++)
|
||||||
|
sm9sign_doit[testnum] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* OPENSSL_NO_SM9 */
|
#endif /* OPENSSL_NO_SM9 */
|
||||||
#ifndef NO_FORK
|
#ifndef NO_FORK
|
||||||
@@ -3552,6 +3779,7 @@ int speed_main(int argc, char **argv)
|
|||||||
for (k = 0; k < SM9_NUM; k++) {
|
for (k = 0; k < SM9_NUM; k++) {
|
||||||
SM9PublicParameters_free(loopargs[i].sm9mpk[k]);
|
SM9PublicParameters_free(loopargs[i].sm9mpk[k]);
|
||||||
SM9PrivateKey_free(loopargs[i].sm9sk[k]);
|
SM9PrivateKey_free(loopargs[i].sm9sk[k]);
|
||||||
|
SM9MasterSecret_free(loopargs[i].sm9mst[k]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
#include <openssl/sm9.h>
|
#include <openssl/sm9.h>
|
||||||
|
#include <openssl/ec_type1.h>
|
||||||
|
#include <openssl/bn_hash.h>
|
||||||
#include "sm9_lcl.h"
|
#include "sm9_lcl.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -302,7 +304,8 @@ SM9_KEY *SM9_MASTER_KEY_extract_key(SM9_MASTER_KEY *master,
|
|||||||
sk = NULL;
|
sk = NULL;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
EC_GROUP_free(group);
|
SM9PrivateKey_free(sk);
|
||||||
|
EC_GROUP_clear_free(group);
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
BN_CTX_end(ctx);
|
BN_CTX_end(ctx);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,7 +166,6 @@ static int fp2_equ(const fp2_t a, const fp2_t b)
|
|||||||
return !BN_cmp(a[0], b[0]) && !BN_cmp(a[1], b[1]);
|
return !BN_cmp(a[0], b[0]) && !BN_cmp(a[1], b[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SM9_TEST
|
|
||||||
static int fp2_equ_hex(const fp2_t a, const char *str[2], BN_CTX *ctx)
|
static int fp2_equ_hex(const fp2_t a, const char *str[2], BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
fp2_t t;
|
fp2_t t;
|
||||||
@@ -174,9 +173,7 @@ static int fp2_equ_hex(const fp2_t a, const char *str[2], BN_CTX *ctx)
|
|||||||
fp2_set_hex(t, str);
|
fp2_set_hex(t, str);
|
||||||
return fp2_equ(a, t);
|
return fp2_equ(a, t);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if SM9_TEST
|
|
||||||
static int fp2_add_word(fp2_t r, const fp2_t a, unsigned long b, const BIGNUM *p, BN_CTX *ctx)
|
static int fp2_add_word(fp2_t r, const fp2_t a, unsigned long b, const BIGNUM *p, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
BIGNUM *w = NULL;
|
BIGNUM *w = NULL;
|
||||||
@@ -190,7 +187,6 @@ static int fp2_add_word(fp2_t r, const fp2_t a, unsigned long b, const BIGNUM *p
|
|||||||
BN_free(w);
|
BN_free(w);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int fp2_add(fp2_t r, const fp2_t a, const fp2_t b, const BIGNUM *p, BN_CTX *ctx)
|
static int fp2_add(fp2_t r, const fp2_t a, const fp2_t b, const BIGNUM *p, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
@@ -430,13 +426,11 @@ static int fp2_inv(fp2_t r, const fp2_t a, const BIGNUM *p, BN_CTX *ctx)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SM9_TEST
|
|
||||||
static int fp2_div(fp2_t r, const fp2_t a, const fp2_t b, const BIGNUM *p, BN_CTX *ctx)
|
static int fp2_div(fp2_t r, const fp2_t a, const fp2_t b, const BIGNUM *p, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
return fp2_inv(r, b, p, ctx)
|
return fp2_inv(r, b, p, ctx)
|
||||||
&& fp2_mul(r, a, r, p, ctx);
|
&& fp2_mul(r, a, r, p, ctx);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int fp2_to_bin(const fp2_t a, unsigned char to[64])
|
static int fp2_to_bin(const fp2_t a, unsigned char to[64])
|
||||||
{
|
{
|
||||||
@@ -452,7 +446,6 @@ static int fp2_from_bin(fp2_t a, const unsigned char from[64])
|
|||||||
&& BN_bin2bn(from + 32, 32, a[0]);
|
&& BN_bin2bn(from + 32, 32, a[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SM9_TEST
|
|
||||||
static int fp2_test(const BIGNUM *p, BN_CTX *ctx)
|
static int fp2_test(const BIGNUM *p, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
const char *_a[] = {
|
const char *_a[] = {
|
||||||
@@ -568,7 +561,6 @@ static int fp2_test(const BIGNUM *p, BN_CTX *ctx)
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int fp4_init(fp4_t a, BN_CTX *ctx)
|
static int fp4_init(fp4_t a, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
@@ -588,13 +580,11 @@ static void fp4_cleanup(fp4_t a)
|
|||||||
fp2_cleanup(a[1]);
|
fp2_cleanup(a[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SM9_TEST
|
|
||||||
static void fp4_clear_cleanup(fp4_t a)
|
static void fp4_clear_cleanup(fp4_t a)
|
||||||
{
|
{
|
||||||
fp2_clear_cleanup(a[0]);
|
fp2_clear_cleanup(a[0]);
|
||||||
fp2_clear_cleanup(a[1]);
|
fp2_clear_cleanup(a[1]);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int fp4_print(const fp4_t a)
|
static int fp4_print(const fp4_t a)
|
||||||
{
|
{
|
||||||
@@ -682,7 +672,6 @@ static int fp4_equ(const fp4_t a, const fp4_t b)
|
|||||||
&& fp2_equ(a[1], b[1]);
|
&& fp2_equ(a[1], b[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SM9_TEST
|
|
||||||
static int fp4_equ_hex(const fp4_t a, const char *str[4], BN_CTX *ctx)
|
static int fp4_equ_hex(const fp4_t a, const char *str[4], BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
fp4_t t;
|
fp4_t t;
|
||||||
@@ -690,7 +679,6 @@ static int fp4_equ_hex(const fp4_t a, const char *str[4], BN_CTX *ctx)
|
|||||||
fp4_set_hex(t, str);
|
fp4_set_hex(t, str);
|
||||||
return fp4_equ(a, t);
|
return fp4_equ(a, t);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int fp4_to_bin(const fp4_t a, unsigned char to[128])
|
static int fp4_to_bin(const fp4_t a, unsigned char to[128])
|
||||||
{
|
{
|
||||||
@@ -875,7 +863,6 @@ static int fp4_inv(fp4_t r, const fp4_t a, const BIGNUM *p, BN_CTX *ctx)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SM9_TEST
|
|
||||||
static int fp4_test(const BIGNUM *p, BN_CTX *ctx)
|
static int fp4_test(const BIGNUM *p, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
const char *_a[] = {
|
const char *_a[] = {
|
||||||
@@ -1012,7 +999,6 @@ static int fp4_test(const BIGNUM *p, BN_CTX *ctx)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
int fp12_init(fp12_t a, BN_CTX *ctx)
|
int fp12_init(fp12_t a, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
@@ -1035,14 +1021,12 @@ void fp12_cleanup(fp12_t a)
|
|||||||
fp4_cleanup(a[2]);
|
fp4_cleanup(a[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SM9_TEST
|
|
||||||
static void fp12_clear_cleanup(fp12_t a)
|
static void fp12_clear_cleanup(fp12_t a)
|
||||||
{
|
{
|
||||||
fp4_clear_cleanup(a[0]);
|
fp4_clear_cleanup(a[0]);
|
||||||
fp4_clear_cleanup(a[1]);
|
fp4_clear_cleanup(a[1]);
|
||||||
fp4_clear_cleanup(a[2]);
|
fp4_clear_cleanup(a[2]);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
int fp12_print(const fp12_t a)
|
int fp12_print(const fp12_t a)
|
||||||
{
|
{
|
||||||
@@ -1052,7 +1036,6 @@ int fp12_print(const fp12_t a)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SM9_TEST
|
|
||||||
static int fp12_is_zero(const fp12_t a)
|
static int fp12_is_zero(const fp12_t a)
|
||||||
{
|
{
|
||||||
return fp4_is_zero(a[0])
|
return fp4_is_zero(a[0])
|
||||||
@@ -1073,7 +1056,6 @@ static void fp12_set_zero(fp12_t r)
|
|||||||
fp4_set_zero(r[1]);
|
fp4_set_zero(r[1]);
|
||||||
fp4_set_zero(r[2]);
|
fp4_set_zero(r[2]);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int fp12_set_one(fp12_t r)
|
static int fp12_set_one(fp12_t r)
|
||||||
{
|
{
|
||||||
@@ -1089,14 +1071,12 @@ static int fp12_copy(fp12_t r, const fp12_t a)
|
|||||||
&& fp4_copy(r[2], a[2]);
|
&& fp4_copy(r[2], a[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SM9_TEST
|
|
||||||
static int fp12_set(fp12_t r, const fp4_t a0, const fp4_t a1, const fp4_t a2)
|
static int fp12_set(fp12_t r, const fp4_t a0, const fp4_t a1, const fp4_t a2)
|
||||||
{
|
{
|
||||||
return fp4_copy(r[0], a0)
|
return fp4_copy(r[0], a0)
|
||||||
&& fp4_copy(r[1], a1)
|
&& fp4_copy(r[1], a1)
|
||||||
&& fp4_copy(r[2], a2);
|
&& fp4_copy(r[2], a2);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int fp12_set_hex(fp12_t r, const char *str[12])
|
static int fp12_set_hex(fp12_t r, const char *str[12])
|
||||||
{
|
{
|
||||||
@@ -1105,14 +1085,12 @@ static int fp12_set_hex(fp12_t r, const char *str[12])
|
|||||||
&& fp4_set_hex(r[2], str + 8);
|
&& fp4_set_hex(r[2], str + 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SM9_TEST
|
|
||||||
static int fp12_set_fp4(fp12_t r, const fp4_t a)
|
static int fp12_set_fp4(fp12_t r, const fp4_t a)
|
||||||
{
|
{
|
||||||
fp4_set_zero(r[1]);
|
fp4_set_zero(r[1]);
|
||||||
fp4_set_zero(r[2]);
|
fp4_set_zero(r[2]);
|
||||||
return fp4_copy(r[0], a);
|
return fp4_copy(r[0], a);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int fp12_set_fp2(fp12_t r, const fp2_t a)
|
static int fp12_set_fp2(fp12_t r, const fp2_t a)
|
||||||
{
|
{
|
||||||
@@ -1128,7 +1106,6 @@ static int fp12_set_bn(fp12_t r, const BIGNUM *a)
|
|||||||
return fp4_set_bn(r[0], a);
|
return fp4_set_bn(r[0], a);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SM9_TEST
|
|
||||||
static int fp12_set_word(fp12_t r, unsigned long a)
|
static int fp12_set_word(fp12_t r, unsigned long a)
|
||||||
{
|
{
|
||||||
fp4_set_zero(r[1]);
|
fp4_set_zero(r[1]);
|
||||||
@@ -1142,7 +1119,6 @@ static int fp12_set_u(fp12_t r)
|
|||||||
fp4_set_zero(r[2]);
|
fp4_set_zero(r[2]);
|
||||||
return fp4_set_u(r[0]);
|
return fp4_set_u(r[0]);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int fp12_set_v(fp12_t r)
|
static int fp12_set_v(fp12_t r)
|
||||||
{
|
{
|
||||||
@@ -1151,14 +1127,12 @@ static int fp12_set_v(fp12_t r)
|
|||||||
return fp4_set_v(r[0]);
|
return fp4_set_v(r[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SM9_TEST
|
|
||||||
static int fp12_set_w(fp12_t r)
|
static int fp12_set_w(fp12_t r)
|
||||||
{
|
{
|
||||||
fp4_set_zero(r[0]);
|
fp4_set_zero(r[0]);
|
||||||
fp4_set_zero(r[2]);
|
fp4_set_zero(r[2]);
|
||||||
return fp4_set_one(r[1]);
|
return fp4_set_one(r[1]);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int fp12_set_w_sqr(fp12_t r)
|
static int fp12_set_w_sqr(fp12_t r)
|
||||||
{
|
{
|
||||||
@@ -1174,7 +1148,6 @@ static int fp12_equ(const fp12_t a, const fp12_t b)
|
|||||||
&& fp4_equ(a[2], b[2]);
|
&& fp4_equ(a[2], b[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SM9_TEST
|
|
||||||
static int fp12_equ_hex(const fp12_t a, const char *str[12], BN_CTX *ctx)
|
static int fp12_equ_hex(const fp12_t a, const char *str[12], BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
fp12_t t;
|
fp12_t t;
|
||||||
@@ -1182,7 +1155,6 @@ static int fp12_equ_hex(const fp12_t a, const char *str[12], BN_CTX *ctx)
|
|||||||
fp12_set_hex(t, str);
|
fp12_set_hex(t, str);
|
||||||
return fp12_equ(a, t);
|
return fp12_equ(a, t);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
int fp12_to_bin(const fp12_t a, unsigned char to[384])
|
int fp12_to_bin(const fp12_t a, unsigned char to[384])
|
||||||
{
|
{
|
||||||
@@ -1193,13 +1165,14 @@ int fp12_to_bin(const fp12_t a, unsigned char to[384])
|
|||||||
|
|
||||||
static int fp12_from_bin(fp4_t a, const unsigned char from[384])
|
static int fp12_from_bin(fp4_t a, const unsigned char from[384])
|
||||||
{
|
{
|
||||||
return fp4_from_bin(&a[2], from)
|
return fp4_from_bin(a[2], from)
|
||||||
&& fp4_from_bin(&a[1], from + 128)
|
&& fp4_from_bin(a[1], from + 128)
|
||||||
&& fp4_from_bin(&a[0], from + 256);
|
&& fp4_from_bin(a[0], from + 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fp12_add(fp12_t r, const fp12_t a, const fp12_t b, const BIGNUM *p, BN_CTX *ctx)
|
static int fp12_add(fp12_t r, const fp12_t a, const fp12_t b, const BIGNUM *p, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
|
|
||||||
return fp4_add(r[0], a[0], b[0], p, ctx)
|
return fp4_add(r[0], a[0], b[0], p, ctx)
|
||||||
&& fp4_add(r[1], a[1], b[1], p, ctx)
|
&& fp4_add(r[1], a[1], b[1], p, ctx)
|
||||||
&& fp4_add(r[2], a[2], b[2], p, ctx);
|
&& fp4_add(r[2], a[2], b[2], p, ctx);
|
||||||
@@ -1470,8 +1443,6 @@ int fp12_pow(fp12_t r, const fp12_t a, const BIGNUM *k, const BIGNUM *p, BN_CTX
|
|||||||
}
|
}
|
||||||
|
|
||||||
fp12_copy(r, t);
|
fp12_copy(r, t);
|
||||||
|
|
||||||
fp12_cleanup(t);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1508,7 +1479,6 @@ static int fp12_fast_expo_p2(fp12_t r, const fp12_t a, const BIGNUM *p, BN_CTX *
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SM9_TEST
|
|
||||||
static int fp12_test(const BIGNUM *p, BN_CTX *ctx)
|
static int fp12_test(const BIGNUM *p, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
const char *_a[] = {
|
const char *_a[] = {
|
||||||
@@ -1792,7 +1762,6 @@ static int fp12_test(const BIGNUM *p, BN_CTX *ctx)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
int point_init(point_t *P, BN_CTX *ctx)
|
int point_init(point_t *P, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
@@ -2226,7 +2195,6 @@ int point_mul_generator(point_t *R, const BIGNUM *k, const BIGNUM *p, BN_CTX *ct
|
|||||||
return point_mul(R, k, &G, p, ctx);
|
return point_mul(R, k, &G, p, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SM9_TEST
|
|
||||||
static int point_test(const BIGNUM *p, BN_CTX *ctx)
|
static int point_test(const BIGNUM *p, BN_CTX *ctx)
|
||||||
{
|
{
|
||||||
const char *_G[] = {
|
const char *_G[] = {
|
||||||
@@ -2327,7 +2295,6 @@ static int point_test(const BIGNUM *p, BN_CTX *ctx)
|
|||||||
//fp12_cleanup(y);
|
//fp12_cleanup(y);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int eval_tangent(fp12_t r, const point_t *T, const BIGNUM *xP, const BIGNUM *yP,
|
static int eval_tangent(fp12_t r, const point_t *T, const BIGNUM *xP, const BIGNUM *yP,
|
||||||
const BIGNUM *p, BN_CTX *ctx)
|
const BIGNUM *p, BN_CTX *ctx)
|
||||||
@@ -2478,8 +2445,6 @@ static int final_expo(fp12_t r, const fp12_t a, const BIGNUM *k, const BIGNUM *p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fp12_copy(r, t);
|
fp12_copy(r, t);
|
||||||
|
|
||||||
fp12_cleanup(t);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2538,9 +2503,6 @@ static int fast_final_expo(fp12_t r, const fp12_t a, const BIGNUM *k, const BIGN
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fp12_copy(r, t);
|
fp12_copy(r, t);
|
||||||
|
|
||||||
fp12_cleanup(t);
|
|
||||||
fp12_cleanup(t0);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2697,10 +2659,10 @@ int rate_pairing(fp12_t r, const point_t *Q, const EC_POINT *P, BN_CTX *ctx)
|
|||||||
|
|
||||||
BN_free(xP);
|
BN_free(xP);
|
||||||
BN_free(yP);
|
BN_free(yP);
|
||||||
|
EC_GROUP_clear_free(group);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SM9_TEST
|
|
||||||
static int rate_test(void)
|
static int rate_test(void)
|
||||||
{
|
{
|
||||||
const char *Ppubs_str[] = {
|
const char *Ppubs_str[] = {
|
||||||
@@ -2750,7 +2712,6 @@ static int rate_test(void)
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* for SM9 sign, the (xP, yP) is the fixed generator of E(Fp)
|
/* for SM9 sign, the (xP, yP) is the fixed generator of E(Fp)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -51,6 +51,8 @@
|
|||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
#include <openssl/sm9.h>
|
#include <openssl/sm9.h>
|
||||||
#include <openssl/ec.h>
|
#include <openssl/ec.h>
|
||||||
|
#include <openssl/ec_type1.h>
|
||||||
|
#include <openssl/bn_gfp2.h>
|
||||||
#include "sm9_lcl.h"
|
#include "sm9_lcl.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -196,6 +198,8 @@ end:
|
|||||||
BN_free(r);
|
BN_free(r);
|
||||||
point_cleanup(&Ppubs);
|
point_cleanup(&Ppubs);
|
||||||
fp12_cleanup(w);
|
fp12_cleanup(w);
|
||||||
|
BN_CTX_end(bn_ctx);
|
||||||
|
BN_CTX_free(bn_ctx);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,9 +357,7 @@ end:
|
|||||||
point_cleanup(&P);
|
point_cleanup(&P);
|
||||||
fp12_cleanup(w);
|
fp12_cleanup(w);
|
||||||
fp12_cleanup(u);
|
fp12_cleanup(u);
|
||||||
if (bn_ctx) {
|
|
||||||
BN_CTX_end(bn_ctx);
|
BN_CTX_end(bn_ctx);
|
||||||
}
|
|
||||||
BN_CTX_free(bn_ctx);
|
BN_CTX_free(bn_ctx);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user