Skip to content

Commit 91f8b5e

Browse files
Merge pull request #5903 from douzzer/20221216-fix-benchmark
20221216-fix-benchmark
2 parents b90c079 + 04b3151 commit 91f8b5e

1 file changed

Lines changed: 24 additions & 24 deletions

File tree

wolfcrypt/benchmark/benchmark.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3251,9 +3251,9 @@ static void bench_aesecb_internal(int useDeviceID, const byte* key, word32 keySz
32513251
Aes enc[BENCH_MAX_PENDING];
32523252
double start;
32533253
#ifdef HAVE_FIPS
3254-
int benchSz = AES_BLOCK_SIZE;
3254+
static const int benchSz = AES_BLOCK_SIZE;
32553255
#else
3256-
int benchSz = BENCH_SIZE;
3256+
static const int benchSz = BENCH_SIZE;
32573257
#endif
32583258

32593259
/* clear for done cleanup */
@@ -3276,7 +3276,7 @@ static void bench_aesecb_internal(int useDeviceID, const byte* key, word32 keySz
32763276

32773277
bench_stats_start(&count, &start);
32783278
do {
3279-
int outer_loop_limit = ((bench_size / AES_BLOCK_SIZE) * 10) + 1;
3279+
int outer_loop_limit = ((bench_size / benchSz) * 10) + 1;
32803280
for (times = 0;
32813281
times < outer_loop_limit /* numBlocks */ || pending > 0;
32823282
) {
@@ -3318,7 +3318,7 @@ static void bench_aesecb_internal(int useDeviceID, const byte* key, word32 keySz
33183318

33193319
bench_stats_start(&count, &start);
33203320
do {
3321-
int outer_loop_limit = (10 * (bench_size / AES_BLOCK_SIZE)) + 1;
3321+
int outer_loop_limit = (10 * (bench_size / benchSz)) + 1;
33223322
for (times = 0; times < outer_loop_limit || pending > 0; ) {
33233323
bench_async_poll(&pending);
33243324

@@ -3571,7 +3571,7 @@ void bench_aesctr(void)
35713571

35723572

35733573
#ifdef HAVE_AESCCM
3574-
void bench_aesccm(int useDevId)
3574+
void bench_aesccm(int useDeviceID)
35753575
{
35763576
Aes enc;
35773577
double start;
@@ -3591,7 +3591,7 @@ void bench_aesccm(int useDevId)
35913591
XMEMSET(bench_additional, 0, AES_AUTH_ADD_SZ);
35923592

35933593
if ((ret = wc_AesInit(&enc, HEAP_HINT,
3594-
(useDevId)? devId: INVALID_DEVID)) != 0) {
3594+
useDeviceID ? devId : INVALID_DEVID)) != 0) {
35953595
printf("wc_AesInit failed, ret = %d\n", ret);
35963596
goto exit;
35973597
}
@@ -3610,7 +3610,7 @@ void bench_aesccm(int useDevId)
36103610
}
36113611
count += i;
36123612
} while (bench_stats_check(start));
3613-
bench_stats_sym_finish(AES_AAD_STRING("AES-CCM-enc"), useDevId, count,
3613+
bench_stats_sym_finish(AES_AAD_STRING("AES-CCM-enc"), useDeviceID, count,
36143614
bench_size, start, ret);
36153615
if (ret != 0) {
36163616
printf("wc_AesCcmEncrypt failed, ret = %d\n", ret);
@@ -3626,7 +3626,7 @@ void bench_aesccm(int useDevId)
36263626
}
36273627
count += i;
36283628
} while (bench_stats_check(start));
3629-
bench_stats_sym_finish(AES_AAD_STRING("AES-CCM-dec"), useDevId, count,
3629+
bench_stats_sym_finish(AES_AAD_STRING("AES-CCM-dec"), useDeviceID, count,
36303630
bench_size, start, ret);
36313631
if (ret != 0) {
36323632
printf("wc_AesCcmEncrypt failed, ret = %d\n", ret);
@@ -5194,7 +5194,7 @@ void bench_blake2s(void)
51945194

51955195
#ifdef WOLFSSL_CMAC
51965196

5197-
static void bench_cmac_helper(int keySz, const char* outMsg, int useDevId)
5197+
static void bench_cmac_helper(int keySz, const char* outMsg, int useDeviceID)
51985198
{
51995199
Cmac cmac;
52005200
byte digest[AES_BLOCK_SIZE];
@@ -5212,29 +5212,29 @@ static void bench_cmac_helper(int keySz, const char* outMsg, int useDevId)
52125212
keyType = CAAM_KEYTYPE_AES256;
52135213
}
52145214

5215-
if (useDevId &&
5215+
if (useDeviceID &&
52165216
wc_SECO_GenerateKey(CAAM_GENERATE_KEY, keyGroup, pubKey, 0, keyType,
52175217
keyInfo, &keyID) != 0) {
52185218
printf("Error generating key in hsm\n");
52195219
return;
52205220
}
52215221
#endif
5222-
(void)useDevId;
5222+
(void)useDeviceID;
52235223

52245224
bench_stats_start(&count, &start);
52255225
do {
52265226
#ifdef HAVE_FIPS
52275227
ret = wc_InitCmac(&cmac, bench_key, keySz, WC_CMAC_AES, NULL);
52285228
#else
52295229
ret = wc_InitCmac_ex(&cmac, bench_key, keySz, WC_CMAC_AES, NULL,
5230-
HEAP_HINT, (useDevId)? devId: INVALID_DEVID);
5230+
HEAP_HINT, useDeviceID ? devId : INVALID_DEVID);
52315231
#endif
52325232
if (ret != 0) {
52335233
printf("InitCmac failed, ret = %d\n", ret);
52345234
return;
52355235
}
52365236
#ifdef WOLFSSL_SECO_CAAM
5237-
if (useDevId) {
5237+
if (useDeviceID) {
52385238
wc_SECO_CMACSetKeyID(&cmac, keyID);
52395239
}
52405240
#endif
@@ -5257,13 +5257,13 @@ static void bench_cmac_helper(int keySz, const char* outMsg, int useDevId)
52575257
bench_stats_sym_finish(outMsg, 0, count, bench_size, start, ret);
52585258
}
52595259

5260-
void bench_cmac(int useDevId)
5260+
void bench_cmac(int useDeviceID)
52615261
{
52625262
#ifdef WOLFSSL_AES_128
5263-
bench_cmac_helper(16, "AES-128-CMAC", useDevId);
5263+
bench_cmac_helper(16, "AES-128-CMAC", useDeviceID);
52645264
#endif
52655265
#ifdef WOLFSSL_AES_256
5266-
bench_cmac_helper(32, "AES-256-CMAC", useDevId);
5266+
bench_cmac_helper(32, "AES-256-CMAC", useDeviceID);
52675267
#endif
52685268

52695269
}
@@ -6834,7 +6834,7 @@ void bench_eccEncrypt(int curveId)
68346834
#endif /* HAVE_ECC */
68356835

68366836
#ifdef HAVE_CURVE25519
6837-
void bench_curve25519KeyGen(int useDevId)
6837+
void bench_curve25519KeyGen(int useDeviceID)
68386838
{
68396839
curve25519_key genKey;
68406840
double start;
@@ -6845,8 +6845,8 @@ void bench_curve25519KeyGen(int useDevId)
68456845
bench_stats_start(&count, &start);
68466846
do {
68476847
for (i = 0; i < genTimes; i++) {
6848-
ret = wc_curve25519_init_ex(&genKey, HEAP_HINT, (useDevId)? devId :
6849-
INVALID_DEVID);
6848+
ret = wc_curve25519_init_ex(&genKey, HEAP_HINT,
6849+
useDeviceID ? devId : INVALID_DEVID);
68506850
if (ret != 0) {
68516851
printf("wc_curve25519_init_ex failed: %d\n", ret);
68526852
break;
@@ -6861,12 +6861,12 @@ void bench_curve25519KeyGen(int useDevId)
68616861
}
68626862
count += i;
68636863
} while (bench_stats_check(start));
6864-
bench_stats_asym_finish("CURVE", 25519, desc[2], useDevId, count, start,
6864+
bench_stats_asym_finish("CURVE", 25519, desc[2], useDeviceID, count, start,
68656865
ret);
68666866
}
68676867

68686868
#ifdef HAVE_CURVE25519_SHARED_SECRET
6869-
void bench_curve25519KeyAgree(int useDevId)
6869+
void bench_curve25519KeyAgree(int useDeviceID)
68706870
{
68716871
curve25519_key genKey, genKey2;
68726872
double start;
@@ -6876,9 +6876,9 @@ void bench_curve25519KeyAgree(int useDevId)
68766876
word32 x = 0;
68776877

68786878
wc_curve25519_init_ex(&genKey, HEAP_HINT,
6879-
(useDevId)? devId : INVALID_DEVID);
6879+
useDeviceID ? devId : INVALID_DEVID);
68806880
wc_curve25519_init_ex(&genKey2, HEAP_HINT,
6881-
(useDevId)? devId : INVALID_DEVID);
6881+
useDeviceID ? devId : INVALID_DEVID);
68826882

68836883
ret = wc_curve25519_make_key(&gRng, 32, &genKey);
68846884
if (ret != 0) {
@@ -6906,7 +6906,7 @@ void bench_curve25519KeyAgree(int useDevId)
69066906
count += i;
69076907
} while (bench_stats_check(start));
69086908
exit:
6909-
bench_stats_asym_finish("CURVE", 25519, desc[3], useDevId, count, start,
6909+
bench_stats_asym_finish("CURVE", 25519, desc[3], useDeviceID, count, start,
69106910
ret);
69116911

69126912
wc_curve25519_free(&genKey2);

0 commit comments

Comments
 (0)