diff options
author | Tomas Mraz <tomas@openssl.org> | 2022-11-09 13:36:21 +0100 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-11-11 11:59:23 +0100 |
commit | 10119e7475bb198e13b1722b186303b8a7528dfe (patch) | |
tree | 3a86623006dbf4a5c61405302e44d4786ca03912 /test/evp_extra_test2.c | |
parent | 990d280da95d3c955b86f38b01f5b95ea88d42bb (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)
Diffstat (limited to 'test/evp_extra_test2.c')
-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 b03b6bd234..3daa2e1985 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 @@ -1156,6 +1180,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); |