Skip to content

Commit cefd55e

Browse files
committed
Fix for benchmarking shake with custom block size. Using ./benchmark -shake 1024 caused seg fault.
1 parent ee12a5f commit cefd55e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ cmake_install.cmake
393393
# GDB Settings
394394
\.gdbinit
395395

396+
libFuzzer
397+
396398
# Pycharm and other IDEs
397399
\.idea
398400

@@ -413,4 +415,4 @@ user_settings_asm.h
413415
/IDE/Espressif/**/sdkconfig
414416

415417
# auto-created CMake backups
416-
**/CMakeLists.txt.old
418+
**/CMakeLists.txt.old

wolfcrypt/benchmark/benchmark.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -5112,7 +5112,7 @@ void bench_shake128(int useDeviceID)
51125112
if (bench_async_check(&ret, BENCH_ASYNC_GET_DEV(&hash[i]),
51135113
0, &times, numBlocks, &pending)) {
51145114
ret = wc_Shake128_Update(&hash[i], bench_plain,
5115-
BENCH_SIZE);
5115+
bench_size);
51165116
if (!bench_async_handle(&ret,
51175117
BENCH_ASYNC_GET_DEV(&hash[i]), 0,
51185118
&times, &pending)) {
@@ -5148,7 +5148,7 @@ void bench_shake128(int useDeviceID)
51485148
ret = wc_InitShake128(hash, HEAP_HINT,
51495149
useDeviceID ? devId : INVALID_DEVID);
51505150
if (ret == 0)
5151-
ret = wc_Shake128_Update(hash, bench_plain, BENCH_SIZE);
5151+
ret = wc_Shake128_Update(hash, bench_plain, bench_size);
51525152
if (ret == 0)
51535153
ret = wc_Shake128_Final(hash, digest[0],
51545154
WC_SHA3_128_BLOCK_SIZE);
@@ -5207,7 +5207,7 @@ void bench_shake256(int useDeviceID)
52075207
if (bench_async_check(&ret, BENCH_ASYNC_GET_DEV(&hash[i]),
52085208
0, &times, numBlocks, &pending)) {
52095209
ret = wc_Shake256_Update(&hash[i], bench_plain,
5210-
BENCH_SIZE);
5210+
bench_size);
52115211
if (!bench_async_handle(&ret,
52125212
BENCH_ASYNC_GET_DEV(&hash[i]), 0,
52135213
&times, &pending)) {
@@ -5243,7 +5243,7 @@ void bench_shake256(int useDeviceID)
52435243
ret = wc_InitShake256(hash, HEAP_HINT,
52445244
useDeviceID ? devId : INVALID_DEVID);
52455245
if (ret == 0)
5246-
ret = wc_Shake256_Update(hash, bench_plain, BENCH_SIZE);
5246+
ret = wc_Shake256_Update(hash, bench_plain, bench_size);
52475247
if (ret == 0)
52485248
ret = wc_Shake256_Final(hash, digest[0],
52495249
WC_SHA3_256_BLOCK_SIZE);

0 commit comments

Comments
 (0)