]>
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
, OSSL_PROVIDER
**default_null_prov
,
15 const char *config_file
,
16 OSSL_PROVIDER
**provider
, const char *module_name
)
18 if ((*libctx
= OSSL_LIB_CTX_new()) == NULL
) {
19 opt_printf_stderr("Failed to create libctx\n");
23 if (default_null_prov
!= NULL
24 && (*default_null_prov
= OSSL_PROVIDER_load(NULL
, "null")) == NULL
) {
25 opt_printf_stderr("Failed to load null provider into default libctx\n");
29 if (config_file
!= NULL
30 && !OSSL_LIB_CTX_load_config(*libctx
, config_file
)) {
31 opt_printf_stderr("Error loading config from file %s\n", config_file
);
35 if (module_name
!= NULL
36 && (*provider
= OSSL_PROVIDER_load(*libctx
, module_name
)) == NULL
) {
37 opt_printf_stderr("Failed to load provider %s\n", module_name
);
43 ERR_print_errors_fp(stderr
);
47 int test_arg_libctx(OSSL_LIB_CTX
**libctx
, OSSL_PROVIDER
**default_null_prov
,
48 OSSL_PROVIDER
**provider
, int argn
, const char *usage
)
50 const char *module_name
;
52 if (!TEST_ptr(module_name
= test_get_argument(argn
))) {
53 TEST_error("usage: <prog> %s", usage
);
56 if (strcmp(module_name
, "none") == 0)
58 return test_get_libctx(libctx
, default_null_prov
,
59 test_get_argument(argn
+ 1), provider
, module_name
);