Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 47 additions & 16 deletions wolfcrypt/benchmark/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -4425,10 +4425,22 @@ static void* benchmarks_do(void* args)
#endif

#ifdef HAVE_ED25519
if (bench_all || (bench_asym_algs & BENCH_ED25519_KEYGEN))
bench_ed25519KeyGen();
if (bench_all || (bench_asym_algs & BENCH_ED25519_SIGN))
bench_ed25519KeySign();
if (bench_all || (bench_asym_algs & BENCH_ED25519_KEYGEN)) {
#ifndef NO_SW_BENCH
bench_ed25519KeyGen(0);
#endif
#ifdef BENCH_DEVID
bench_ed25519KeyGen(1);
#endif
}
if (bench_all || (bench_asym_algs & BENCH_ED25519_SIGN)) {
#ifndef NO_SW_BENCH
bench_ed25519KeySign(0);
#endif
#ifdef BENCH_DEVID
bench_ed25519KeySign(1);
#endif
}
#endif

#ifdef HAVE_CURVE448
Expand Down Expand Up @@ -12995,12 +13007,15 @@ void bench_curve25519KeyAgree(int useDeviceID)
#endif /* HAVE_CURVE25519 */

#ifdef HAVE_ED25519
void bench_ed25519KeyGen(void)
void bench_ed25519KeyGen(int useDeviceID)
{
#ifndef HAVE_ED25519_MAKE_KEY
(void)useDeviceID;
#endif
#ifdef HAVE_ED25519_MAKE_KEY
ed25519_key genKey;
double start;
int i, count;
int ret = 0, i, count;
const char**desc = bench_desc_words[lng_index];
DECLARE_MULTI_VALUE_STATS_VARS()

Expand All @@ -13010,9 +13025,19 @@ void bench_ed25519KeyGen(void)
bench_stats_start(&count, &start);
do {
for (i = 0; i < genTimes; i++) {
wc_ed25519_init(&genKey);
(void)wc_ed25519_make_key(&gRng, 32, &genKey);
ret = wc_ed25519_init_ex(&genKey, HEAP_HINT,
useDeviceID ? devId : INVALID_DEVID);
if (ret != 0) {
printf("wc_ed25519_init_ex failed: %d\n", ret);
break;
}

ret = wc_ed25519_make_key(&gRng, 32, &genKey);
wc_ed25519_free(&genKey);
if (ret != 0) {
printf("wc_ed25519_make_key failed: %d\n", ret);
break;
}
RECORD_MULTI_VALUE_STATS();
}
count += i;
Expand All @@ -13022,19 +13047,18 @@ void bench_ed25519KeyGen(void)
#endif
);

bench_stats_asym_finish("ED", 25519, desc[2], 0, count, start, 0);
bench_stats_asym_finish("ED", 25519, desc[2], useDeviceID, count, start,
ret);
#ifdef MULTI_VALUE_STATISTICS
bench_multi_value_stats(max, min, sum, squareSum, runs);
#endif
#endif /* HAVE_ED25519_MAKE_KEY */
}


void bench_ed25519KeySign(void)
void bench_ed25519KeySign(int useDeviceID)
{
#ifdef HAVE_ED25519_MAKE_KEY
int ret;
#endif
int ret = 0;
ed25519_key genKey;
#ifdef HAVE_ED25519_SIGN
double start;
Expand All @@ -13048,7 +13072,12 @@ void bench_ed25519KeySign(void)

bench_stats_prepare();

wc_ed25519_init(&genKey);
ret = wc_ed25519_init_ex(&genKey, HEAP_HINT,
useDeviceID ? devId : INVALID_DEVID);
if (ret != 0) {
printf("wc_ed25519_init_ex failed: %d\n", ret);
return;
}

#ifdef HAVE_ED25519_MAKE_KEY
ret = wc_ed25519_make_key(&gRng, ED25519_KEY_SIZE, &genKey);
Expand Down Expand Up @@ -13082,7 +13111,8 @@ void bench_ed25519KeySign(void)
);

exit_ed_sign:
bench_stats_asym_finish("ED", 25519, desc[4], 0, count, start, ret);
bench_stats_asym_finish("ED", 25519, desc[4], useDeviceID, count, start,
ret);
#ifdef MULTI_VALUE_STATISTICS
bench_multi_value_stats(max, min, sum, squareSum, runs);
#endif
Expand Down Expand Up @@ -13110,7 +13140,8 @@ void bench_ed25519KeySign(void)
);

exit_ed_verify:
bench_stats_asym_finish("ED", 25519, desc[5], 0, count, start, ret);
bench_stats_asym_finish("ED", 25519, desc[5], useDeviceID, count, start,
ret);
#ifdef MULTI_VALUE_STATISTICS
bench_multi_value_stats(max, min, sum, squareSum, runs);
#endif
Expand Down
5 changes: 2 additions & 3 deletions wolfcrypt/benchmark/benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ void bench_eccEncrypt(int curveId);
void bench_sm2(int useDeviceID);
void bench_curve25519KeyGen(int useDeviceID);
void bench_curve25519KeyAgree(int useDeviceID);
void bench_ed25519KeyGen(void);
void bench_ed25519KeySign(void);
void bench_ed25519KeyGen(int useDeviceID);
void bench_ed25519KeySign(int useDeviceID);
void bench_curve448KeyGen(void);
void bench_curve448KeyAgree(void);
void bench_ed448KeyGen(void);
Expand Down Expand Up @@ -144,4 +144,3 @@ void bench_stats_print(void);


#endif /* WOLFCRYPT_BENCHMARK_H */

Loading