]>
git.ipfire.org Git - thirdparty/openssl.git/blob - test/testutil/provider.c
2 * Copyright 2018-2020 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 "../testutil.h"
11 #include <openssl/provider.h>
14 int test_get_libctx(OSSL_LIB_CTX
**libctx
,
15 OSSL_PROVIDER
**default_null_provider
,
16 OSSL_PROVIDER
**provider
, int argn
, const char *usage
)
18 const char *module_name
;
20 if (!TEST_ptr(module_name
= test_get_argument(argn
))) {
21 TEST_error("usage: <prog> %s", usage
);
24 if (strcmp(module_name
, "none") != 0) {
25 const char *config_fname
= test_get_argument(argn
+ 1);
27 *default_null_provider
= OSSL_PROVIDER_load(NULL
, "null");
28 *libctx
= OSSL_LIB_CTX_new();
29 if (!TEST_ptr(*libctx
)) {
30 TEST_error("Failed to create libctx\n");
34 if (config_fname
!= NULL
35 && !TEST_true(OSSL_LIB_CTX_load_config(*libctx
, config_fname
))) {
36 TEST_error("Error loading config file %s\n", config_fname
);
40 *provider
= OSSL_PROVIDER_load(*libctx
, module_name
);
41 if (!TEST_ptr(*provider
)) {
42 TEST_error("Failed to load provider %s\n", module_name
);
49 ERR_print_errors_fp(stderr
);