summaryrefslogtreecommitdiff
path: root/test/evp_extra_test2.c
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2022-05-05 14:45:23 +0200
committerPauli <pauli@openssl.org>2022-05-09 10:09:39 +1000
commit4b4d0ded6df357f76f580b7218abb3fe55f64463 (patch)
tree517f7109a34a171d47226c8ca86aebad5c2c54c7 /test/evp_extra_test2.c
parent0b3d2594d060dc19269d3740ad672f065ec6398a (diff)
downloadopenssl-new-4b4d0ded6df357f76f580b7218abb3fe55f64463.tar.gz
Add a testcase for OSSL_PROVIDER_unload() being fully effective
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18254)
Diffstat (limited to 'test/evp_extra_test2.c')
-rw-r--r--test/evp_extra_test2.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/evp_extra_test2.c b/test/evp_extra_test2.c
index aadfc6216a..bdadc30a7e 100644
--- a/test/evp_extra_test2.c
+++ b/test/evp_extra_test2.c
@@ -512,6 +512,42 @@ static int test_alternative_default(void)
return ok;
}
+static int test_provider_unload_effective(int testid)
+{
+ EVP_MD *sha256 = NULL;
+ OSSL_PROVIDER *provider = NULL;
+ int ok = 0;
+
+ if (!TEST_ptr(provider = OSSL_PROVIDER_load(NULL, "default"))
+ || !TEST_ptr(sha256 = EVP_MD_fetch(NULL, "SHA2-256", NULL)))
+ goto err;
+
+ if (testid > 0) {
+ OSSL_PROVIDER_unload(provider);
+ provider = NULL;
+ EVP_MD_free(sha256);
+ sha256 = NULL;
+ } else {
+ EVP_MD_free(sha256);
+ sha256 = NULL;
+ OSSL_PROVIDER_unload(provider);
+ provider = NULL;
+ }
+
+ /*
+ * setup_tests() loaded the "null" provider in the current default, and
+ * we unloaded it above after the load so we know this fetch should fail.
+ */
+ if (!TEST_ptr_null(sha256 = EVP_MD_fetch(NULL, "SHA2-256", NULL)))
+ goto err;
+
+ ok = 1;
+ err:
+ EVP_MD_free(sha256);
+ OSSL_PROVIDER_unload(provider);
+ return ok;
+}
+
static int test_d2i_PrivateKey_ex(int testid)
{
int ok = 0;
@@ -1064,6 +1100,7 @@ int setup_tests(void)
ADD_TEST(test_rsa_pss_sign);
ADD_TEST(test_evp_md_ctx_dup);
ADD_TEST(test_evp_md_ctx_copy);
+ ADD_ALL_TESTS(test_provider_unload_effective, 2);
return 1;
}