2 * Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #include <openssl/evp.h>
14 * Test that the default libctx does not get initialised when using a custom
15 * libctx. We assume that this test application has been executed such that the
16 * null provider is loaded via the config file.
18 static int test_no_deflt_ctx_init(void)
22 OSSL_LIB_CTX
*ctx
= OSSL_LIB_CTX_new();
27 md
= EVP_MD_fetch(ctx
, "SHA2-256", NULL
);
32 * Since we're using a non-default libctx above, the default libctx should
33 * not have been initialised via config file, and so it is not too late to
34 * use OPENSSL_INIT_NO_LOAD_CONFIG.
36 OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG
, NULL
);
39 * If the config file was incorrectly loaded then the null provider will
40 * have been initialised and the default provider loading will have been
41 * blocked. If the config file was NOT loaded (as we expect) then the
42 * default provider should be available.
44 if (!TEST_true(OSSL_PROVIDER_available(NULL
, "default")))
46 if (!TEST_false(OSSL_PROVIDER_available(NULL
, "null")))
52 OSSL_LIB_CTX_free(ctx
);
58 ADD_TEST(test_no_deflt_ctx_init
);