diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2021-03-11 13:36:27 +1000 |
---|---|---|
committer | Shane Lontis <shane.lontis@oracle.com> | 2021-03-15 09:01:51 +1000 |
commit | 3a37ddde911fe735c73121a8a561451cc719fc91 (patch) | |
tree | 36c5f038fa4efbf166358a48e465744bd3c965ca /test | |
parent | 91bd45eb9ac26daf87abc2c21cb03143a745a420 (diff) |
Fix DSA EVP_PKEY_param_check() when defaults are used for param generation.
Fixes #14480
An internal flag that is set during param gen was not being tested, so
the wrong type was used to select the dsa domain param validation method.
In the default provider - if no gen_type is set then by default the fips186_4 gentype
will be selected when pbits >=2048 otherwise it selects fips186_2.
The fips provider ignores the gen_type and always uses fips186_4.
Before this change dsa used fips186_2 by default in the default
provider.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14508)
Diffstat (limited to 'test')
-rw-r--r-- | test/dsatest.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/dsatest.c b/test/dsatest.c index 962946602e..2b65e199df 100644 --- a/test/dsatest.c +++ b/test/dsatest.c @@ -302,6 +302,27 @@ end: return ret; } +static int test_dsa_default_paramgen_validate(int i) +{ + int ret; + EVP_PKEY_CTX *gen_ctx = NULL; + EVP_PKEY_CTX *check_ctx = NULL; + EVP_PKEY *params = NULL; + + ret = TEST_ptr(gen_ctx = EVP_PKEY_CTX_new_from_name(NULL, "DSA", NULL)) + && TEST_int_gt(EVP_PKEY_paramgen_init(gen_ctx), 0) + && (i == 0 + || TEST_true(EVP_PKEY_CTX_set_dsa_paramgen_bits(gen_ctx, 512))) + && TEST_int_gt(EVP_PKEY_gen(gen_ctx, ¶ms), 0) + && TEST_ptr(check_ctx = EVP_PKEY_CTX_new_from_pkey(NULL, params, NULL)) + && TEST_int_gt(EVP_PKEY_param_check(check_ctx), 0); + + EVP_PKEY_free(params); + EVP_PKEY_CTX_free(check_ctx); + EVP_PKEY_CTX_free(gen_ctx); + return ret; +} + #endif /* OPENSSL_NO_DSA */ int setup_tests(void) @@ -309,6 +330,7 @@ int setup_tests(void) #ifndef OPENSSL_NO_DSA ADD_TEST(dsa_test); ADD_TEST(dsa_keygen_test); + ADD_ALL_TESTS(test_dsa_default_paramgen_validate, 2); #endif return 1; } |