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