Skip to content

Commit 1aa3782

Browse files
committed
protect benchmark code with feature macro
1 parent b27f132 commit 1aa3782

16 files changed

+67
-7
lines changed

benchmark/bench_modules/wh_bench_mod_aes.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#include "wolfssl/wolfcrypt/aes.h"
2525

26+
#if defined(WOLFHSM_CFG_BENCH_ENABLE)
27+
2628
#if !defined(NO_AES)
2729

2830
/* 128-bit key */
@@ -353,3 +355,5 @@ int wh_Bench_Mod_Aes256GCMDecrypt(whClientContext* client, BenchOpContext* ctx,
353355
#endif /* HAVE_AESGCM */
354356

355357
#endif /* !defined(NO_AES) */
358+
359+
#endif /* WOLFHSM_CFG_BENCH_ENABLE */

benchmark/bench_modules/wh_bench_mod_cmac.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#include "wolfssl/wolfcrypt/cmac.h"
2525

26+
#if defined(WOLFHSM_CFG_BENCH_ENABLE)
27+
2628
#if defined(WOLFSSL_CMAC) && !defined(NO_AES) && defined(WOLFSSL_AES_DIRECT)
2729

2830
static const uint8_t key128[] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae,
@@ -159,4 +161,6 @@ int wh_Bench_Mod_CmacAes256Dma(whClientContext* client, BenchOpContext* ctx,
159161
#endif
160162
}
161163

162-
#endif /* WOLFSSL_CMAC && !defined(NO_AES) && defined(WOLFSSL_AES_DIRECT) */
164+
#endif /* WOLFSSL_CMAC && !defined(NO_AES) && defined(WOLFSSL_AES_DIRECT) */
165+
166+
#endif /* WOLFHSM_CFG_BENCH_ENABLE */

benchmark/bench_modules/wh_bench_mod_curve25519.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include "wolfssl/wolfcrypt/random.h"
2626
#include "wolfssl/wolfcrypt/curve25519.h"
2727

28+
#if defined(WOLFHSM_CFG_BENCH_ENABLE)
29+
2830
#if defined(HAVE_CURVE25519)
2931

3032
uint8_t key1_der[] = {
@@ -243,4 +245,6 @@ int wh_Bench_Mod_Curve25519SharedSecret(whClientContext* client,
243245
return ret;
244246
}
245247

246-
#endif /* HAVE_CURVE25519 */
248+
#endif /* HAVE_CURVE25519 */
249+
250+
#endif /* WOLFHSM_CFG_BENCH_ENABLE */

benchmark/bench_modules/wh_bench_mod_ecc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include "wolfssl/wolfcrypt/ecc.h"
2525
#include "wolfssl/wolfcrypt/random.h"
2626

27+
#if defined(WOLFHSM_CFG_BENCH_ENABLE)
28+
2729
#if defined(HAVE_ECC)
2830

2931
/* hardcoded DER-encoded ECC keys for benchmarking */
@@ -548,4 +550,6 @@ int wh_Bench_Mod_EccP256Ecdh(whClientContext* client, BenchOpContext* ctx,
548550
bobKeyDer, sizeof(bobKeyDer), 32, WH_DEV_ID);
549551
}
550552

551-
#endif /* HAVE_ECC */
553+
#endif /* HAVE_ECC */
554+
555+
#endif /* WOLFHSM_CFG_BENCH_ENABLE */

benchmark/bench_modules/wh_bench_mod_echo.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <string.h>
2121
#include "wh_bench_mod.h"
2222

23+
#if defined(WOLFHSM_CFG_BENCH_ENABLE)
24+
2325
int wh_Bench_Mod_Echo(whClientContext* client, BenchOpContext* benchCtx, int id,
2426
void* params)
2527
{
@@ -86,3 +88,5 @@ int wh_Bench_Mod_Echo(whClientContext* client, BenchOpContext* benchCtx, int id,
8688

8789
return ret;
8890
}
91+
92+
#endif /* WOLFHSM_CFG_BENCH_ENABLE */

benchmark/bench_modules/wh_bench_mod_hmac.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "wolfssl/wolfcrypt/hmac.h"
2323
#include "wolfssl/wolfcrypt/sha256.h"
2424

25+
#if defined(WOLFHSM_CFG_BENCH_ENABLE)
26+
2527
#if !defined(NO_HMAC)
2628

2729
#if !defined(NO_SHA256)
@@ -157,3 +159,5 @@ int wh_Bench_Mod_HmacSha3256Dma(whClientContext* client, BenchOpContext* ctx,
157159
#endif /* WOLFSSL_SHA3 */
158160

159161
#endif /* !defined(NO_HMAC) */
162+
163+
#endif /* WOLFHSM_CFG_BENCH_ENABLE */

benchmark/bench_modules/wh_bench_mod_mldsa.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include "wolfssl/wolfcrypt/dilithium.h"
2525
#include "wolfssl/wolfcrypt/random.h"
2626

27+
#if defined(WOLFHSM_CFG_BENCH_ENABLE)
28+
2729
#if defined(HAVE_DILITHIUM)
2830

2931
#if !defined(WOLFSSL_DILITHIUM_NO_SIGN)
@@ -1110,3 +1112,5 @@ int wh_Bench_Mod_MlDsa87KeyGenDma(whClientContext* client, BenchOpContext* ctx,
11101112
#endif /* !defined(WOLFSSL_NO_ML_DSA_87) */
11111113

11121114
#endif /* HAVE_DILITHIUM */
1115+
1116+
#endif /* WOLFHSM_CFG_BENCH_ENABLE */

benchmark/bench_modules/wh_bench_mod_rng.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "wolfhsm/wh_error.h"
2121
#include "wolfssl/wolfcrypt/random.h"
2222

23+
#if defined(WOLFHSM_CFG_BENCH_ENABLE)
24+
2325
#if !defined(WC_NO_RNG)
2426

2527
int _benchRng(whClientContext* client, BenchOpContext* ctx, int id, int devId)
@@ -86,3 +88,5 @@ int wh_Bench_Mod_Rng(whClientContext* client, BenchOpContext* ctx, int id,
8688
}
8789

8890
#endif /* !defined(WC_NO_RNG) */
91+
92+
#endif /* WOLFHSM_CFG_BENCH_ENABLE */

benchmark/bench_modules/wh_bench_mod_rsa.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include "wolfssl/wolfcrypt/rsa.h"
2525
#include "wolfssl/wolfcrypt/random.h"
2626

27+
#if defined(WOLFHSM_CFG_BENCH_ENABLE)
28+
2729
#if !defined(NO_RSA)
2830

2931
/* RSA 2048-bit key in DER format for benchmarking */
@@ -975,3 +977,5 @@ int wh_Bench_Mod_Rsa4096KeyGenDma(whClientContext* client, BenchOpContext* ctx,
975977
}
976978

977979
#endif /* !(NO_RSA) */
980+
981+
#endif /* WOLFHSM_CFG_BENCH_ENABLE */

benchmark/bench_modules/wh_bench_mod_sha2.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include "wolfssl/wolfcrypt/hash.h"
2424
#include "wolfssl/wolfcrypt/sha256.h"
2525

26+
#if defined(WOLFHSM_CFG_BENCH_ENABLE)
27+
2628
#if !defined(NO_SHA256)
2729

2830
int _benchSha256(whClientContext* client, BenchOpContext* ctx, int id,
@@ -131,3 +133,5 @@ int wh_Bench_Mod_Sha256Dma(whClientContext* client, BenchOpContext* ctx, int id,
131133
}
132134

133135
#endif /* !defined(NO_SHA256) */
136+
137+
#endif /* WOLFHSM_CFG_BENCH_ENABLE */

0 commit comments

Comments
 (0)