diff options
author | Tomas Mraz <tomas@openssl.org> | 2022-11-09 13:36:21 +0100 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-11-11 12:01:41 +0100 |
commit | 985eb23fbf83c1b83ca13798a9c84c8abfe7edc9 (patch) | |
tree | b6f8beabc7be80c38d54d0f52d9b2d42d628a206 /test | |
parent | 729295023af4598efa6ce5b4ead0dab73345816c (diff) |
Add test for generating safeprime DH parameters
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19635)
(cherry picked from commit 10119e7475bb198e13b1722b186303b8a7528dfe)
Diffstat (limited to 'test')
-rw-r--r-- | test/evp_extra_test2.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/evp_extra_test2.c b/test/evp_extra_test2.c index fc73994ca3..c8ae45ca78 100644 --- a/test/evp_extra_test2.c +++ b/test/evp_extra_test2.c @@ -356,6 +356,30 @@ static int test_dh_tofrom_data_select(void) EVP_PKEY_CTX_free(gctx); return ret; } + +static int test_dh_paramgen(void) +{ + int ret; + OSSL_PARAM params[3]; + EVP_PKEY *pkey = NULL; + EVP_PKEY_CTX *gctx = NULL; + unsigned int pbits = 512; /* minimum allowed for speed */ + + params[0] = OSSL_PARAM_construct_uint(OSSL_PKEY_PARAM_FFC_PBITS, &pbits); + params[1] = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_FFC_TYPE, + "generator", 0); + params[2] = OSSL_PARAM_construct_end(); + + ret = TEST_ptr(gctx = EVP_PKEY_CTX_new_from_name(mainctx, "DH", NULL)) + && TEST_int_gt(EVP_PKEY_paramgen_init(gctx), 0) + && TEST_true(EVP_PKEY_CTX_set_params(gctx, params)) + && TEST_true(EVP_PKEY_paramgen(gctx, &pkey)) + && TEST_ptr(pkey); + + EVP_PKEY_CTX_free(gctx); + EVP_PKEY_free(pkey); + return ret; +} #endif #ifndef OPENSSL_NO_EC @@ -1126,6 +1150,7 @@ int setup_tests(void) #endif #ifndef OPENSSL_NO_DH ADD_TEST(test_dh_tofrom_data_select); + ADD_TEST(test_dh_paramgen); #endif ADD_TEST(test_rsa_tofrom_data_select); |