add brainpool benchmark of key generation

This commit is contained in:
Jacob Barthelmeh
2020-08-26 16:09:21 -06:00
parent fe37137f12
commit e3fa462d72
2 changed files with 20 additions and 12 deletions

View File

@@ -1836,11 +1836,14 @@ static void* benchmarks_do(void* args)
#ifdef HAVE_ECC #ifdef HAVE_ECC
if (bench_all || (bench_asym_algs & BENCH_ECC_MAKEKEY)) { if (bench_all || (bench_asym_algs & BENCH_ECC_MAKEKEY)) {
#ifndef NO_SW_BENCH #ifndef NO_SW_BENCH
bench_eccMakeKey(0); #ifdef HAVE_ECC_BRAINPOOL
bench_eccMakeKey(0, ECC_BRAINPOOLP256R1);
#endif
bench_eccMakeKey(0, ECC_SECP256R1);
#endif #endif
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC) && \ #if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC) && \
!defined(NO_HW_BENCH) !defined(NO_HW_BENCH)
bench_eccMakeKey(1); bench_eccMakeKey(1, ECC_SECP256R1);
#endif #endif
} }
if (bench_all || (bench_asym_algs & BENCH_ECC)) { if (bench_all || (bench_asym_algs & BENCH_ECC)) {
@@ -5257,11 +5260,16 @@ void bench_ntruKeyGen(void)
#endif #endif
#ifdef HAVE_ECC #ifdef HAVE_ECC
void bench_eccMakeKey(int doAsync)
/* +8 for 'ECDSA [%s]' and null terminator */
#define BENCH_ECC_NAME_SZ (ECC_MAXNAME + 8)
void bench_eccMakeKey(int doAsync, int curveId)
{ {
int ret = 0, i, times, count, pending = 0; int ret = 0, i, times, count, pending = 0;
const int keySize = bench_ecc_size; const int keySize = bench_ecc_size;
ecc_key genKey[BENCH_MAX_PENDING]; ecc_key genKey[BENCH_MAX_PENDING];
char name[BENCH_ECC_NAME_SZ];
double start; double start;
const char**desc = bench_desc_words[lng_index]; const char**desc = bench_desc_words[lng_index];
@@ -5284,7 +5292,8 @@ void bench_eccMakeKey(int doAsync)
goto exit; goto exit;
} }
ret = wc_ecc_make_key(&gRng, keySize, &genKey[i]); ret = wc_ecc_make_key_ex(&gRng, keySize, &genKey[i],
curveId);
if (!bench_async_handle(&ret, BENCH_ASYNC_GET_DEV(&genKey[i]), 0, &times, &pending)) { if (!bench_async_handle(&ret, BENCH_ASYNC_GET_DEV(&genKey[i]), 0, &times, &pending)) {
goto exit; goto exit;
} }
@@ -5294,7 +5303,8 @@ void bench_eccMakeKey(int doAsync)
count += times; count += times;
} while (bench_stats_sym_check(start)); } while (bench_stats_sym_check(start));
exit: exit:
bench_stats_asym_finish("ECC", keySize * 8, desc[2], doAsync, count, start, ret); XSNPRINTF(name, BENCH_ECC_NAME_SZ, "ECC [%15s]", wc_ecc_get_name(curveId));
bench_stats_asym_finish(name, keySize * 8, desc[2], doAsync, count, start, ret);
/* cleanup */ /* cleanup */
for (i = 0; i < BENCH_MAX_PENDING; i++) { for (i = 0; i < BENCH_MAX_PENDING; i++) {
@@ -5302,8 +5312,6 @@ exit:
} }
} }
/* +8 for 'ECDSA [%s]' and null terminator */
#define BENCH_ECC_NAME_SZ (ECC_MAXNAME + 8)
void bench_ecc(int doAsync, int curveId) void bench_ecc(int doAsync, int curveId)
{ {
@@ -5407,7 +5415,7 @@ void bench_ecc(int doAsync, int curveId)
count += times; count += times;
} while (bench_stats_sym_check(start)); } while (bench_stats_sym_check(start));
exit_ecdhe: exit_ecdhe:
XSNPRINTF(name, BENCH_ECC_NAME_SZ, "ECDHE [%s]", wc_ecc_get_name(curveId)); XSNPRINTF(name, BENCH_ECC_NAME_SZ, "ECDHE [%15s]", wc_ecc_get_name(curveId));
bench_stats_asym_finish(name, keySize * 8, desc[3], doAsync, count, start, bench_stats_asym_finish(name, keySize * 8, desc[3], doAsync, count, start,
ret); ret);
@@ -5448,7 +5456,7 @@ exit_ecdhe:
count += times; count += times;
} while (bench_stats_sym_check(start)); } while (bench_stats_sym_check(start));
exit_ecdsa_sign: exit_ecdsa_sign:
XSNPRINTF(name, BENCH_ECC_NAME_SZ, "ECDSA [%s]", wc_ecc_get_name(curveId)); XSNPRINTF(name, BENCH_ECC_NAME_SZ, "ECDSA [%15s]", wc_ecc_get_name(curveId));
bench_stats_asym_finish(name, keySize * 8, desc[4], doAsync, count, start, bench_stats_asym_finish(name, keySize * 8, desc[4], doAsync, count, start,
ret); ret);
@@ -5481,7 +5489,7 @@ exit_ecdsa_sign:
count += times; count += times;
} while (bench_stats_sym_check(start)); } while (bench_stats_sym_check(start));
exit_ecdsa_verify: exit_ecdsa_verify:
XSNPRINTF(name, BENCH_ECC_NAME_SZ, "ECDSA [%s]", wc_ecc_get_name(curveId)); XSNPRINTF(name, BENCH_ECC_NAME_SZ, "ECDSA [%15s]", wc_ecc_get_name(curveId));
bench_stats_asym_finish(name, keySize * 8, desc[5], doAsync, count, start, bench_stats_asym_finish(name, keySize * 8, desc[5], doAsync, count, start,
ret); ret);

View File

@@ -81,8 +81,8 @@ void bench_rsaKeyGen_size(int, int);
void bench_rsa(int); void bench_rsa(int);
void bench_rsa_key(int, int); void bench_rsa_key(int, int);
void bench_dh(int); void bench_dh(int);
void bench_eccMakeKey(int); void bench_eccMakeKey(int, int);
void bench_ecc(int doAsync, int curveId); void bench_ecc(int, int);
void bench_eccEncrypt(void); void bench_eccEncrypt(void);
void bench_curve25519KeyGen(void); void bench_curve25519KeyGen(void);
void bench_curve25519KeyAgree(void); void bench_curve25519KeyAgree(void);