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