summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2022-07-13 16:04:09 +0200
committerTomas Mraz <tomas@openssl.org>2022-07-19 12:11:02 +0200
commit5eac066bef0c23bb74255423d335e634e4deb8d5 (patch)
tree1dcd4ce7fd2c91724e00f48ad4b1ceb512e30458
parentc9bdbc12ac7343992ba249e11d2bda3338469a97 (diff)
Test that we generate a short private key for known DH prime
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Kurt Roeckx <kurt@roeckx.be> (Merged from https://github.com/openssl/openssl/pull/18793)
-rw-r--r--test/evp_extra_test2.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/evp_extra_test2.c b/test/evp_extra_test2.c
index 0021c44341..75072885c2 100644
--- a/test/evp_extra_test2.c
+++ b/test/evp_extra_test2.c
@@ -333,6 +333,10 @@ static int test_dh_tofrom_data_select(void)
OSSL_PARAM params[2];
EVP_PKEY *key = NULL;
EVP_PKEY_CTX *gctx = NULL;
+# ifndef OPENSSL_NO_DEPRECATED_3_0
+ const DH *dhkey;
+ const BIGNUM *privkey;
+# endif
params[0] = OSSL_PARAM_construct_utf8_string("group", "ffdhe2048", 0);
params[1] = OSSL_PARAM_construct_end();
@@ -341,6 +345,12 @@ static int test_dh_tofrom_data_select(void)
&& TEST_true(EVP_PKEY_CTX_set_params(gctx, params))
&& TEST_int_gt(EVP_PKEY_generate(gctx, &key), 0)
&& TEST_true(do_pkey_tofrom_data_select(key, "DHX"));
+# ifndef OPENSSL_NO_DEPRECATED_3_0
+ dhkey = EVP_PKEY_get0_DH(key);
+ ret = ret && TEST_ptr(dhkey);
+ ret = ret && TEST_ptr(privkey = DH_get0_priv_key(dhkey))
+ && TEST_int_le(BN_num_bits(privkey), 225);
+# endif
EVP_PKEY_free(key);
EVP_PKEY_CTX_free(gctx);
return ret;