fc2df2ee676299a52c9c9a1d040c7c8d64b03771
[oweals/openssl.git] / providers / common / include / prov / provider_ctx.h
1 /*
2  * Copyright 2019-2020 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 #include <openssl/types.h>
11 #include <openssl/crypto.h>
12
13 typedef struct prov_ctx_st {
14     const OSSL_PROVIDER *provider;
15     OPENSSL_CTX *libctx;         /* For all provider modules */
16 } PROV_CTX;
17
18 /*
19  * To be used anywhere the library context needs to be passed, such as to
20  * fetching functions.
21  */
22 #define PROV_LIBRARY_CONTEXT_OF(provctx)        \
23     PROV_CTX_get0_library_context((provctx))
24
25 PROV_CTX *PROV_CTX_new(void);
26 void PROV_CTX_free(PROV_CTX *ctx);
27 void PROV_CTX_set0_library_context(PROV_CTX *ctx, OPENSSL_CTX *libctx);
28 void PROV_CTX_set0_provider(PROV_CTX *ctx, const OSSL_PROVIDER *libctx);
29 OPENSSL_CTX *PROV_CTX_get0_library_context(PROV_CTX *ctx);
30 const OSSL_PROVIDER *PROV_CTX_get0_provider(PROV_CTX *ctx);