Validate DSA parameters when verifying DSA key.#10381
Open
kareem-wolfssl wants to merge 1 commit intowolfSSL:masterfrom
Open
Validate DSA parameters when verifying DSA key.#10381kareem-wolfssl wants to merge 1 commit intowolfSSL:masterfrom
kareem-wolfssl wants to merge 1 commit intowolfSSL:masterfrom
Conversation
Thanks to Kr0emer for the report.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds DSA public key/domain parameter validation to prevent signature verification with malformed parameters (e.g., g = 1, y = 1) and exposes the validation as a public API, with a new regression test.
Changes:
- Add new public API
wc_DsaCheckPubKey()for validating DSA domain parameters + public key. - Call
wc_DsaCheckPubKey()fromwc_DsaVerify_ex()prior to signature math. - Add an API test that constructs malformed keys (requires
WOLFSSL_PUBLIC_MP) and asserts verify/validation rejection.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| wolfssl/wolfcrypt/dsa.h | Exposes wc_DsaCheckPubKey() as a public API. |
| wolfcrypt/src/dsa.c | Implements key/parameter checks and enforces them in DSA verify. |
| tests/api/test_dsa.h | Registers the new API test. |
| tests/api/test_dsa.c | Adds regression coverage for malformed DSA params/pubkeys and verify rejection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+104
to
+105
| * - g^q mod p == 1 (g generates the order-q subgroup) | ||
| * - y^q mod p == 1 (y is in the order-q subgroup) |
Comment on lines
+1169
to
+1173
| /* Validate domain parameters and public key before doing any | ||
| * signature math. */ | ||
| ret = wc_DsaCheckPubKey(key); | ||
| if (ret != 0) { | ||
| break; |
| @@ -95,6 +95,7 @@ WOLFSSL_API int wc_DsaKeyToDer(DsaKey* key, byte* output, word32 inLen); | |||
| WOLFSSL_API int wc_SetDsaPublicKey(byte* output, DsaKey* key, | |||
| int outLen, int with_header); | |||
| WOLFSSL_API int wc_DsaKeyToPublicDer(DsaKey* key, byte* output, word32 inLen); | |||
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
Fixes zd#21694
Testing
PoC, newly added test
Checklist