Use as small dh key size as possible to support the security
authorTomas Mraz <tomas@openssl.org>
Mon, 6 Jun 2022 08:22:00 +0000 (10:22 +0200)
committerTomas Mraz <tomas@openssl.org>
Mon, 21 Nov 2022 09:49:52 +0000 (10:49 +0100)
commitac214d7015572bd8d715d79631c2d15b6d06f6ac
tree52605424f716de9e41e490477ccb2833a763fe2e
parent1f664896b90f7e57ee831bfa38ac03992da0e2a4
Use as small dh key size as possible to support the security

Longer private key sizes unnecessarily raise the cycles needed to
compute the shared secret without any increase of the real security.

We use minimum key sizes as defined in RFC7919.

For arbitrary parameters we cannot know whether they are safe
primes (we could test but that would be too inefficient) we have
to keep generating large keys.

However we now set a small dh->length when we are generating safe prime
parameters because we know it is safe to use small keys with them.

That means users need to regenerate the parameters if they
want to take the performance advantage of small private key.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18480)

(cherry picked from commit ddb13b283be84d771deba1e964610b1670641f03)
CHANGES.md
crypto/dh/dh_gen.c