From 99325852207e3f8ae970799235de169b40eded75 Mon Sep 17 00:00:00 2001 From: Shane Lontis Date: Tue, 15 Jun 2021 19:56:36 +1000 Subject: Fix DH private key check. A recent addition removed setting the dh private key length when a safe prime group is used. The private key validation check was relying on this being set for safe primes. Setting the upper bound no longer checks the length if the value is zero. This caused a failure in the daily build of acvp_tests. Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/15760) --- crypto/dh/dh_check.c | 2 +- crypto/dh/dh_lib.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'crypto/dh') diff --git a/crypto/dh/dh_check.c b/crypto/dh/dh_check.c index 61be68bf64..e75d20d862 100644 --- a/crypto/dh/dh_check.c +++ b/crypto/dh/dh_check.c @@ -262,7 +262,7 @@ int ossl_dh_check_priv_key(const DH *dh, const BIGNUM *priv_key, int *ret) upper = dh->params.q; /* Is it from an approved Safe prime group ?*/ - if (DH_get_nid((DH *)dh) != NID_undef) { + if (DH_get_nid((DH *)dh) != NID_undef && dh->length != 0) { if (!BN_lshift(two_powN, BN_value_one(), dh->length)) goto err; if (BN_cmp(two_powN, dh->params.q) < 0) diff --git a/crypto/dh/dh_lib.c b/crypto/dh/dh_lib.c index f5e0f893c1..7154f8c2ab 100644 --- a/crypto/dh/dh_lib.c +++ b/crypto/dh/dh_lib.c @@ -202,6 +202,7 @@ int DH_size(const DH *dh) int DH_security_bits(const DH *dh) { int N; + if (dh->params.q != NULL) N = BN_num_bits(dh->params.q); else if (dh->length) -- cgit v1.2.3