Fix benchmark guard macros#418
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the preprocessor guard that controls compilation of the ML-DSA 87 benchmark functions so it correctly honors the WOLFSSL_NO_ML_DSA_87 feature-disable macro (consistent with the ML-DSA 44/65 benchmark sections and benchmark/wh_bench.c’s registration guards).
Changes:
- Replace
#if !defined(WOLFSSL_MLDSA_NO_SIGN)with#if !defined(WOLFSSL_NO_ML_DSA_87)at the start of the ML-DSA 87 benchmark section. - Align the ML-DSA 87 section’s opening guard with its existing
#endif /* !defined(WOLFSSL_NO_ML_DSA_87) */and with other code that references ML-DSA 87.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #if !defined(WOLFSSL_MLDSA_NO_SIGN) && \ | ||
| !defined(WOLFHSM_CFG_TEST_CLIENT_LARGE_DATA_DMA_ONLY) |
There was a problem hiding this comment.
I'm confused why in your latest commit you added all of these gates putting identical void casting logic in both cases? We shouldnt add conditional implementations unless it does something.
There was a problem hiding this comment.
In your earlier comment, you asked, "Do we not also still need WOLFSSL_MLDSA_NO_SIGN here?", so I guarded the sign operation in the same way as wh_Bench_Mod_MlDsa44Sign(), which returns WH_ERROR_NOTIMPL when WOLFSSL_MLDSA_NO_SIGN is defined.
However, since _benchMlDsaSign() does not currently support ML-DSA 65/87, the added guard creates a redundant code path. I applied the same pattern to the other functions for consistency.
Going forward, I see two options:
- Remove the added macro guards.
- Extend
_benchMlDsaSign(), _benchMlDsaVerify(), and _benchMlDsaKeyGen()to support ML-DSA 65 and 87.
There was a problem hiding this comment.
based on your original diff, the comment was valid since you removed the dependency on sign, but I see no why you did that. I can merge this now but can you please add a follow up PR introducing benchmark support for all security levels? Thanks!
Fix benchmark guard macros
Summary
wh_bench_mod_mldsa.cWOLFHSM_CFG_ENABLE_SERVERguard aroundwh_Bench_ServerCfgLoop()inwh_bench.cChanges
benchmark/bench_modules/wh_bench_mod_mldsa.cWOLFSSL_MLDSA_NO_SIGNwithWOLFSSL_NO_ML_DSA_87for ML-DSA 87 benchmark sectionbenchmark/wh_bench.cwh_Bench_ServerCfgLoop()with#if defined(WOLFHSM_CFG_ENABLE_SERVER)guardDetails
Fix typo in ML-DSA 87 guard (
wh_bench_mod_mldsa.c)The wrong macro
WOLFSSL_MLDSA_NO_SIGNwas used to guard the ML-DSA 87 benchmark section. The correct macro isWOLFSSL_NO_ML_DSA_87, consistent with the guards used for ML-DSA 44 and ML-DSA 65 in the same file.#if !defined(WOLFSSL_MLDSA_NO_SIGN)#if !defined(WOLFSSL_NO_ML_DSA_87)Without this fix, defining
WOLFSSL_NO_ML_DSA_87to disable ML-DSA 87 support would not exclude the corresponding benchmark functions from compilation.Guard server benchmark loop (
wh_bench.c)wh_Bench_ServerCfgLoop()uses server APIs (wh_Server_Init,wh_Server_HandleRequestMessage, etc.) and must not be compiled in configurations where server support is disabled. A stub implementation is provided under#elseso that callers such as_whBenchServerTask()link cleanly without server support.#if defined(WOLFHSM_CFG_ENABLE_SERVER); stub (returnsWH_ERROR_OK) provided under#elseImpact
WOLFSSL_NO_ML_DSA_87will now correctly exclude ML-DSA 87 benchmark functions.WOLFHSM_CFG_ENABLE_SERVERwill now link cleanly via the stub implementation.