return ret;
}
+static int success = 1;
+static void md_names(const char *name, void *vctx)
+{
+ OSSL_LIB_CTX *ctx = (OSSL_LIB_CTX *)vctx;
+ /* Force a namemap update */
+ EVP_CIPHER *aes128 = EVP_CIPHER_fetch(ctx, "AES-128-CBC", NULL);
+
+ if (!TEST_ptr(aes128))
+ success = 0;
+
+ EVP_CIPHER_free(aes128);
+}
+
+/*
+ * Test that changing the namemap in a user callback works in a names_do_all
+ * function.
+ */
+static int test_names_do_all(void)
+{
+ /* We use a custom libctx so that we know the state of the namemap */
+ OSSL_LIB_CTX *ctx = OSSL_LIB_CTX_new();
+ EVP_MD *sha256 = NULL;
+ int testresult = 0;
+
+ if (!TEST_ptr(ctx))
+ goto err;
+
+ sha256 = EVP_MD_fetch(ctx, "SHA2-256", NULL);
+ if (!TEST_ptr(sha256))
+ goto err;
+
+ /*
+ * We loop through all the names for a given digest. This should still work
+ * even if the namemap changes part way through.
+ */
+ if (!TEST_true(EVP_MD_names_do_all(sha256, md_names, ctx)))
+ goto err;
+
+ if (!TEST_true(success))
+ goto err;
+
+ testresult = 1;
+ err:
+ EVP_MD_free(sha256);
+ OSSL_LIB_CTX_free(ctx);
+ return testresult;
+}
int setup_tests(void)
{
ADD_ALL_TESTS(test_evp_iv, 10);
ADD_TEST(test_EVP_rsa_pss_with_keygen_bits);
+ ADD_TEST(test_names_do_all);
+
return 1;
}