Test that we generate a short private key for known DH prime
@@ -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;
