Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical build-configuration and white-box call-site issues remain, along with an unresolved DER signature handling case.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR fixes DSA certificate signature length handling by sizing signatures from the public key’s q value and padding ASN.1 components.
Changes:
- Validates DSA
qsizes. - Decodes and zero-pads signature components.
- Adds regression test coverage.
File summaries
| File | Summary |
|---|---|
wolfcrypt/src/dsa.c |
Bounds signature handling by q. |
wolfcrypt/src/asn.c |
Decodes, sizes, and pads DSA signatures. |
tests/api/test_dsa.h |
Registers the regression test. |
tests/api/test_dsa.c |
Adds certificate verification coverage. |
Review details
Suppressed comments (3)
wolfcrypt/src/asn.c:17552
- The new test only supplies a malformed 40-byte raw signature and verifies that certificate checking fails, so it never reaches this conversion for a valid ASN.1 DSA-Sig-Value. Consequently, the newly required zero-padding (and the
sigCpy + qSzplacement fors) is untested; add a valid DER r/s case with at least one component narrower thanqSzand assert that verification reaches the expected result, or directly inspect the padded buffer in the white-box test.
wolfcrypt/src/asn.c:17510 - This helper is decoding the
SEQUENCE { INTEGER r, INTEGER s }DSA-Sig-Value after the certificate BIT STRING wrapper has already been removed; it is not parsing an ASN.1 BIT STRING. Please correct the comment so callers do not look for the wrong wire format.
wolfcrypt/src/asn.c:17917 - Length alone cannot distinguish raw
r||sfrom an ASN.1 DSA-Sig-Value. A valid DER signature can also total exactly2 * qSzbytes (for example, two 29-byte INTEGERs with a 256-bit q), so this branch will pass the DER bytes directly towc_DsaVerify()and reject that otherwise valid certificate instead of decoding and padding it. Detect the ASN.1 form or keep the certificate-verification path unconditionally DER-decoding.
- Files reviewed: 4/4 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
gasbytes
force-pushed
the
dsa-sig-fix
branch
from
September 17, 2026 11:57
2323d6d to
ab1b141
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Size the DSA signature copy from the verifying key's q, zero-pad each half of an ASN.1-encoded signature to that width, and reject a q outside the range wolfCrypt can sign with. Adds a unit test.
Thanks to Anthropic for the report.
Testing
Added associated regression test (
test_wc_DsaVerify_cert_sig_narrower_than_q).Checklist