Fix Dilithium signing when WC_DILITHIUM_CACHE_MATRIX_A is enabled#10400
Open
embhorn wants to merge 2 commits intowolfSSL:masterfrom
Open
Fix Dilithium signing when WC_DILITHIUM_CACHE_MATRIX_A is enabled#10400embhorn wants to merge 2 commits intowolfSSL:masterfrom
embhorn wants to merge 2 commits intowolfSSL:masterfrom
Conversation
4 tasks
Contributor
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. ✅
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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