Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a testcase for OSSL_PROVIDER_unload() being fully effective #18254

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 37 additions & 0 deletions test/evp_extra_test2.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down