diff options
author | Pauli <paul.dale@oracle.com> | 2020-06-12 10:34:46 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2020-06-23 21:44:47 +1000 |
commit | f9e504e8b1d4da4b8c9c16ee4c11e9815a800422 (patch) | |
tree | a53b2ee1974b87cdc17f3367338ef4f8abead154 /test/evp_extra_test.c | |
parent | 1b495200436b57309ca958a7a72affaf75171c1a (diff) |
property: Move global default properties to the library context.
Fixes a problem where global properties don't work with a NULL query.
Specifying an algorithm with a NULL query ignores the default properties.
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12123)
Diffstat (limited to 'test/evp_extra_test.c')
-rw-r--r-- | test/evp_extra_test.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index 7f07ab738e..fe139fbf17 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -471,6 +471,35 @@ static EVP_PKEY *load_example_hmac_key(void) return pkey; } +static int test_EVP_set_default_properties(void) +{ + OPENSSL_CTX *ctx; + EVP_MD *md = NULL; + int res = 0; + + if (!TEST_ptr(ctx = OPENSSL_CTX_new()) + || !TEST_ptr(md = EVP_MD_fetch(ctx, "sha256", NULL))) + goto err; + EVP_MD_free(md); + md = NULL; + + if (!TEST_true(EVP_set_default_properties(ctx, "provider=fizzbang")) + || !TEST_ptr_null(md = EVP_MD_fetch(ctx, "sha256", NULL)) + || !TEST_ptr(md = EVP_MD_fetch(ctx, "sha256", "-provider"))) + goto err; + EVP_MD_free(md); + md = NULL; + + if (!TEST_true(EVP_set_default_properties(ctx, NULL)) + || !TEST_ptr(md = EVP_MD_fetch(ctx, "sha256", NULL))) + goto err; + res = 1; +err: + EVP_MD_free(md); + OPENSSL_CTX_free(ctx); + return res; +} + static int test_EVP_Enveloped(void) { int ret = 0; @@ -1748,6 +1777,7 @@ int setup_tests(void) if (!TEST_ptr(testctx)) return 0; + ADD_TEST(test_EVP_set_default_properties); ADD_ALL_TESTS(test_EVP_DigestSignInit, 9); ADD_TEST(test_EVP_DigestVerifyInit); ADD_TEST(test_EVP_Enveloped); |