fix: drop redundant XMEMSET before XMSS Init#265
Open
MarkAtwood wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.
Removes redundant zero-initialization of XmssKey structs immediately before wc_XmssKey_Init(), relying on the init function’s internal zeroization to avoid reorder-fragility while preserving behavior.
Changes:
- Deleted
XMEMSET(key, 0, sizeof(XmssKey))beforewc_XmssKey_Init()inwolfCLU_sign_data_xmss(). - Deleted
XMEMSET(key, 0, sizeof(XmssKey))beforewc_XmssKey_Init()inwolfCLU_sign_data_xmssmt(). - Updated the nearby comments to document that
wc_XmssKey_Init()zeroizes the struct internally.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Bug: In both XMSS sign functions in
src/sign-verify/clu_sign.c, the key struct is zeroized withXMEMSET(key, 0, sizeof(XmssKey))immediately before callingwc_XmssKey_Init(key, HEAP_HINT, 0). This memset is redundant and reorder-fragile.Fix:
wc_XmssKey_Init()already zeroizes the entire struct viaForceZero(key, sizeof(XmssKey))before setting heap/devId/state (seewolfcrypt/src/wc_xmss.c). The manual XMEMSET is fully redundant, so it is removed at both sites; the comment is kept and annotated. No behavior change — Init self-zeroizes.Build-verified: compiled the affected translation unit against a wolfSSL install with
-DWOLFSSL_HAVE_XMSS(the config where this block is live); compiles clean (exit 0), object shows the expectedU wc_XmssKey_Initreference.Reported by static analysis (Fenrir finding 581).