Fix Dilithium signing when WC_DILITHIUM_CACHE_MATRIX_A is enabled#10400
Fix Dilithium signing when WC_DILITHIUM_CACHE_MATRIX_A is enabled#10400embhorn wants to merge 3 commits intowolfSSL:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the Dilithium/ML-DSA signing path when matrix-A caching is enabled, addressing the cached-matrix allocation bug described in #10383. It updates the core signing implementation and adds a regression test in the wolfCrypt test suite to keep this cache-allocation path covered.
Changes:
- Fix
dilithium_sign_with_seed_mu()so the cached matrix-A allocation is stored onkey->ainstead of a transient local pointer. - Zero-initialize the newly allocated cache buffer before use, matching other cached-allocation paths.
- Add
dilithium_sign_cache_alloc_test()and run it for ML-DSA 44/65/87 to exercise the sign-after-cache-reset path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
wolfcrypt/src/dilithium.c |
Fixes cached matrix-A allocation in the Dilithium signing path. |
wolfcrypt/test/test.c |
Adds a regression test that clears the cache, signs, and verifies for all supported ML-DSA levels. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #10400
Scan targets checked: wolfcrypt-bugs, wolfcrypt-src
No new issues found in the changed files. ✅
|
Frauschi
left a comment
There was a problem hiding this comment.
As ML-DSA is now added to Wconversion testing, you will need type casts on the XMALLOC() and XMEMSET() calls for the params->aSz argument.
Description
dilithium_sign_with_seed_mu()allocated matrix A into a local variable a, then immediately overwrote it with a = key->aFixes #10383
Testing
Added
dilithium_sign_cache_alloc_testWC_DILITHIUM_CACHE_MATRIX_Ais enabled in Debian RPM testsChecklist