1e1051a39Sopenharmony_ci/* 2e1051a39Sopenharmony_ci * Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved. 3e1051a39Sopenharmony_ci * 4e1051a39Sopenharmony_ci * Licensed under the Apache License 2.0 (the "License"). You may not use 5e1051a39Sopenharmony_ci * this file except in compliance with the License. You can obtain a copy 6e1051a39Sopenharmony_ci * in the file LICENSE in the source distribution or at 7e1051a39Sopenharmony_ci * https://www.openssl.org/source/license.html 8e1051a39Sopenharmony_ci */ 9e1051a39Sopenharmony_ci 10e1051a39Sopenharmony_ci#ifndef OSSL_INTERNAL_CORE_H 11e1051a39Sopenharmony_ci# define OSSL_INTERNAL_CORE_H 12e1051a39Sopenharmony_ci# pragma once 13e1051a39Sopenharmony_ci 14e1051a39Sopenharmony_ci/* 15e1051a39Sopenharmony_ci * namespaces: 16e1051a39Sopenharmony_ci * 17e1051a39Sopenharmony_ci * ossl_method_ Core Method API 18e1051a39Sopenharmony_ci */ 19e1051a39Sopenharmony_ci 20e1051a39Sopenharmony_ci/* 21e1051a39Sopenharmony_ci * construct an arbitrary method from a dispatch table found by looking 22e1051a39Sopenharmony_ci * up a match for the < operation_id, name, property > combination. 23e1051a39Sopenharmony_ci * constructor and destructor are the constructor and destructor for that 24e1051a39Sopenharmony_ci * arbitrary object. 25e1051a39Sopenharmony_ci * 26e1051a39Sopenharmony_ci * These objects are normally cached, unless the provider says not to cache. 27e1051a39Sopenharmony_ci * However, force_cache can be used to force caching whatever the provider 28e1051a39Sopenharmony_ci * says (for example, because the application knows better). 29e1051a39Sopenharmony_ci */ 30e1051a39Sopenharmony_citypedef struct ossl_method_construct_method_st { 31e1051a39Sopenharmony_ci /* Get a temporary store */ 32e1051a39Sopenharmony_ci void *(*get_tmp_store)(void *data); 33e1051a39Sopenharmony_ci /* Reserve the appropriate method store */ 34e1051a39Sopenharmony_ci int (*lock_store)(void *store, void *data); 35e1051a39Sopenharmony_ci /* Unreserve the appropriate method store */ 36e1051a39Sopenharmony_ci int (*unlock_store)(void *store, void *data); 37e1051a39Sopenharmony_ci /* Get an already existing method from a store */ 38e1051a39Sopenharmony_ci void *(*get)(void *store, const OSSL_PROVIDER **prov, void *data); 39e1051a39Sopenharmony_ci /* Store a method in a store */ 40e1051a39Sopenharmony_ci int (*put)(void *store, void *method, const OSSL_PROVIDER *prov, 41e1051a39Sopenharmony_ci const char *name, const char *propdef, void *data); 42e1051a39Sopenharmony_ci /* Construct a new method */ 43e1051a39Sopenharmony_ci void *(*construct)(const OSSL_ALGORITHM *algodef, OSSL_PROVIDER *prov, 44e1051a39Sopenharmony_ci void *data); 45e1051a39Sopenharmony_ci /* Destruct a method */ 46e1051a39Sopenharmony_ci void (*destruct)(void *method, void *data); 47e1051a39Sopenharmony_ci} OSSL_METHOD_CONSTRUCT_METHOD; 48e1051a39Sopenharmony_ci 49e1051a39Sopenharmony_civoid *ossl_method_construct(OSSL_LIB_CTX *ctx, int operation_id, 50e1051a39Sopenharmony_ci OSSL_PROVIDER **provider_rw, int force_cache, 51e1051a39Sopenharmony_ci OSSL_METHOD_CONSTRUCT_METHOD *mcm, void *mcm_data); 52e1051a39Sopenharmony_ci 53e1051a39Sopenharmony_civoid ossl_algorithm_do_all(OSSL_LIB_CTX *libctx, int operation_id, 54e1051a39Sopenharmony_ci OSSL_PROVIDER *provider, 55e1051a39Sopenharmony_ci int (*pre)(OSSL_PROVIDER *, int operation_id, 56e1051a39Sopenharmony_ci int no_store, void *data, int *result), 57e1051a39Sopenharmony_ci int (*reserve_store)(int no_store, void *data), 58e1051a39Sopenharmony_ci void (*fn)(OSSL_PROVIDER *provider, 59e1051a39Sopenharmony_ci const OSSL_ALGORITHM *algo, 60e1051a39Sopenharmony_ci int no_store, void *data), 61e1051a39Sopenharmony_ci int (*unreserve_store)(void *data), 62e1051a39Sopenharmony_ci int (*post)(OSSL_PROVIDER *, int operation_id, 63e1051a39Sopenharmony_ci int no_store, void *data, int *result), 64e1051a39Sopenharmony_ci void *data); 65e1051a39Sopenharmony_cichar *ossl_algorithm_get1_first_name(const OSSL_ALGORITHM *algo); 66e1051a39Sopenharmony_ci 67e1051a39Sopenharmony_ci__owur int ossl_lib_ctx_write_lock(OSSL_LIB_CTX *ctx); 68e1051a39Sopenharmony_ci__owur int ossl_lib_ctx_read_lock(OSSL_LIB_CTX *ctx); 69e1051a39Sopenharmony_ciint ossl_lib_ctx_unlock(OSSL_LIB_CTX *ctx); 70e1051a39Sopenharmony_ciint ossl_lib_ctx_is_child(OSSL_LIB_CTX *ctx); 71e1051a39Sopenharmony_ci#endif 72