<feed xmlns='http://www.w3.org/2005/Atom'>
<title>openbsd/src/lib/libcrypto/dh/dh_check.c, branch OPENBSD_7_9_BASE</title>
<subtitle>A mirror of https://github.com/libressl/openbsd.git
</subtitle>
<id>https://git.lua4.win/openbsd/atom?h=OPENBSD_7_9_BASE</id>
<link rel='self' href='https://git.lua4.win/openbsd/atom?h=OPENBSD_7_9_BASE'/>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/'/>
<updated>2026-01-23T08:32:22+00:00</updated>
<entry>
<title>DH_check: teach this DoS vector about RFC 7919 primes</title>
<updated>2026-01-23T08:32:22+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2026-01-23T08:32:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=cd68beaaec2fafb4bd60e9b8655b93d91804cc69'/>
<id>urn:sha1:cd68beaaec2fafb4bd60e9b8655b93d91804cc69</id>
<content type='text'>
ok beck
</content>
</entry>
<entry>
<title>Scapy special for DH_check()</title>
<updated>2026-01-23T08:21:52+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2026-01-23T08:21:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=e8699208c6c4338d425f0979a68ec6ea04009819'/>
<id>urn:sha1:e8699208c6c4338d425f0979a68ec6ea04009819</id>
<content type='text'>
The latest release of Scapy calls DH_check() on all the well-known
Diffie-Hellman parameters for RFCs 2409, 3526, and 7919. It does this
via pyca/cryptography at startup. Every single time. This is obviously
very expensive, due to our 64 MR rounds (which are complete overkill
now that we have BPSW). Instead of pondering the ideal number of rounds
for BPSW with FFDH, simply skip the check if the parameter matches a
well-known prime. These are known to be safe primes, so we can skip
those super-expensive and pointless checks without any risk.

This is only done for the public dh-&gt;p parameter. It could be further
optimized, but with the follow-up commit adding the RFC 7919 primes this
reduces the startup time to what it was before Scapy 2.7.0: &lt; 1s.

Reverting from 64 MR rounds to BN_check_primes rounds, we would still
have ~8s startup time without this optimization, which isn't great for
an interactive tool.

Clearly, it's not entirely our fault, it's also Scapy and cryptography
that do something ... suboptimal, but I think we're better off if
DH_check() isn't a complete DoS vector. If you're using non-standard
parameters with FFDH, you deserve it.

We could consider adding a flag for non-well-known p and thus making
DH_check() indicate failure for candidate primes larger than, say, 4k.

https://github.com/pyca/cryptography/issues/14048

ok beck kenjiro
</content>
</entry>
<entry>
<title>Use err_local.h rather than err.h in most places</title>
<updated>2025-05-10T05:54:39+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2025-05-10T05:54:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=41e8f99dd1625a9f0c80ce9d4383e95b18e85709'/>
<id>urn:sha1:41e8f99dd1625a9f0c80ce9d4383e95b18e85709</id>
<content type='text'>
ok jsing
</content>
</entry>
<entry>
<title>Remove X9.42 DH rudiments</title>
<updated>2024-11-29T15:59:57+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2024-11-29T15:59:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=30b4f7f318b03413f22e3849cf9eeba83c165643'/>
<id>urn:sha1:30b4f7f318b03413f22e3849cf9eeba83c165643</id>
<content type='text'>
In the unlikely event that we should ever decide to implement this after
a quarter century of not needing it, we can readily put this back. Until
then this is dead weight.

prompted by a question by djm
ok jsing
</content>
</entry>
<entry>
<title>Garbage collect the DH_check*_ex() API</title>
<updated>2024-08-30T17:44:56+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2024-08-30T17:44:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=67d80505486d7a6c9512d45a4d7e0add8a2b13ec'/>
<id>urn:sha1:67d80505486d7a6c9512d45a4d7e0add8a2b13ec</id>
<content type='text'>
This was only needed by the EVP_PKEY_*check() API, which was defanged. So
this silly garbage can now go: it translated flags to errors on the error
stack so that openssl *check could print ugly errors while DoS-ing the
user.

ok beck
</content>
</entry>
<entry>
<title>Fix a minibug in DH_check()</title>
<updated>2023-07-24T16:25:02+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2023-07-24T16:25:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=ae68984cb6546bfc49fe5398fa5b46c84d803d60'/>
<id>urn:sha1:ae68984cb6546bfc49fe5398fa5b46c84d803d60</id>
<content type='text'>
Or in the flag, don't overwrite the already set ones.

ok jsing
</content>
</entry>
<entry>
<title>Hide symbols in dh</title>
<updated>2023-07-08T15:29:04+00:00</updated>
<author>
<name>beck</name>
<email></email>
</author>
<published>2023-07-08T15:29:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=c15c3edb5607f3e03c47fdea19a5828ad6d9c477'/>
<id>urn:sha1:c15c3edb5607f3e03c47fdea19a5828ad6d9c477</id>
<content type='text'>
ok tb@
</content>
</entry>
<entry>
<title>Make internal header file names consistent</title>
<updated>2022-11-26T16:08:57+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2022-11-26T16:08:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=81d98bf600a381a625eb11b39a725b08c0ba547f'/>
<id>urn:sha1:81d98bf600a381a625eb11b39a725b08c0ba547f</id>
<content type='text'>
Libcrypto currently has a mess of *_lcl.h, *_locl.h, and *_local.h names
used for internal headers. Move all these headers we inherited from
OpenSSL to *_local.h, reserving the name *_internal.h for our own code.
Similarly, move dtls_locl.h and ssl_locl.h to dtls_local and ssl_local.h.
constant_time_locl.h is moved to constant_time.h since it's special.

Adjust all .c files in libcrypto, libssl and regress.

The diff is mechanical with the exception of tls13_quic.c, where
#include &lt;ssl_locl.h&gt; was fixed manually.

discussed with jsing,
no objection bcook
</content>
</entry>
<entry>
<title>Simplify computation of max_pub_key = dh-&gt;p - 1.</title>
<updated>2022-07-13T18:38:20+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2022-07-13T18:38:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=c5df41ab4c6221a6afbdce624a917ed470179c2e'/>
<id>urn:sha1:c5df41ab4c6221a6afbdce624a917ed470179c2e</id>
<content type='text'>
ok jsing
</content>
</entry>
<entry>
<title>Provide DH_check*_ex and many error codes</title>
<updated>2022-01-10T12:00:52+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2022-01-10T12:00:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=7f7aefb469a9916b1d914a9fabaed99bb909ef8d'/>
<id>urn:sha1:7f7aefb469a9916b1d914a9fabaed99bb909ef8d</id>
<content type='text'>
DH_check{,_pub_key}_ex() wrap their non-ex versions to translate
the flags argument of the original functions into OpenSSL errors.
For this almost a dozen new error codes need to be added.

DH_params_check{,_ex}() is a new version of DH_check that only
performs a cheap subset of the checks.

They are needed to implement EVP_PKEY_{public,param}_check()
(observe the consistent naming) although the actual implementation
of EVP_PKEY_param_check() chose to use DH_check_ex().

As far as I can tell, the only raison d'être of the _ex functions
and error codes is to spew them to stderr in a couple of openssl(1)
commands. This couldn't have been solved differently...

These functions will not be exposed publicly.

ok inoguchi jsing
</content>
</entry>
</feed>
