Commit 4598010
committed
Fix wolfSSL#3058: GetSigLen NULL-deref on key->params
wc_LmsKey_GetSigLen dereferenced key->params->sig_len without first
guarding against key->params == NULL, so an Init -> GetSigLen call
without a SetParameters in between (a plausible verify-only flow)
would crash. wc_XmssKey_GetSigLen has a state check that incidentally
catches the same condition, but lacks the explicit guard its sibling
GetPubLen / GetPrivLen carry.
Add (key->params == NULL) to the BAD_FUNC_ARG precondition block in
both functions, matching wc_LmsKey_GetPubLen / wc_LmsKey_GetPrivLen
and wc_XmssKey_GetPubLen / wc_XmssKey_GetPrivLen. Documented return
contracts already list BAD_FUNC_ARG.
Negative tests in test_rfc9802_x509_verify now Init a key and call
GetSigLen on it without SetParameters, expecting BAD_FUNC_ARG, for
both LMS and XMSS.
https://claude.ai/code/session_01SnSQMb145Hkyyf7hQQQ8cq1 parent 94a546d commit 4598010
3 files changed
Lines changed: 22 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35754 | 35754 | | |
35755 | 35755 | | |
35756 | 35756 | | |
| 35757 | + | |
| 35758 | + | |
| 35759 | + | |
| 35760 | + | |
| 35761 | + | |
| 35762 | + | |
| 35763 | + | |
| 35764 | + | |
| 35765 | + | |
| 35766 | + | |
35757 | 35767 | | |
35758 | 35768 | | |
35759 | 35769 | | |
| |||
35789 | 35799 | | |
35790 | 35800 | | |
35791 | 35801 | | |
| 35802 | + | |
| 35803 | + | |
| 35804 | + | |
| 35805 | + | |
| 35806 | + | |
| 35807 | + | |
| 35808 | + | |
| 35809 | + | |
| 35810 | + | |
| 35811 | + | |
35792 | 35812 | | |
35793 | 35813 | | |
35794 | 35814 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1531 | 1531 | | |
1532 | 1532 | | |
1533 | 1533 | | |
1534 | | - | |
| 1534 | + | |
1535 | 1535 | | |
1536 | 1536 | | |
1537 | 1537 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1652 | 1652 | | |
1653 | 1653 | | |
1654 | 1654 | | |
1655 | | - | |
| 1655 | + | |
1656 | 1656 | | |
1657 | 1657 | | |
1658 | 1658 | | |
| |||
0 commit comments