XMSS/Falcon: zeroize secret working state and key buffers before free - #11372
Open
Arpan0995 wants to merge 1 commit into
Open
XMSS/Falcon: zeroize secret working state and key buffers before free#11372Arpan0995 wants to merge 1 commit into
Arpan0995 wants to merge 1 commit into
Conversation
Several secret buffers were freed without being zeroized first, leaving key material resident in freed heap or on the stack: - wc_xmss.c: the XmssState working buffer holds the XMSS private seed S_XMSS and transient WOTS secret keys during keygen and sign. It is now ForceZero'd before WC_FREE_VAR_EX at the keygen, sign, and verify sites, matching wc_lms.c (ForceZero(state, sizeof(LmsState))). - wc_xmss.c: the keygen seed buffer (SK_seed || SK_PRF) is zeroized before free; the first 2*n bytes are secret. The adjacent key->sk was already zeroized. - falcon.c: wc_Falcon_PrivateKeyDecode zeroizes the decoded private-key temporary before freeing it, matching every other secret temporary in the file. No functional change.
|
Can one of the admins verify this patch? |
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
A few secret buffers in the XMSS and Falcon code are freed without being
zeroized first, so key material stays resident in freed heap or on the stack.
This adds ForceZero in each spot, matching the pattern already used by LMS,
ML-KEM, ML-DSA, and SLH-DSA, and by every other secret temporary in falcon.c.
wc_xmss.c
WOTS secret keys during keygen and sign. It is now ForceZero'd before
WC_FREE_VAR_EX, mirroring wc_lms.c (ForceZero(state, sizeof(LmsState))). Added
at the sign, keygen, and verify sites so all three match the LMS treatment.
freed; the first 2*n bytes are secret. The adjacent key->sk was already
zeroized.
falcon.c
freeing it. pubKey is public and is left as is.
No functional change; behavior is identical.
Testing
Built and regression tested with:
XMSS, LMS, and Falcon self-tests pass; the full suite returns 0.