Skip to content

Commit

Permalink
EVP_get_default_properties - tests
Browse files Browse the repository at this point in the history
  • Loading branch information
beldmit committed Sep 11, 2024
1 parent 2d55024 commit 6af03e8
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion test/evp_extra_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -868,25 +868,48 @@ static int test_EVP_set_default_properties(void)
OSSL_LIB_CTX *ctx;
EVP_MD *md = NULL;
int res = 0;
char *fetched_properties = NULL;
const char test_propq[] = "provider=fizzbang";
const char test_fips_propq[] = "fips=yes,provider=fizzbang";

if (!TEST_ptr(ctx = OSSL_LIB_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"))
if (!TEST_true(EVP_set_default_properties(ctx, test_propq))
|| !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;

fetched_properties = EVP_get1_default_properties(ctx);
if (!TEST_ptr(fetched_properties)
|| !TEST_false(strcmp(fetched_properties, test_propq)))
goto err;
OPENSSL_free(fetched_properties);
fetched_properties = NULL;

if (!TEST_true(EVP_default_properties_enable_fips(ctx, 1)))
goto err;
fetched_properties = EVP_get1_default_properties(ctx);
if (!TEST_ptr(fetched_properties)
|| !TEST_false(strcmp(fetched_properties, test_fips_propq)))
goto err;
OPENSSL_free(fetched_properties);
fetched_properties = NULL;

if (!TEST_true(EVP_default_properties_enable_fips(ctx, 0)))
goto err;

if (!TEST_true(EVP_set_default_properties(ctx, NULL))
|| !TEST_ptr(md = EVP_MD_fetch(ctx, "sha256", NULL)))
goto err;
res = 1;
err:
OPENSSL_free(fetched_properties);
EVP_MD_free(md);
OSSL_LIB_CTX_free(ctx);
return res;
Expand Down

0 comments on commit 6af03e8

Please sign in to comment.