diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index b28611d0ca9ac1..29068c10eebbc7 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -868,6 +868,9 @@ 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))) @@ -875,18 +878,38 @@ static int test_EVP_set_default_properties(void) 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;