Fix ML-DSA MakePublicKey derivation, verify guards, and ASN derivation testing#10985
Fix ML-DSA MakePublicKey derivation, verify guards, and ASN derivation testing#10985stenslae wants to merge 1 commit into
Conversation
…ubkey derivation logs
|
retest this please |
|
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #10985
Scan targets checked: wolfcrypt-bugs, wolfcrypt-rs-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
| } | ||
|
|
||
| /* --- Cleanup --------------------------------------------------- */ | ||
| #ifndef WC_MLDSA_CACHE_PRIV_VECTORS |
There was a problem hiding this comment.
🟠 [Medium] Memory leak in wc_MlDsaKey_MakePublicKey when WC_MLDSA_CACHE_PRIV_VECTORS is defined · Resource leaks on error paths
The cleanup block that calls XFREE(s1, ...) is gated #ifndef WC_MLDSA_CACHE_PRIV_VECTORS, but when that macro is defined without WC_MLDSA_FIXED_ARRAY, XMALLOC is still called into local s1 (didAlloc=1): in non-small-mem mode line 10399 adds aSz to allocSz; in small-mem mode lines 10403-10406 always include s1/s2/t sizes regardless of the macro. The allocation is never freed.
Fix: Add a matching if (didAlloc) { XFREE(s1, key->heap, DYNAMIC_TYPE_MLDSA); } inside a #ifdef WC_MLDSA_CACHE_PRIV_VECTORS block, or restructure so didAlloc always drives a single free regardless of the macro.
Description
This update introduces automatic derivation of the ML-DSA public key from the private key during parsing if the public key data is missing.
wolfSSL/wolfssh#1120
Testing
Added test coverage.
Checklist