Skip to content

Add ML-DSA 65/87 Sign/Verify/KeyGen benchmarks#488

Open
miyazakh wants to merge 1 commit into
wolfSSL:mainfrom
miyazakh:mldsa_bench
Open

Add ML-DSA 65/87 Sign/Verify/KeyGen benchmarks#488
miyazakh wants to merge 1 commit into
wolfSSL:mainfrom
miyazakh:mldsa_bench

Conversation

@miyazakh

Copy link
Copy Markdown
Contributor

Add ML-DSA 65/87 Sign/Verify/KeyGen benchmarks

Summary

  • Implement the ML-DSA 65 and ML-DSA 87 Sign/Verify/KeyGen benchmark entry points in wh_bench_mod_mldsa.c, which previously returned WH_ERROR_NOTIMPL stubs.
  • Extend the shared _benchMlDsaSign/_benchMlDsaVerify/_benchMlDsaKeyGen helpers to select the correct test key/message/signature data based on the requested paramSet (WC_ML_DSA_44 / WC_ML_DSA_65 / WC_ML_DSA_87).
  • Add per-level WOLFSSL_NO_ML_DSA_44/65/87 feature gates so any level can be individually disabled and its test data compiled out.
  • Add ML-DSA 65/87 test key, message, and signature vectors.
  • Update benchmark config (user_settings.h, wolfhsm_cfg.h) to support the new levels.

Changes

File Description
benchmark/bench_modules/wh_bench_mod_mldsa.c Fill in wh_Bench_Mod_MlDsa65{Sign,Verify,KeyGen}[Dma] and wh_Bench_Mod_MlDsa87{Sign,Verify,KeyGen}[Dma], which previously just returned WH_ERROR_NOTIMPL; add ML-DSA 65/87 key/message/signature test vectors; guard each level's data and helper cases with WOLFSSL_NO_ML_DSA_44/65/87
benchmark/config/user_settings.h Add (disabled by default) WOLFSSL_NO_ML_DSA_44/65/87 toggles so individual ML-DSA levels can be excluded from the build
benchmark/config/wolfhsm_cfg.h Pull in user_settings.h early so the ML-DSA feature gates are visible when sizing buffers; size WOLFHSM_CFG_COMM_DATA_LEN to the largest enabled ML-DSA level (1280*8 for 87, 1280*5 for 65, 1280*4 otherwise)

Details

Benchmark entry points (wh_bench_mod_mldsa.c)

Previously, wh_Bench_Mod_MlDsa65Sign/Verify/KeyGen and the corresponding ML-DSA 87 and DMA variants were stubs that unconditionally returned WH_ERROR_NOTIMPL. They now call the shared _benchMlDsaSign, _benchMlDsaVerify, and _benchMlDsaKeyGen helpers with WC_ML_DSA_65 / WC_ML_DSA_87 as the parameter set, matching the existing ML-DSA 44 pattern.

The shared helpers were extended with a switch (paramSet) to select the correct static test key (and, for verify, message/signature) buffer for the requested level, each guarded by the corresponding WOLFSSL_NO_ML_DSA_xx macro so disabled levels don't pull in their test data.

Config changes

  • WOLFHSM_CFG_COMM_DATA_LEN must be large enough to hold the biggest enabled ML-DSA level's key/signature payload for non-DMA client/server messages, so it now scales with which levels are enabled.
  • wolfhsm_cfg.h needs to see the WOLFSSL_NO_ML_DSA_xx gates from user_settings.h before computing that buffer size, so user_settings.h is now included early (it's guarded, so the later include from wh_settings.h remains a no-op).

Impact

  • ML-DSA 65 and 87 benchmarks are now functional instead of returning "not implemented".
  • Any ML-DSA level can be disabled individually via WOLFSSL_NO_ML_DSA_44/65/87, shrinking both the compiled test data and the comm buffer accordingly.

@miyazakh miyazakh self-assigned this Jul 24, 2026
Copilot AI review requested due to automatic review settings July 24, 2026 08:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds functional ML-DSA level 65/87 benchmark entry points (sign/verify/keygen, including DMA variants) and wires configuration so individual ML-DSA levels can be compiled out and benchmark comm buffers scale to the largest enabled level.

Changes:

  • Implement ML-DSA 65/87 benchmark entry points by delegating to the shared ML-DSA helper routines with the requested parameter set.
  • Extend ML-DSA helpers and vector compilation to support per-level feature gates (WOLFSSL_NO_ML_DSA_44/65/87) and per-level test vectors.
  • Update benchmark configuration headers to expose per-level toggles and size WOLFHSM_CFG_COMM_DATA_LEN based on enabled ML-DSA level(s).

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
benchmark/bench_modules/wh_bench_mod_mldsa.c Adds ML-DSA 65/87 benchmark entry points and extends helper logic/vectors to be parameter-set aware and feature-gated.
benchmark/config/user_settings.h Adds per-ML-DSA-level compile-time toggles (disabled by default).
benchmark/config/wolfhsm_cfg.h Includes user_settings.h early (when enabled) and sizes WOLFHSM_CFG_COMM_DATA_LEN to the largest enabled ML-DSA level.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

#define WOLFSSL_MLDSA_NO_MAKE_KEY
#endif

/* The following options can be individually disabled ML-DSA levels */
Comment on lines 2733 to 2737
/* Time only the verify operation */
benchStartRet = wh_Bench_StartOp(ctx, id);
ret = wc_MlDsaKey_VerifyCtx(&key, ml_dsa_44_sig,
sizeof(ml_dsa_44_sig), NULL, 0, test_msg,
sizeof(test_msg), &verified);
ret = wc_MlDsaKey_VerifyCtx(&key, sigData, sigDataSz, NULL, 0,
test_msg, sizeof(test_msg), &verified);
benchStopRet = wh_Bench_StopOp(ctx, id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants