
From: lizhi <lizhi206@huawei.com> Adapt benchmark tool to support secp256r1 and replace original secp256k1. Signed-off-by: lizhi <lizhi206@huawei.com> Signed-off-by: Qi Tao <taoqi10@huawei.com> --- uadk_tool/benchmark/hpre_uadk_benchmark.c | 30 +++++------------------ uadk_tool/benchmark/uadk_benchmark.c | 3 +-- uadk_tool/benchmark/uadk_benchmark.h | 3 +-- 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/uadk_tool/benchmark/hpre_uadk_benchmark.c b/uadk_tool/benchmark/hpre_uadk_benchmark.c index 585d70af..70d81fef 100644 --- a/uadk_tool/benchmark/hpre_uadk_benchmark.c +++ b/uadk_tool/benchmark/hpre_uadk_benchmark.c @@ -11,8 +11,7 @@ #include "include/wd_ecc.h" #include "include/wd_sched.h" -#define ECC_CURVE_SECP256K1 0x3 /* def set with secp256k1 */ -#define ECC_CURVE_SECP256R1 0x7 /* optional set with secp256r1 */ +#define ECC_CURVE_SECP256R1 0x3 /* default set with secp256r1 */ #define HPRE_TST_PRT printf #define ERR_OPTYPE 0xFF #define SM2_DG_SZ 1024 @@ -220,9 +219,6 @@ static void get_ecc_param(u32 algtype, u32 *keysize) case ECDH_256: *keysize = 256; break; - case ECDH_256R1: - *keysize = 256; - break; case ECDH_384: *keysize = 384; break; @@ -1022,9 +1018,9 @@ static int get_ecc_curve(struct hpre_ecc_setup *setup, u32 cid) setup->nid = 712; setup->curve_id = WD_SECP224R1; break; - case 3: // secp256K1 - setup->nid = 714; - setup->curve_id = WD_SECP256K1; + case 3: // secp256R1 + setup->nid = 415; + setup->curve_id = WD_SECP256R1; break; case 4: // brainpoolP320R1 setup->nid = 929; @@ -1038,10 +1034,6 @@ static int get_ecc_curve(struct hpre_ecc_setup *setup, u32 cid) setup->nid = 716; setup->curve_id = WD_SECP521R1; break; - case 7: // secp256R1 - setup->nid = 415; - setup->curve_id = WD_SECP256R1; - break; default: HPRE_TST_PRT("failed to get ecc curve id!\n"); return -EINVAL; @@ -2247,6 +2239,7 @@ static void *ecc_uadk_sync_run(void *arg) { thread_data *pdata = (thread_data *)arg; int key_size = pdata->keybits >> 3; + u32 cid = ECC_CURVE_SECP256R1; u32 subtype = pdata->subtype; struct wd_ecc_sess_setup sess_setup; struct hpre_ecc_setup setup; @@ -2257,7 +2250,6 @@ static void *ecc_uadk_sync_run(void *arg) struct wd_ecc_point pbk; struct wd_dtb prk; struct wd_ecc_req req; - u32 cid; handle_t h_sess; u32 count = 0; int ret; @@ -2268,11 +2260,6 @@ static void *ecc_uadk_sync_run(void *arg) memset(&setup, 0, sizeof(setup)); - if (pdata->algtype == ECDH_256R1) - cid = ECC_CURVE_SECP256R1; - else - cid = ECC_CURVE_SECP256K1; - ret = get_ecc_curve(&setup, cid); if (ret) return NULL; @@ -2408,6 +2395,7 @@ static void *ecc_uadk_async_run(void *arg) { thread_data *pdata = (thread_data *)arg; int key_size = pdata->keybits >> 3; + u32 cid = ECC_CURVE_SECP256R1; u32 subtype = pdata->subtype; struct wd_ecc_sess_setup sess_setup; struct rsa_async_tag *tag; @@ -2419,7 +2407,6 @@ static void *ecc_uadk_async_run(void *arg) struct wd_ecc_point pbk; struct wd_ecc_req req; struct wd_dtb prk; - u32 cid; handle_t h_sess; int try_cnt = 0; u32 count = 0; @@ -2431,11 +2418,6 @@ static void *ecc_uadk_async_run(void *arg) memset(&setup, 0, sizeof(setup)); - if (pdata->algtype == ECDH_256R1) - cid = ECC_CURVE_SECP256R1; - else - cid = ECC_CURVE_SECP256K1; - ret = get_ecc_curve(&setup, cid); if (ret) return NULL; diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c index ce53d327..16980616 100644 --- a/uadk_tool/benchmark/uadk_benchmark.c +++ b/uadk_tool/benchmark/uadk_benchmark.c @@ -85,7 +85,6 @@ static struct acc_alg_item alg_options[] = { {"dh", "dh-3072", DH_3072}, {"dh", "dh-4096", DH_4096}, {"ecdh", "ecdh-256", ECDH_256}, - {"ecdh", "ecdh-256r1", ECDH_256R1}, {"ecdh", "ecdh-384", ECDH_384}, {"ecdh", "ecdh-521", ECDH_521}, {"ecdsa", "ecdsa-256", ECDSA_256}, @@ -648,7 +647,7 @@ void print_benchmark_help(void) ACC_TST_PRT(" specify numa nodes for cpu and memory\n"); ACC_TST_PRT("DESCRIPTION\n"); ACC_TST_PRT(" [--alg aes-128-cbc ]:\n"); - ACC_TST_PRT(" The name of the algorithm for benchmarking, note that alg ecdh-256r1 means ecdh with secp256r1\n"); + ACC_TST_PRT(" The name of the algorithm for benchmarking\n"); ACC_TST_PRT(" [--mode sva/nosva/soft/sva-soft/nosva-soft/instr/multibuff]: start UADK or Warpdrive or Openssl or Instruction mode test\n"); ACC_TST_PRT(" [--sync/--async]: start asynchronous/synchronous mode test\n"); ACC_TST_PRT(" [--opt 0,1,2,3,4,5]:\n"); diff --git a/uadk_tool/benchmark/uadk_benchmark.h b/uadk_tool/benchmark/uadk_benchmark.h index 7d2336a6..2739a0ef 100644 --- a/uadk_tool/benchmark/uadk_benchmark.h +++ b/uadk_tool/benchmark/uadk_benchmark.h @@ -135,8 +135,7 @@ enum test_alg { DH_2048, DH_3072, DH_4096, - ECDH_256, // ecdh - ECDH_256R1, // ecdh with secp256r1 curve + ECDH_256, // ecdh with secp256r1 curve ECDH_384, ECDH_521, ECDSA_256, // ecdsa -- 2.33.0