x509asn1: fix DH public key parameter extraction#21595
Closed
sergio-correia wants to merge 1 commit into
Closed
Conversation
vszakats
reviewed
May 13, 2026
There was a problem hiding this comment.
Pull request overview
This PR fixes DH parameter extraction in the ASN.1 certificate info parser so that dh(g) is read from the correct cursor position (instead of re-reading dh(p)), restoring correct CURLOPT_CERTINFO output on non-OpenSSL backends that use lib/vtls/x509asn1.c.
Changes:
- Fix cursor usage when extracting DH
gparameter indo_pubkey()fordhpublicnumber. - Add unit1676 with a minimal DER certificate to ensure
dh(p),dh(g), anddh(pub_key)are extracted distinctly. - Register the new unit test in the unit and test-data makefiles.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/vtls/x509asn1.c | Fixes DH g element parsing to use the advanced cursor returned after parsing p. |
| tests/unit/unit1676.c | Adds a unit test exercising the DH public key parsing path via Curl_extract_certinfo(). |
| tests/unit/Makefile.inc | Includes unit1676.c in the unit test build list. |
| tests/data/test1676 | Adds the test case definition for the new unit test. |
| tests/data/Makefile.am | Registers test1676 in the test data makefile list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The dh(g) parameter was read from param->beg instead of from the cursor p returned by parsing dh(p). This caused dh(g) to always report the same value as dh(p) when inspecting DH certificates via CURLOPT_CERTINFO on non-OpenSSL backends. The DSA branch correctly advances the cursor; the DH branch lost this during what appears to be a copy-paste. Add unit1676 to verify that dh(p) and dh(g) report distinct values using a hand-crafted minimal DER certificate. Assisted-by: Claude Opus 4.6 Signed-off-by: Sergio Correia <scorreia@redhat.com>
bagder
approved these changes
May 15, 2026
Member
|
Thanks! |
outcast36
pushed a commit
to greearb/curl
that referenced
this pull request
Jun 3, 2026
The dh(g) parameter was read from param->beg instead of from the cursor p returned by parsing dh(p). This caused dh(g) to always report the same value as dh(p) when inspecting DH certificates via CURLOPT_CERTINFO on non-OpenSSL backends. The DSA branch correctly advances the cursor; the DH branch lost this during what appears to be a copy-paste. Add unit1676 to verify that dh(p) and dh(g) report distinct values using a hand-crafted minimal DER certificate. Assisted by: Claude Opus 4.6 Signed-off-by: Sergio Correia <scorreia@redhat.com> Closes curl#21595
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.
The dh(g) parameter was read from param->beg instead of from the cursor p returned by parsing dh(p). This caused dh(g) to always report the same value as dh(p) when inspecting DH certificates via CURLOPT_CERTINFO on non-OpenSSL backends.
The DSA branch correctly advances the cursor; the DH branch lost this during what appears to be a copy-paste.
Add unit1676 to verify that dh(p) and dh(g) report distinct values using a hand-crafted minimal DER certificate.