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