xref: /freebsd/crypto/openssl/include/internal/provider.h (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1*b077aed3SPierre Pronchery /*
2*b077aed3SPierre Pronchery  * Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved.
3*b077aed3SPierre Pronchery  *
4*b077aed3SPierre Pronchery  * Licensed under the Apache License 2.0 (the "License").  You may not use
5*b077aed3SPierre Pronchery  * this file except in compliance with the License.  You can obtain a copy
6*b077aed3SPierre Pronchery  * in the file LICENSE in the source distribution or at
7*b077aed3SPierre Pronchery  * https://www.openssl.org/source/license.html
8*b077aed3SPierre Pronchery  */
9*b077aed3SPierre Pronchery 
10*b077aed3SPierre Pronchery #ifndef OSSL_INTERNAL_PROVIDER_H
11*b077aed3SPierre Pronchery # define OSSL_INTERNAL_PROVIDER_H
12*b077aed3SPierre Pronchery # pragma once
13*b077aed3SPierre Pronchery 
14*b077aed3SPierre Pronchery # include <openssl/core.h>
15*b077aed3SPierre Pronchery # include <openssl/core_dispatch.h>
16*b077aed3SPierre Pronchery # include "internal/dso.h"
17*b077aed3SPierre Pronchery # include "internal/symhacks.h"
18*b077aed3SPierre Pronchery 
19*b077aed3SPierre Pronchery # ifdef __cplusplus
20*b077aed3SPierre Pronchery extern "C" {
21*b077aed3SPierre Pronchery # endif
22*b077aed3SPierre Pronchery 
23*b077aed3SPierre Pronchery /*
24*b077aed3SPierre Pronchery  * namespaces:
25*b077aed3SPierre Pronchery  *
26*b077aed3SPierre Pronchery  * ossl_provider_       Provider Object internal API
27*b077aed3SPierre Pronchery  * OSSL_PROVIDER        Provider Object
28*b077aed3SPierre Pronchery  */
29*b077aed3SPierre Pronchery 
30*b077aed3SPierre Pronchery /* Provider Object finder, constructor and destructor */
31*b077aed3SPierre Pronchery OSSL_PROVIDER *ossl_provider_find(OSSL_LIB_CTX *libctx, const char *name,
32*b077aed3SPierre Pronchery                                   int noconfig);
33*b077aed3SPierre Pronchery OSSL_PROVIDER *ossl_provider_new(OSSL_LIB_CTX *libctx, const char *name,
34*b077aed3SPierre Pronchery                                  OSSL_provider_init_fn *init_function,
35*b077aed3SPierre Pronchery                                  int noconfig);
36*b077aed3SPierre Pronchery int ossl_provider_up_ref(OSSL_PROVIDER *prov);
37*b077aed3SPierre Pronchery void ossl_provider_free(OSSL_PROVIDER *prov);
38*b077aed3SPierre Pronchery 
39*b077aed3SPierre Pronchery /* Setters */
40*b077aed3SPierre Pronchery int ossl_provider_set_fallback(OSSL_PROVIDER *prov);
41*b077aed3SPierre Pronchery int ossl_provider_set_module_path(OSSL_PROVIDER *prov, const char *module_path);
42*b077aed3SPierre Pronchery int ossl_provider_add_parameter(OSSL_PROVIDER *prov, const char *name,
43*b077aed3SPierre Pronchery                                 const char *value);
44*b077aed3SPierre Pronchery 
45*b077aed3SPierre Pronchery int ossl_provider_is_child(const OSSL_PROVIDER *prov);
46*b077aed3SPierre Pronchery int ossl_provider_set_child(OSSL_PROVIDER *prov, const OSSL_CORE_HANDLE *handle);
47*b077aed3SPierre Pronchery const OSSL_CORE_HANDLE *ossl_provider_get_parent(OSSL_PROVIDER *prov);
48*b077aed3SPierre Pronchery int ossl_provider_up_ref_parent(OSSL_PROVIDER *prov, int activate);
49*b077aed3SPierre Pronchery int ossl_provider_free_parent(OSSL_PROVIDER *prov, int deactivate);
50*b077aed3SPierre Pronchery int ossl_provider_default_props_update(OSSL_LIB_CTX *libctx, const char *props);
51*b077aed3SPierre Pronchery 
52*b077aed3SPierre Pronchery /* Disable fallback loading */
53*b077aed3SPierre Pronchery int ossl_provider_disable_fallback_loading(OSSL_LIB_CTX *libctx);
54*b077aed3SPierre Pronchery 
55*b077aed3SPierre Pronchery /*
56*b077aed3SPierre Pronchery  * Activate the Provider
57*b077aed3SPierre Pronchery  * If the Provider is a module, the module will be loaded
58*b077aed3SPierre Pronchery  */
59*b077aed3SPierre Pronchery int ossl_provider_activate(OSSL_PROVIDER *prov, int upcalls, int aschild);
60*b077aed3SPierre Pronchery int ossl_provider_deactivate(OSSL_PROVIDER *prov, int removechildren);
61*b077aed3SPierre Pronchery int ossl_provider_add_to_store(OSSL_PROVIDER *prov, OSSL_PROVIDER **actualprov,
62*b077aed3SPierre Pronchery                                int retain_fallbacks);
63*b077aed3SPierre Pronchery 
64*b077aed3SPierre Pronchery /* Return pointer to the provider's context */
65*b077aed3SPierre Pronchery void *ossl_provider_ctx(const OSSL_PROVIDER *prov);
66*b077aed3SPierre Pronchery 
67*b077aed3SPierre Pronchery /* Iterate over all loaded providers */
68*b077aed3SPierre Pronchery int ossl_provider_doall_activated(OSSL_LIB_CTX *,
69*b077aed3SPierre Pronchery                                   int (*cb)(OSSL_PROVIDER *provider,
70*b077aed3SPierre Pronchery                                             void *cbdata),
71*b077aed3SPierre Pronchery                                   void *cbdata);
72*b077aed3SPierre Pronchery 
73*b077aed3SPierre Pronchery /* Getters for other library functions */
74*b077aed3SPierre Pronchery const char *ossl_provider_name(const OSSL_PROVIDER *prov);
75*b077aed3SPierre Pronchery const DSO *ossl_provider_dso(const OSSL_PROVIDER *prov);
76*b077aed3SPierre Pronchery const char *ossl_provider_module_name(const OSSL_PROVIDER *prov);
77*b077aed3SPierre Pronchery const char *ossl_provider_module_path(const OSSL_PROVIDER *prov);
78*b077aed3SPierre Pronchery void *ossl_provider_prov_ctx(const OSSL_PROVIDER *prov);
79*b077aed3SPierre Pronchery const OSSL_DISPATCH *ossl_provider_get0_dispatch(const OSSL_PROVIDER *prov);
80*b077aed3SPierre Pronchery OSSL_LIB_CTX *ossl_provider_libctx(const OSSL_PROVIDER *prov);
81*b077aed3SPierre Pronchery 
82*b077aed3SPierre Pronchery /* Thin wrappers around calls to the provider */
83*b077aed3SPierre Pronchery void ossl_provider_teardown(const OSSL_PROVIDER *prov);
84*b077aed3SPierre Pronchery const OSSL_PARAM *ossl_provider_gettable_params(const OSSL_PROVIDER *prov);
85*b077aed3SPierre Pronchery int ossl_provider_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]);
86*b077aed3SPierre Pronchery int ossl_provider_get_capabilities(const OSSL_PROVIDER *prov,
87*b077aed3SPierre Pronchery                                    const char *capability,
88*b077aed3SPierre Pronchery                                    OSSL_CALLBACK *cb,
89*b077aed3SPierre Pronchery                                    void *arg);
90*b077aed3SPierre Pronchery int ossl_provider_self_test(const OSSL_PROVIDER *prov);
91*b077aed3SPierre Pronchery const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov,
92*b077aed3SPierre Pronchery                                                     int operation_id,
93*b077aed3SPierre Pronchery                                                     int *no_cache);
94*b077aed3SPierre Pronchery void ossl_provider_unquery_operation(const OSSL_PROVIDER *prov,
95*b077aed3SPierre Pronchery                                      int operation_id,
96*b077aed3SPierre Pronchery                                      const OSSL_ALGORITHM *algs);
97*b077aed3SPierre Pronchery 
98*b077aed3SPierre Pronchery /*
99*b077aed3SPierre Pronchery  * Cache of bits to see if we already added methods for an operation in
100*b077aed3SPierre Pronchery  * the "permanent" method store.
101*b077aed3SPierre Pronchery  * They should never be called for temporary method stores!
102*b077aed3SPierre Pronchery  */
103*b077aed3SPierre Pronchery int ossl_provider_set_operation_bit(OSSL_PROVIDER *provider, size_t bitnum);
104*b077aed3SPierre Pronchery int ossl_provider_test_operation_bit(OSSL_PROVIDER *provider, size_t bitnum,
105*b077aed3SPierre Pronchery                                      int *result);
106*b077aed3SPierre Pronchery 
107*b077aed3SPierre Pronchery /* Configuration */
108*b077aed3SPierre Pronchery void ossl_provider_add_conf_module(void);
109*b077aed3SPierre Pronchery 
110*b077aed3SPierre Pronchery /* Child providers */
111*b077aed3SPierre Pronchery int ossl_provider_init_as_child(OSSL_LIB_CTX *ctx,
112*b077aed3SPierre Pronchery                                 const OSSL_CORE_HANDLE *handle,
113*b077aed3SPierre Pronchery                                 const OSSL_DISPATCH *in);
114*b077aed3SPierre Pronchery void ossl_provider_deinit_child(OSSL_LIB_CTX *ctx);
115*b077aed3SPierre Pronchery 
116*b077aed3SPierre Pronchery # ifdef __cplusplus
117*b077aed3SPierre Pronchery }
118*b077aed3SPierre Pronchery # endif
119*b077aed3SPierre Pronchery 
120*b077aed3SPierre Pronchery #endif
121