@@ -4425,10 +4425,22 @@ static void* benchmarks_do(void* args)
44254425#endif
44264426
44274427#ifdef HAVE_ED25519
4428- if (bench_all || (bench_asym_algs & BENCH_ED25519_KEYGEN))
4429- bench_ed25519KeyGen();
4430- if (bench_all || (bench_asym_algs & BENCH_ED25519_SIGN))
4431- bench_ed25519KeySign();
4428+ if (bench_all || (bench_asym_algs & BENCH_ED25519_KEYGEN)) {
4429+ #ifndef NO_SW_BENCH
4430+ bench_ed25519KeyGen(0);
4431+ #endif
4432+ #ifdef BENCH_DEVID
4433+ bench_ed25519KeyGen(1);
4434+ #endif
4435+ }
4436+ if (bench_all || (bench_asym_algs & BENCH_ED25519_SIGN)) {
4437+ #ifndef NO_SW_BENCH
4438+ bench_ed25519KeySign(0);
4439+ #endif
4440+ #ifdef BENCH_DEVID
4441+ bench_ed25519KeySign(1);
4442+ #endif
4443+ }
44324444#endif
44334445
44344446#ifdef HAVE_CURVE448
@@ -12995,12 +13007,15 @@ void bench_curve25519KeyAgree(int useDeviceID)
1299513007#endif /* HAVE_CURVE25519 */
1299613008
1299713009#ifdef HAVE_ED25519
12998- void bench_ed25519KeyGen(void )
13010+ void bench_ed25519KeyGen(int useDeviceID )
1299913011{
13012+ #ifndef HAVE_ED25519_MAKE_KEY
13013+ (void)useDeviceID;
13014+ #endif
1300013015#ifdef HAVE_ED25519_MAKE_KEY
1300113016 ed25519_key genKey;
1300213017 double start;
13003- int i, count;
13018+ int ret = 0, i, count;
1300413019 const char**desc = bench_desc_words[lng_index];
1300513020 DECLARE_MULTI_VALUE_STATS_VARS()
1300613021
@@ -13010,9 +13025,19 @@ void bench_ed25519KeyGen(void)
1301013025 bench_stats_start(&count, &start);
1301113026 do {
1301213027 for (i = 0; i < genTimes; i++) {
13013- wc_ed25519_init(&genKey);
13014- (void)wc_ed25519_make_key(&gRng, 32, &genKey);
13028+ ret = wc_ed25519_init_ex(&genKey, HEAP_HINT,
13029+ useDeviceID ? devId : INVALID_DEVID);
13030+ if (ret != 0) {
13031+ printf("wc_ed25519_init_ex failed: %d\n", ret);
13032+ break;
13033+ }
13034+
13035+ ret = wc_ed25519_make_key(&gRng, 32, &genKey);
1301513036 wc_ed25519_free(&genKey);
13037+ if (ret != 0) {
13038+ printf("wc_ed25519_make_key failed: %d\n", ret);
13039+ break;
13040+ }
1301613041 RECORD_MULTI_VALUE_STATS();
1301713042 }
1301813043 count += i;
@@ -13022,19 +13047,18 @@ void bench_ed25519KeyGen(void)
1302213047#endif
1302313048 );
1302413049
13025- bench_stats_asym_finish("ED", 25519, desc[2], 0, count, start, 0);
13050+ bench_stats_asym_finish("ED", 25519, desc[2], useDeviceID, count, start,
13051+ ret);
1302613052#ifdef MULTI_VALUE_STATISTICS
1302713053 bench_multi_value_stats(max, min, sum, squareSum, runs);
1302813054#endif
1302913055#endif /* HAVE_ED25519_MAKE_KEY */
1303013056}
1303113057
1303213058
13033- void bench_ed25519KeySign(void )
13059+ void bench_ed25519KeySign(int useDeviceID )
1303413060{
13035- #ifdef HAVE_ED25519_MAKE_KEY
13036- int ret;
13037- #endif
13061+ int ret = 0;
1303813062 ed25519_key genKey;
1303913063#ifdef HAVE_ED25519_SIGN
1304013064 double start;
@@ -13048,7 +13072,12 @@ void bench_ed25519KeySign(void)
1304813072
1304913073 bench_stats_prepare();
1305013074
13051- wc_ed25519_init(&genKey);
13075+ ret = wc_ed25519_init_ex(&genKey, HEAP_HINT,
13076+ useDeviceID ? devId : INVALID_DEVID);
13077+ if (ret != 0) {
13078+ printf("wc_ed25519_init_ex failed: %d\n", ret);
13079+ return;
13080+ }
1305213081
1305313082#ifdef HAVE_ED25519_MAKE_KEY
1305413083 ret = wc_ed25519_make_key(&gRng, ED25519_KEY_SIZE, &genKey);
@@ -13082,7 +13111,8 @@ void bench_ed25519KeySign(void)
1308213111 );
1308313112
1308413113exit_ed_sign:
13085- bench_stats_asym_finish("ED", 25519, desc[4], 0, count, start, ret);
13114+ bench_stats_asym_finish("ED", 25519, desc[4], useDeviceID, count, start,
13115+ ret);
1308613116#ifdef MULTI_VALUE_STATISTICS
1308713117 bench_multi_value_stats(max, min, sum, squareSum, runs);
1308813118#endif
@@ -13110,7 +13140,8 @@ void bench_ed25519KeySign(void)
1311013140 );
1311113141
1311213142exit_ed_verify:
13113- bench_stats_asym_finish("ED", 25519, desc[5], 0, count, start, ret);
13143+ bench_stats_asym_finish("ED", 25519, desc[5], useDeviceID, count, start,
13144+ ret);
1311413145#ifdef MULTI_VALUE_STATISTICS
1311513146 bench_multi_value_stats(max, min, sum, squareSum, runs);
1311613147#endif
0 commit comments