mirror of
https://github.com/openssl/openssl.git
synced 2025-01-18 13:44:20 +08:00
Test that we generate a short private key for known DH prime
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)
This commit is contained in:
parent
2885b2ca4e
commit
2266d1cad0
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user