1 1.1 christos /* 2 1.1 christos * Copyright 2020 The OpenSSL Project Authors. All Rights Reserved. 3 1.1 christos * 4 1.1 christos * Licensed under the Apache License 2.0 (the "License"). You may not use 5 1.1 christos * this file except in compliance with the License. You can obtain a copy 6 1.1 christos * in the file LICENSE in the source distribution or at 7 1.1 christos * https://www.openssl.org/source/license.html 8 1.1 christos */ 9 1.1 christos 10 1.1 christos #include <stdlib.h> 11 1.1 christos #include "prov/provider_ctx.h" 12 1.1 christos #include "prov/bio.h" 13 1.1 christos 14 1.1 christos PROV_CTX *ossl_prov_ctx_new(void) 15 1.1 christos { 16 1.1 christos return OPENSSL_zalloc(sizeof(PROV_CTX)); 17 1.1 christos } 18 1.1 christos 19 1.1 christos void ossl_prov_ctx_free(PROV_CTX *ctx) 20 1.1 christos { 21 1.1 christos OPENSSL_free(ctx); 22 1.1 christos } 23 1.1 christos 24 1.1 christos void ossl_prov_ctx_set0_libctx(PROV_CTX *ctx, OSSL_LIB_CTX *libctx) 25 1.1 christos { 26 1.1 christos if (ctx != NULL) 27 1.1 christos ctx->libctx = libctx; 28 1.1 christos } 29 1.1 christos 30 1.1 christos void ossl_prov_ctx_set0_handle(PROV_CTX *ctx, const OSSL_CORE_HANDLE *handle) 31 1.1 christos { 32 1.1 christos if (ctx != NULL) 33 1.1 christos ctx->handle = handle; 34 1.1 christos } 35 1.1 christos 36 1.1 christos void ossl_prov_ctx_set0_core_bio_method(PROV_CTX *ctx, BIO_METHOD *corebiometh) 37 1.1 christos { 38 1.1 christos if (ctx != NULL) 39 1.1 christos ctx->corebiometh = corebiometh; 40 1.1 christos } 41 1.1 christos 42 1.1 christos OSSL_LIB_CTX *ossl_prov_ctx_get0_libctx(PROV_CTX *ctx) 43 1.1 christos { 44 1.1 christos if (ctx == NULL) 45 1.1 christos return NULL; 46 1.1 christos return ctx->libctx; 47 1.1 christos } 48 1.1 christos 49 1.1 christos const OSSL_CORE_HANDLE *ossl_prov_ctx_get0_handle(PROV_CTX *ctx) 50 1.1 christos { 51 1.1 christos if (ctx == NULL) 52 1.1 christos return NULL; 53 1.1 christos return ctx->handle; 54 1.1 christos } 55 1.1 christos 56 1.1 christos BIO_METHOD *ossl_prov_ctx_get0_core_bio_method(PROV_CTX *ctx) 57 1.1 christos { 58 1.1 christos if (ctx == NULL) 59 1.1 christos return NULL; 60 1.1 christos return ctx->corebiometh; 61 1.1 christos } 62