Add buffer size and callback checks to wc_LmsKey_Sign#10084
Add buffer size and callback checks to wc_LmsKey_Sign#10084holtrop-wolfssl wants to merge 1 commit intowolfSSL:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds stricter input validation to wc_LmsKey_Sign to prevent signing when the output buffer is too small or when required callbacks/context are missing, along with unit tests reproducing the reported issue (ZD#21439).
Changes:
- Add signature buffer size validation in
wc_LmsKey_Sign. - Require read/write private-key callbacks and context to be configured before signing.
- Add unit tests covering the new validation failures.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| wolfcrypt/src/wc_lms.c | Adds early validation for signature buffer size, callbacks, and context in wc_LmsKey_Sign. |
| wolfcrypt/test/test.c | Adds unit tests to ensure wc_LmsKey_Sign returns expected errors for invalid inputs. |
Comments suppressed due to low confidence (4)
wolfcrypt/test/test.c:1
- These casts convert
msgto a non-constbyte*, which discards constness even thoughwc_LmsKey_Signtakes aconst byte*message pointer. Prefer passingmsgwithout a cast (or casting toconst byte*if needed) to avoid hiding accidental mutation and to keep const-correctness in the test.
wolfcrypt/test/test.c:1 - These casts convert
msgto a non-constbyte*, which discards constness even thoughwc_LmsKey_Signtakes aconst byte*message pointer. Prefer passingmsgwithout a cast (or casting toconst byte*if needed) to avoid hiding accidental mutation and to keep const-correctness in the test.
wolfcrypt/test/test.c:1 - These casts convert
msgto a non-constbyte*, which discards constness even thoughwc_LmsKey_Signtakes aconst byte*message pointer. Prefer passingmsgwithout a cast (or casting toconst byte*if needed) to avoid hiding accidental mutation and to keep const-correctness in the test.
wolfcrypt/test/test.c:1 - These casts convert
msgto a non-constbyte*, which discards constness even thoughwc_LmsKey_Signtakes aconst byte*message pointer. Prefer passingmsgwithout a cast (or casting toconst byte*if needed) to avoid hiding accidental mutation and to keep const-correctness in the test.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8d651a3 to
0696193
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0696193 to
ba862ad
Compare
Fixes ZD#21439
ba862ad to
048a03e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
Add buffer size and callback checks to wc_LmsKey_Sign
Fixes ZD#21439
Testing
Added unit tests to reproduce ZD bug report. Tested with and without fix in place.
Checklist