x509asn1: fix DH public key parameter extraction

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 #21595
This commit is contained in:
Sergio Correia 2026-05-13 19:44:05 +01:00 committed by Daniel Stenberg
parent d6571f7a70
commit 61d59c9e39
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 144 additions and 3 deletions

View file

@ -223,7 +223,7 @@ test1650 test1651 test1652 test1653 test1654 test1655 test1656 test1657 \
test1658 test1659 test1660 test1661 test1662 test1663 test1664 test1665 \
test1666 test1667 test1668 test1669 \
\
test1670 test1671 test1672 test1673 test1674 test1675 \
test1670 test1671 test1672 test1673 test1674 test1675 test1676 \
\
test1680 test1681 test1682 test1683 test1684 test1685 \
\

21
tests/data/test1676 Normal file
View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="US-ASCII"?>
<testcase>
<info>
<keywords>
unittest
x509
DH
</keywords>
</info>
# Client-side
<client>
<features>
unittest
</features>
<name>
x509 DH public key parameter extraction
</name>
</client>
</testcase>