summaryrefslogtreecommitdiffstats
path: root/crypto/dh
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2022-07-13 15:06:00 +0200
committerTomas Mraz <tomas@openssl.org>2022-07-19 12:11:02 +0200
commit8ed6ddcaa559b7b04202c15ea3a95ee0b05caeba (patch)
tree76676c06c89ddb1e2426799a2d0ab26729d30c79 /crypto/dh
parentb89a5b8df909cb3c10b2efe72dc32755e66771b6 (diff)
For known safe primes use the minimum key length according to RFC 7919
Longer private key sizes unnecessarily raise the cycles needed to compute the shared secret without any increase of the real security. This fixes a regression from 1.1.1 where these shorter keys were generated for the known safe primes. Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Kurt Roeckx <kurt@roeckx.be> (Merged from https://github.com/openssl/openssl/pull/18793)
Diffstat (limited to 'crypto/dh')
-rw-r--r--crypto/dh/dh_group_params.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/crypto/dh/dh_group_params.c b/crypto/dh/dh_group_params.c
index 3f843fe956..460bd8f009 100644
--- a/crypto/dh/dh_group_params.c
+++ b/crypto/dh/dh_group_params.c
@@ -31,7 +31,7 @@ static DH *dh_param_init(OSSL_LIB_CTX *libctx, const DH_NAMED_GROUP *group)
if (dh == NULL)
return NULL;
- ossl_ffc_named_group_set_pqg(&dh->params, group);
+ ossl_ffc_named_group_set(&dh->params, group);
dh->params.nid = ossl_ffc_named_group_get_uid(group);
dh->dirty_cnt++;
return dh;
@@ -72,8 +72,9 @@ void ossl_dh_cache_named_group(DH *dh)
dh->params.g)) != NULL) {
if (dh->params.q == NULL)
dh->params.q = (BIGNUM *)ossl_ffc_named_group_get_q(group);
- /* cache the nid */
+ /* cache the nid and default key length */
dh->params.nid = ossl_ffc_named_group_get_uid(group);
+ dh->params.keylength = ossl_ffc_named_group_get_keylength(group);
dh->dirty_cnt++;
}
}