Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions wolfcrypt/src/falcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -9540,6 +9540,9 @@ int wc_Falcon_PrivateKeyDecode(const byte* input, word32* inOutIdx,
}
}

/* Zeroize the decoded private key before free (matches every other secret
* temporary in this file); pubKey is public and needs no scrubbing. */
ForceZero(privKey, FALCON_MAX_PRV_KEY_SIZE);
XFREE(privKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(pubKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
return ret;
Expand Down
14 changes: 14 additions & 0 deletions wolfcrypt/src/wc_xmss.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,8 @@ static WC_INLINE int wc_xmsskey_signupdate(XmssKey* key, byte* sig,
/* Free state after use. */
wc_xmss_state_free(state);
}
/* Zeroize working state before free. */
ForceZero(state, sizeof(XmssState));
WC_FREE_VAR_EX(state, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
}
}
Expand Down Expand Up @@ -1284,6 +1286,8 @@ int wc_XmssKey_MakeKey(XmssKey* key, WC_RNG* rng)
/* Free state after use. */
wc_xmss_state_free(state);
}
/* Zeroize working state before free. */
ForceZero(state, sizeof(XmssState));
WC_FREE_VAR_EX(state, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
}
}
Expand All @@ -1305,6 +1309,14 @@ int wc_XmssKey_MakeKey(XmssKey* key, WC_RNG* rng)
key->state = WC_XMSS_STATE_OK;
}

/* Zeroize the secret seed (SK_seed || SK_PRF) before freeing the buffer. */
#ifdef WOLFSSL_SMALL_STACK
if (seed != NULL) {
ForceZero(seed, 3U * key->params->n);
}
#else
ForceZero(seed, sizeof(seed));
#endif
WC_FREE_VAR_EX(seed, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
return ret;
}
Expand Down Expand Up @@ -2015,6 +2027,8 @@ int wc_XmssKey_Verify(XmssKey* key, const byte* sig, word32 sigLen,
/* Free state after use. */
wc_xmss_state_free(state);
}
/* Zeroize working state before free. */
ForceZero(state, sizeof(XmssState));
WC_FREE_VAR_EX(state, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
}
}
Expand Down