1*b077aed3SPierre Pronchery /* 2*b077aed3SPierre Pronchery * Copyright 1995-2021 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 #include "app_libctx.h" 10*b077aed3SPierre Pronchery #include "apps.h" 11*b077aed3SPierre Pronchery 12*b077aed3SPierre Pronchery static OSSL_LIB_CTX *app_libctx = NULL; 13*b077aed3SPierre Pronchery static const char *app_propq = NULL; 14*b077aed3SPierre Pronchery app_set_propq(const char * arg)15*b077aed3SPierre Proncheryint app_set_propq(const char *arg) 16*b077aed3SPierre Pronchery { 17*b077aed3SPierre Pronchery app_propq = arg; 18*b077aed3SPierre Pronchery return 1; 19*b077aed3SPierre Pronchery } 20*b077aed3SPierre Pronchery app_get0_propq(void)21*b077aed3SPierre Proncheryconst char *app_get0_propq(void) 22*b077aed3SPierre Pronchery { 23*b077aed3SPierre Pronchery return app_propq; 24*b077aed3SPierre Pronchery } 25*b077aed3SPierre Pronchery app_get0_libctx(void)26*b077aed3SPierre ProncheryOSSL_LIB_CTX *app_get0_libctx(void) 27*b077aed3SPierre Pronchery { 28*b077aed3SPierre Pronchery return app_libctx; 29*b077aed3SPierre Pronchery } 30*b077aed3SPierre Pronchery app_create_libctx(void)31*b077aed3SPierre ProncheryOSSL_LIB_CTX *app_create_libctx(void) 32*b077aed3SPierre Pronchery { 33*b077aed3SPierre Pronchery /* 34*b077aed3SPierre Pronchery * Load the NULL provider into the default library context and create a 35*b077aed3SPierre Pronchery * library context which will then be used for any OPT_PROV options. 36*b077aed3SPierre Pronchery */ 37*b077aed3SPierre Pronchery if (app_libctx == NULL) { 38*b077aed3SPierre Pronchery if (!app_provider_load(NULL, "null")) { 39*b077aed3SPierre Pronchery opt_printf_stderr( "Failed to create null provider\n"); 40*b077aed3SPierre Pronchery return NULL; 41*b077aed3SPierre Pronchery } 42*b077aed3SPierre Pronchery app_libctx = OSSL_LIB_CTX_new(); 43*b077aed3SPierre Pronchery } 44*b077aed3SPierre Pronchery if (app_libctx == NULL) 45*b077aed3SPierre Pronchery opt_printf_stderr("Failed to create library context\n"); 46*b077aed3SPierre Pronchery return app_libctx; 47*b077aed3SPierre Pronchery } 48*b077aed3SPierre Pronchery 49