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