Repository navigation
Fix/ecc make pub heapmath leak - #12151
Conversation
|
retest this please |
61e1039 to
6cda2cf
Compare
|
d681148 to
2d7f1dd
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12151
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs
Unchanged since last review (not re-run): wolfssl-bugs
Not reviewed (no scan target covers them): doc/dox_comments/header_files/asn_public.h, doc/dox_comments/header_files/dh.h
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
Fenrir's latest completed scan found no issues; clearing the prior automated change request.
|
Retest this please. (fipsv2 PRB git fetch failure) |
|
confirmed fixed with tests good with |
Fenrir:
1ab2b82385(key->pubkeyinecc_make_pub_ex),6cda2cfe05(key->kin_ecc_make_key_ex),d681148f52(also wipes the BLIND_K mask)wc_ecc_import_raw_privatereinitializes already initialized bignums251a0e828f(_ecc_import_raw_privateviaecc_free_key_ints)wc_MakeRsaKeyre-initializes RsaKey mp_ints thatwc_InitRsaKeyalready initialized251a0e828f(RsaForceZeroPrivplus clearingnande)wc_DhSetKey_exre-runs mp_init on p, g and q thatwc_InitDhKey_exalready initialised251a0e828f(_DhSetKey)wc_MakeDsaKeyandwc_MakeDsaParametersreinitialize live DsaKey integers251a0e828f(both functions)Description:
If you generated a key, or rebuilt its public key, more than once on the same ecc_key, the memory from the earlier run was never freed. The old private key was also left in that memory without being erased. This only happened with heap math (--enable-heapmath).
Fix: free the old public key before reusing it, and erase and free the old private key. test_wc_ecc_make_key now generates a key twice on the same object.
Tested:
Built with heap math and a memory-leak checker. Before the fix, three ECC tests leaked memory, which matches the CI failure. After the fix, the full API test suite passes with no leaks.
Built with the default math on macOS; the three tests pass.
Skoll review found nothing that needs a change.
Checklist