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