1*b077aed3SPierre Pronchery /*
2*b077aed3SPierre Pronchery  * Copyright 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 #include <stdlib.h>
11*b077aed3SPierre Pronchery #include "prov/provider_ctx.h"
12*b077aed3SPierre Pronchery #include "prov/bio.h"
13*b077aed3SPierre Pronchery 
ossl_prov_ctx_new(void)14*b077aed3SPierre Pronchery PROV_CTX *ossl_prov_ctx_new(void)
15*b077aed3SPierre Pronchery {
16*b077aed3SPierre Pronchery     return OPENSSL_zalloc(sizeof(PROV_CTX));
17*b077aed3SPierre Pronchery }
18*b077aed3SPierre Pronchery 
ossl_prov_ctx_free(PROV_CTX * ctx)19*b077aed3SPierre Pronchery void ossl_prov_ctx_free(PROV_CTX *ctx)
20*b077aed3SPierre Pronchery {
21*b077aed3SPierre Pronchery     OPENSSL_free(ctx);
22*b077aed3SPierre Pronchery }
23*b077aed3SPierre Pronchery 
ossl_prov_ctx_set0_libctx(PROV_CTX * ctx,OSSL_LIB_CTX * libctx)24*b077aed3SPierre Pronchery void ossl_prov_ctx_set0_libctx(PROV_CTX *ctx, OSSL_LIB_CTX *libctx)
25*b077aed3SPierre Pronchery {
26*b077aed3SPierre Pronchery     if (ctx != NULL)
27*b077aed3SPierre Pronchery         ctx->libctx = libctx;
28*b077aed3SPierre Pronchery }
29*b077aed3SPierre Pronchery 
ossl_prov_ctx_set0_handle(PROV_CTX * ctx,const OSSL_CORE_HANDLE * handle)30*b077aed3SPierre Pronchery void ossl_prov_ctx_set0_handle(PROV_CTX *ctx, const OSSL_CORE_HANDLE *handle)
31*b077aed3SPierre Pronchery {
32*b077aed3SPierre Pronchery     if (ctx != NULL)
33*b077aed3SPierre Pronchery         ctx->handle = handle;
34*b077aed3SPierre Pronchery }
35*b077aed3SPierre Pronchery 
ossl_prov_ctx_set0_core_bio_method(PROV_CTX * ctx,BIO_METHOD * corebiometh)36*b077aed3SPierre Pronchery void ossl_prov_ctx_set0_core_bio_method(PROV_CTX *ctx, BIO_METHOD *corebiometh)
37*b077aed3SPierre Pronchery {
38*b077aed3SPierre Pronchery     if (ctx != NULL)
39*b077aed3SPierre Pronchery         ctx->corebiometh = corebiometh;
40*b077aed3SPierre Pronchery }
41*b077aed3SPierre Pronchery 
ossl_prov_ctx_get0_libctx(PROV_CTX * ctx)42*b077aed3SPierre Pronchery OSSL_LIB_CTX *ossl_prov_ctx_get0_libctx(PROV_CTX *ctx)
43*b077aed3SPierre Pronchery {
44*b077aed3SPierre Pronchery     if (ctx == NULL)
45*b077aed3SPierre Pronchery         return NULL;
46*b077aed3SPierre Pronchery     return ctx->libctx;
47*b077aed3SPierre Pronchery }
48*b077aed3SPierre Pronchery 
ossl_prov_ctx_get0_handle(PROV_CTX * ctx)49*b077aed3SPierre Pronchery const OSSL_CORE_HANDLE *ossl_prov_ctx_get0_handle(PROV_CTX *ctx)
50*b077aed3SPierre Pronchery {
51*b077aed3SPierre Pronchery     if (ctx == NULL)
52*b077aed3SPierre Pronchery         return NULL;
53*b077aed3SPierre Pronchery     return ctx->handle;
54*b077aed3SPierre Pronchery }
55*b077aed3SPierre Pronchery 
ossl_prov_ctx_get0_core_bio_method(PROV_CTX * ctx)56*b077aed3SPierre Pronchery BIO_METHOD *ossl_prov_ctx_get0_core_bio_method(PROV_CTX *ctx)
57*b077aed3SPierre Pronchery {
58*b077aed3SPierre Pronchery     if (ctx == NULL)
59*b077aed3SPierre Pronchery         return NULL;
60*b077aed3SPierre Pronchery     return ctx->corebiometh;
61*b077aed3SPierre Pronchery }
62