xref: /freebsd-src/crypto/openssl/providers/common/include/prov/provider_ctx.h (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1*b077aed3SPierre Pronchery /*
2*b077aed3SPierre Pronchery  * Copyright 2019-2020 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_PROV_PROVIDER_CTX_H
11*b077aed3SPierre Pronchery # define OSSL_PROV_PROVIDER_CTX_H
12*b077aed3SPierre Pronchery 
13*b077aed3SPierre Pronchery # include <openssl/types.h>
14*b077aed3SPierre Pronchery # include <openssl/crypto.h>
15*b077aed3SPierre Pronchery # include <openssl/bio.h>
16*b077aed3SPierre Pronchery # include <openssl/core.h>
17*b077aed3SPierre Pronchery 
18*b077aed3SPierre Pronchery typedef struct prov_ctx_st {
19*b077aed3SPierre Pronchery     const OSSL_CORE_HANDLE *handle;
20*b077aed3SPierre Pronchery     OSSL_LIB_CTX *libctx;         /* For all provider modules */
21*b077aed3SPierre Pronchery     BIO_METHOD *corebiometh;
22*b077aed3SPierre Pronchery } PROV_CTX;
23*b077aed3SPierre Pronchery 
24*b077aed3SPierre Pronchery /*
25*b077aed3SPierre Pronchery  * To be used anywhere the library context needs to be passed, such as to
26*b077aed3SPierre Pronchery  * fetching functions.
27*b077aed3SPierre Pronchery  */
28*b077aed3SPierre Pronchery # define PROV_LIBCTX_OF(provctx)        \
29*b077aed3SPierre Pronchery     ossl_prov_ctx_get0_libctx((provctx))
30*b077aed3SPierre Pronchery 
31*b077aed3SPierre Pronchery PROV_CTX *ossl_prov_ctx_new(void);
32*b077aed3SPierre Pronchery void ossl_prov_ctx_free(PROV_CTX *ctx);
33*b077aed3SPierre Pronchery void ossl_prov_ctx_set0_libctx(PROV_CTX *ctx, OSSL_LIB_CTX *libctx);
34*b077aed3SPierre Pronchery void ossl_prov_ctx_set0_handle(PROV_CTX *ctx, const OSSL_CORE_HANDLE *handle);
35*b077aed3SPierre Pronchery void ossl_prov_ctx_set0_core_bio_method(PROV_CTX *ctx, BIO_METHOD *corebiometh);
36*b077aed3SPierre Pronchery OSSL_LIB_CTX *ossl_prov_ctx_get0_libctx(PROV_CTX *ctx);
37*b077aed3SPierre Pronchery const OSSL_CORE_HANDLE *ossl_prov_ctx_get0_handle(PROV_CTX *ctx);
38*b077aed3SPierre Pronchery BIO_METHOD *ossl_prov_ctx_get0_core_bio_method(PROV_CTX *ctx);
39*b077aed3SPierre Pronchery 
40*b077aed3SPierre Pronchery #endif
41