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_CORE_H 11*b077aed3SPierre Pronchery # define OSSL_INTERNAL_CORE_H 12*b077aed3SPierre Pronchery # pragma once 13*b077aed3SPierre Pronchery 14*b077aed3SPierre Pronchery /* 15*b077aed3SPierre Pronchery * namespaces: 16*b077aed3SPierre Pronchery * 17*b077aed3SPierre Pronchery * ossl_method_ Core Method API 18*b077aed3SPierre Pronchery */ 19*b077aed3SPierre Pronchery 20*b077aed3SPierre Pronchery /* 21*b077aed3SPierre Pronchery * construct an arbitrary method from a dispatch table found by looking 22*b077aed3SPierre Pronchery * up a match for the < operation_id, name, property > combination. 23*b077aed3SPierre Pronchery * constructor and destructor are the constructor and destructor for that 24*b077aed3SPierre Pronchery * arbitrary object. 25*b077aed3SPierre Pronchery * 26*b077aed3SPierre Pronchery * These objects are normally cached, unless the provider says not to cache. 27*b077aed3SPierre Pronchery * However, force_cache can be used to force caching whatever the provider 28*b077aed3SPierre Pronchery * says (for example, because the application knows better). 29*b077aed3SPierre Pronchery */ 30*b077aed3SPierre Pronchery typedef struct ossl_method_construct_method_st { 31*b077aed3SPierre Pronchery /* Get a temporary store */ 32*b077aed3SPierre Pronchery void *(*get_tmp_store)(void *data); 33*b077aed3SPierre Pronchery /* Reserve the appropriate method store */ 34*b077aed3SPierre Pronchery int (*lock_store)(void *store, void *data); 35*b077aed3SPierre Pronchery /* Unreserve the appropriate method store */ 36*b077aed3SPierre Pronchery int (*unlock_store)(void *store, void *data); 37*b077aed3SPierre Pronchery /* Get an already existing method from a store */ 38*b077aed3SPierre Pronchery void *(*get)(void *store, const OSSL_PROVIDER **prov, void *data); 39*b077aed3SPierre Pronchery /* Store a method in a store */ 40*b077aed3SPierre Pronchery int (*put)(void *store, void *method, const OSSL_PROVIDER *prov, 41*b077aed3SPierre Pronchery const char *name, const char *propdef, void *data); 42*b077aed3SPierre Pronchery /* Construct a new method */ 43*b077aed3SPierre Pronchery void *(*construct)(const OSSL_ALGORITHM *algodef, OSSL_PROVIDER *prov, 44*b077aed3SPierre Pronchery void *data); 45*b077aed3SPierre Pronchery /* Destruct a method */ 46*b077aed3SPierre Pronchery void (*destruct)(void *method, void *data); 47*b077aed3SPierre Pronchery } OSSL_METHOD_CONSTRUCT_METHOD; 48*b077aed3SPierre Pronchery 49*b077aed3SPierre Pronchery void *ossl_method_construct(OSSL_LIB_CTX *ctx, int operation_id, 50*b077aed3SPierre Pronchery OSSL_PROVIDER **provider_rw, int force_cache, 51*b077aed3SPierre Pronchery OSSL_METHOD_CONSTRUCT_METHOD *mcm, void *mcm_data); 52*b077aed3SPierre Pronchery 53*b077aed3SPierre Pronchery void ossl_algorithm_do_all(OSSL_LIB_CTX *libctx, int operation_id, 54*b077aed3SPierre Pronchery OSSL_PROVIDER *provider, 55*b077aed3SPierre Pronchery int (*pre)(OSSL_PROVIDER *, int operation_id, 56*b077aed3SPierre Pronchery int no_store, void *data, int *result), 57*b077aed3SPierre Pronchery int (*reserve_store)(int no_store, void *data), 58*b077aed3SPierre Pronchery void (*fn)(OSSL_PROVIDER *provider, 59*b077aed3SPierre Pronchery const OSSL_ALGORITHM *algo, 60*b077aed3SPierre Pronchery int no_store, void *data), 61*b077aed3SPierre Pronchery int (*unreserve_store)(void *data), 62*b077aed3SPierre Pronchery int (*post)(OSSL_PROVIDER *, int operation_id, 63*b077aed3SPierre Pronchery int no_store, void *data, int *result), 64*b077aed3SPierre Pronchery void *data); 65*b077aed3SPierre Pronchery char *ossl_algorithm_get1_first_name(const OSSL_ALGORITHM *algo); 66*b077aed3SPierre Pronchery 67*b077aed3SPierre Pronchery __owur int ossl_lib_ctx_write_lock(OSSL_LIB_CTX *ctx); 68*b077aed3SPierre Pronchery __owur int ossl_lib_ctx_read_lock(OSSL_LIB_CTX *ctx); 69*b077aed3SPierre Pronchery int ossl_lib_ctx_unlock(OSSL_LIB_CTX *ctx); 70*b077aed3SPierre Pronchery int ossl_lib_ctx_is_child(OSSL_LIB_CTX *ctx); 71*b077aed3SPierre Pronchery #endif 72