Skip to content

XMSS/Falcon: zeroize secret working state and key buffers before free - #11372

Open
Arpan0995 wants to merge 1 commit into
wolfSSL:masterfrom
Arpan0995:xmss-falcon-zeroize-secrets
Open

XMSS/Falcon: zeroize secret working state and key buffers before free#11372
Arpan0995 wants to merge 1 commit into
wolfSSL:masterfrom
Arpan0995:xmss-falcon-zeroize-secrets

Conversation

@Arpan0995

Copy link
Copy Markdown

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

  • 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, mirroring wc_lms.c (ForceZero(state, sizeof(LmsState))). Added
    at the sign, keygen, and verify sites so all three match the LMS treatment.
  • The keygen seed buffer (SK_seed || SK_PRF || SEED) is zeroized before it is
    freed; 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. pubKey is public and is left as is.

No functional change; behavior is identical.

Testing

Built and regression tested with:

./configure --enable-experimental --enable-xmss --enable-lms --enable-falcon
make
./wolfcrypt/test/testwolfcrypt

XMSS, LMS, and Falcon self-tests pass; the full suite returns 0.

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.
@wolfSSL-Bot

Copy link
Copy Markdown

Can one of the admins verify this patch?

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