Skip to content

Commit 058686b

Browse files
authored
Merge pull request #9305 from dgarske/bench_rsapub
Fix for benchmark with key gen and "out" not being allocated
2 parents 832e23a + 0c4f587 commit 058686b

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

wolfcrypt/benchmark/benchmark.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9005,28 +9005,26 @@ static void bench_rsa_helper(int useDeviceID,
90059005
WC_DECLARE_HEAP_ARRAY(enc, byte, BENCH_MAX_PENDING,
90069006
rsaKeySz/8, HEAP_HINT);
90079007

9008-
#if (!defined(WOLFSSL_RSA_VERIFY_INLINE) && \
9009-
!defined(WOLFSSL_RSA_PUBLIC_ONLY))
9008+
#if !defined(WOLFSSL_RSA_VERIFY_ONLY) || !defined(WOLFSSL_RSA_PUBLIC_ONLY)
90109009
WC_DECLARE_HEAP_ARRAY(out, byte, BENCH_MAX_PENDING,
90119010
rsaKeySz/8, HEAP_HINT);
90129011
#else
90139012
byte* out[BENCH_MAX_PENDING];
90149013
#endif
90159014

9016-
XMEMSET(out, 0, sizeof(out));
9017-
9018-
WC_ALLOC_HEAP_ARRAY(enc, byte, BENCH_MAX_PENDING,
9019-
rsaKeySz/8, HEAP_HINT);
9020-
9021-
#if (!defined(WOLFSSL_RSA_VERIFY_INLINE) && \
9022-
!defined(WOLFSSL_RSA_PUBLIC_ONLY))
9023-
WC_ALLOC_HEAP_ARRAY(out, byte, BENCH_MAX_PENDING,
9015+
#if !defined(WOLFSSL_RSA_VERIFY_ONLY) || !defined(WOLFSSL_RSA_PUBLIC_ONLY)
9016+
WC_CALLOC_HEAP_ARRAY(out, byte, BENCH_MAX_PENDING,
90249017
rsaKeySz/8, HEAP_HINT);
90259018
if (out[0] == NULL) {
90269019
ret = MEMORY_E;
90279020
goto exit;
90289021
}
9022+
#else
9023+
XMEMSET(out, 0, sizeof(out));
90299024
#endif
9025+
9026+
WC_CALLOC_HEAP_ARRAY(enc, byte, BENCH_MAX_PENDING,
9027+
rsaKeySz/8, HEAP_HINT);
90309028
if (enc[0] == NULL) {
90319029
ret = MEMORY_E;
90329030
goto exit;
@@ -9234,7 +9232,7 @@ static void bench_rsa_helper(int useDeviceID,
92349232
exit:
92359233

92369234
WC_FREE_HEAP_ARRAY(enc, BENCH_MAX_PENDING, HEAP_HINT);
9237-
#if !defined(WOLFSSL_RSA_VERIFY_INLINE) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)
9235+
#if !defined(WOLFSSL_RSA_VERIFY_ONLY) || !defined(WOLFSSL_RSA_PUBLIC_ONLY)
92389236
WC_FREE_HEAP_ARRAY(out, BENCH_MAX_PENDING, HEAP_HINT);
92399237
#endif
92409238
#ifndef WOLFSSL_RSA_VERIFY_ONLY

0 commit comments

Comments
 (0)