Repository navigation
Check DiffieHellman parameters only when verifyError is read - #8931
Merged
Merged
Conversation
DiffieHellmanHandle ran DH_check() in its constructor, so every createDiffieHellman(), createDiffieHellmanGroup() and getDiffieHellman() paid for primality tests of the prime and of (p-1)/2, whether or not the script ever read verifyError. For the 2048-bit and larger standard groups, those tests cost far more CPU than anything else the handle does. DH_check() reads only the prime and generator, which never change after construction, so getVerifyError() now runs it on first use and caches the result. crypto_dh-test created a dozen such handles, and also generated two random 1024-bit safe primes, whose search time varies widely from run to run. It took 6-13 s in debug builds and close to a minute on slow CI machines. dhKeygenTest now generates a 512-bit prime, which FIPS-mode BoringSSL accepts too, despite the comment the test had. dhPubKeyValidation, which needs no generated prime, uses modp14's. The test now takes about a second, so it no longer needs the enormous size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
DiffieHellmanHandleranDH_check()in its constructor, so everycreateDiffieHellman(),createDiffieHellmanGroup()andgetDiffieHellman()paid for primality tests of the prime and of (p-1)/2, whether or not the script ever readverifyError. For the 2048-bit and larger standard groups, those tests cost far more CPU than anything else the handle does.DH_check()reads only the prime and generator, which never change after construction, sogetVerifyError()now runs it on first use and caches the result.crypto_dh-testcreated a dozen such handles and also generated two random 1024-bit safe primes, whose search time varies widely from run to run. It took 6–13 s in debug builds and close to a minute on slow CI machines. Now:dhKeygenTestgenerates a 512-bit prime. FIPS-mode BoringSSL accepts that too, despite what the test's comment said.dhPubKeyValidationneeds no generated prime, so it uses modp14's.enormoussize.Five runs of each variant: debug max 1.6 s, ASan 3.7 s, release 1.1 s.
🤖 Generated with Claude Code