]>
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 OSSL_LIB_CTX
*new_libctx
= NULL
;
21 if ((new_libctx
= *libctx
= OSSL_LIB_CTX_new()) == NULL
) {
22 opt_printf_stderr("Failed to create libctx\n");
27 if (default_null_prov
!= NULL
28 && (*default_null_prov
= OSSL_PROVIDER_load(NULL
, "null")) == NULL
) {
29 opt_printf_stderr("Failed to load null provider into default libctx\n");
33 if (config_file
!= NULL
34 && !OSSL_LIB_CTX_load_config(new_libctx
, config_file
)) {
35 opt_printf_stderr("Error loading config from file %s\n", config_file
);
39 if (module_name
!= NULL
40 && (*provider
= OSSL_PROVIDER_load(new_libctx
, module_name
)) == NULL
) {
41 opt_printf_stderr("Failed to load provider %s\n", module_name
);
47 ERR_print_errors_fp(stderr
);
51 int test_arg_libctx(OSSL_LIB_CTX
**libctx
, OSSL_PROVIDER
**default_null_prov
,
52 OSSL_PROVIDER
**provider
, int argn
, const char *usage
)
54 const char *module_name
;
56 if (!TEST_ptr(module_name
= test_get_argument(argn
))) {
57 TEST_error("usage: <prog> %s", usage
);
60 if (strcmp(module_name
, "none") == 0)
62 return test_get_libctx(libctx
, default_null_prov
,
63 test_get_argument(argn
+ 1), provider
, module_name
);