]> git.ipfire.org Git - thirdparty/openssl.git/blame - providers/common/provider_ctx.c
Maintain strict type discipline between the core and providers
[thirdparty/openssl.git] / providers / common / provider_ctx.c
CommitLineData
05aa8790
RL
1/*
2 * Copyright 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 <stdlib.h>
11#include "prov/provider_ctx.h"
d40b42ab 12#include "prov/bio.h"
05aa8790
RL
13
14PROV_CTX *PROV_CTX_new(void)
15{
16 return OPENSSL_zalloc(sizeof(PROV_CTX));
17}
18
19void PROV_CTX_free(PROV_CTX *ctx)
20{
21 OPENSSL_free(ctx);
22}
23
24void PROV_CTX_set0_library_context(PROV_CTX *ctx, OPENSSL_CTX *libctx)
25{
26 if (ctx != NULL)
27 ctx->libctx = libctx;
28}
29
d40b42ab 30void PROV_CTX_set0_handle(PROV_CTX *ctx, const OSSL_CORE_HANDLE *handle)
05aa8790
RL
31{
32 if (ctx != NULL)
d40b42ab 33 ctx->handle = handle;
05aa8790
RL
34}
35
d40b42ab
MC
36void PROV_CTX_set0_core_bio_method(PROV_CTX *ctx, BIO_METHOD *corebiometh)
37{
38 if (ctx != NULL)
39 ctx->corebiometh = corebiometh;
40}
05aa8790
RL
41
42OPENSSL_CTX *PROV_CTX_get0_library_context(PROV_CTX *ctx)
43{
44 if (ctx == NULL)
45 return NULL;
46 return ctx->libctx;
47}
48
d40b42ab
MC
49const OSSL_CORE_HANDLE *PROV_CTX_get0_handle(PROV_CTX *ctx)
50{
51 if (ctx == NULL)
52 return NULL;
53 return ctx->handle;
54}
55
56BIO_METHOD *PROV_CTX_get0_core_bio_method(PROV_CTX *ctx)
05aa8790
RL
57{
58 if (ctx == NULL)
59 return NULL;
d40b42ab 60 return ctx->corebiometh;
05aa8790 61}