Store the list of activated providers in the libctx
[openssl.git] / include / internal / provider.h
1 /*
2  * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
3  *
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
8  */
9
10 #ifndef OSSL_INTERNAL_PROVIDER_H
11 # define OSSL_INTERNAL_PROVIDER_H
12 # pragma once
13
14 # include <openssl/core.h>
15 # include <openssl/core_dispatch.h>
16 # include "internal/dso.h"
17 # include "internal/symhacks.h"
18
19 # ifdef __cplusplus
20 extern "C" {
21 # endif
22
23 /*
24  * namespaces:
25  *
26  * ossl_provider_       Provider Object internal API
27  * OSSL_PROVIDER        Provider Object
28  */
29
30 /* Provider Object finder, constructor and destructor */
31 OSSL_PROVIDER *ossl_provider_find(OSSL_LIB_CTX *libctx, const char *name,
32                                   int noconfig);
33 OSSL_PROVIDER *ossl_provider_new(OSSL_LIB_CTX *libctx, const char *name,
34                                  OSSL_provider_init_fn *init_function,
35                                  int noconfig);
36 int ossl_provider_up_ref(OSSL_PROVIDER *prov);
37 void ossl_provider_free(OSSL_PROVIDER *prov);
38
39 /* Setters */
40 int ossl_provider_set_fallback(OSSL_PROVIDER *prov);
41 int ossl_provider_set_module_path(OSSL_PROVIDER *prov, const char *module_path);
42 int ossl_provider_add_parameter(OSSL_PROVIDER *prov, const char *name,
43                                 const char *value);
44
45 /* Disable fallback loading */
46 int ossl_provider_disable_fallback_loading(OSSL_LIB_CTX *libctx);
47
48 /*
49  * Activate the Provider
50  * If the Provider is a module, the module will be loaded
51  */
52 int ossl_provider_activate(OSSL_PROVIDER *prov, int retain_fallbacks);
53 int ossl_provider_deactivate(OSSL_PROVIDER *prov);
54 /* Check if the provider is available (activated) */
55 int ossl_provider_available(OSSL_PROVIDER *prov);
56
57 /* Return pointer to the provider's context */
58 void *ossl_provider_ctx(const OSSL_PROVIDER *prov);
59
60 /* Iterate over all loaded providers */
61 int ossl_provider_doall_activated(OSSL_LIB_CTX *,
62                                   int (*cb)(OSSL_PROVIDER *provider,
63                                             void *cbdata),
64                                   void *cbdata);
65
66 /* Getters for other library functions */
67 const char *ossl_provider_name(const OSSL_PROVIDER *prov);
68 const DSO *ossl_provider_dso(const OSSL_PROVIDER *prov);
69 const char *ossl_provider_module_name(const OSSL_PROVIDER *prov);
70 const char *ossl_provider_module_path(const OSSL_PROVIDER *prov);
71 void *ossl_provider_prov_ctx(const OSSL_PROVIDER *prov);
72 OSSL_LIB_CTX *ossl_provider_libctx(const OSSL_PROVIDER *prov);
73
74 /* Thin wrappers around calls to the provider */
75 void ossl_provider_teardown(const OSSL_PROVIDER *prov);
76 const OSSL_PARAM *ossl_provider_gettable_params(const OSSL_PROVIDER *prov);
77 int ossl_provider_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]);
78 int ossl_provider_get_capabilities(const OSSL_PROVIDER *prov,
79                                    const char *capability,
80                                    OSSL_CALLBACK *cb,
81                                    void *arg);
82 int ossl_provider_self_test(const OSSL_PROVIDER *prov);
83 const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov,
84                                                     int operation_id,
85                                                     int *no_cache);
86 void ossl_provider_unquery_operation(const OSSL_PROVIDER *prov,
87                                      int operation_id,
88                                      const OSSL_ALGORITHM *algs);
89
90 /* Cache of bits to see if we already queried an operation */
91 int ossl_provider_set_operation_bit(OSSL_PROVIDER *provider, size_t bitnum);
92 int ossl_provider_test_operation_bit(OSSL_PROVIDER *provider, size_t bitnum,
93                                      int *result);
94
95 /* Configuration */
96 void ossl_provider_add_conf_module(void);
97
98 # ifdef __cplusplus
99 }
100 # endif
101
102 #endif