Add NCONF_get0_libctx()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15466)
This commit is contained in:
Rich Salz 2021-05-25 14:48:41 -04:00 committed by Pauli
parent ff234c6804
commit 6b750b89ee
7 changed files with 20 additions and 5 deletions

View File

@ -20,6 +20,11 @@
static void value_free_hash(const CONF_VALUE *a, LHASH_OF(CONF_VALUE) *conf);
static void value_free_stack_doall(CONF_VALUE *a);
OSSL_LIB_CTX *NCONF_get0_libctx(CONF *conf)
{
return conf->libctx;
}
CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section)
{
CONF_VALUE vv;

View File

@ -46,12 +46,14 @@ static int alg_module_init(CONF_IMODULE *md, const CONF *cnf)
* fips_mode is deprecated and should not be used in new
* configurations.
*/
if (!EVP_default_properties_enable_fips(cnf->libctx, m > 0)) {
if (!EVP_default_properties_enable_fips(NCONF_get0_libctx((CONF *)cnf),
m > 0)) {
ERR_raise(ERR_LIB_EVP, EVP_R_SET_DEFAULT_PROPERTY_FAILURE);
return 0;
}
} else if (strcmp(oval->name, "default_properties") == 0) {
if (!evp_set_default_properties_int(cnf->libctx, oval->value, 0, 0)) {
if (!evp_set_default_properties_int(NCONF_get0_libctx((CONF *)cnf),
oval->value, 0, 0)) {
ERR_raise(ERR_LIB_EVP, EVP_R_SET_DEFAULT_PROPERTY_FAILURE);
return 0;
}

View File

@ -199,7 +199,8 @@ static int provider_conf_init(CONF_IMODULE *md, const CONF *cnf)
for (i = 0; i < sk_CONF_VALUE_num(elist); i++) {
cval = sk_CONF_VALUE_value(elist, i);
if (!provider_conf_load(cnf->libctx, cval->name, cval->value, cnf))
if (!provider_conf_load(NCONF_get0_libctx((CONF *)cnf),
cval->name, cval->value, cnf))
return 0;
}

View File

@ -746,7 +746,7 @@ static int random_conf_init(CONF_IMODULE *md, const CONF *cnf)
{
STACK_OF(CONF_VALUE) *elist;
CONF_VALUE *cval;
RAND_GLOBAL *dgbl = rand_get_global(cnf->libctx);
RAND_GLOBAL *dgbl = rand_get_global(NCONF_get0_libctx((CONF *)cnf));
int i, r = 1;
OSSL_TRACE1(CONF, "Loading random module: section %s\n",

View File

@ -2,7 +2,8 @@
=head1 NAME
NCONF_new_ex, NCONF_new, NCONF_free, NCONF_default, NCONF_load
NCONF_new_ex, NCONF_new, NCONF_free, NCONF_default, NCONF_load,
NCONF_get0_libctx
- functionality to Load and parse configuration files manually
=head1 SYNOPSIS
@ -14,6 +15,7 @@ NCONF_new_ex, NCONF_new, NCONF_free, NCONF_default, NCONF_load
void NCONF_free(CONF *conf);
CONF_METHOD *NCONF_default(void);
int NCONF_load(CONF *conf, const char *file, long *eline);
OSSL_LIB_CTX *NCONF_get0_libctx(CONF *conf);
=head1 DESCRIPTION
@ -32,6 +34,9 @@ the load failed on if they are not NULL.
NCONF_default() gets the default method table for processing a configuration file.
NCONF_get0_libctx() gets the library context associated with the I<conf>
parameter.
=head1 RETURN VALUES
NCONF_load() returns 1 on success or 0 on error.

View File

@ -106,6 +106,7 @@ OSSL_DEPRECATEDIN_1_1_0 void OPENSSL_config(const char *config_name);
*/
CONF *NCONF_new_ex(OSSL_LIB_CTX *libctx, CONF_METHOD *meth);
OSSL_LIB_CTX *NCONF_get0_libctx(CONF *conf);
CONF *NCONF_new(CONF_METHOD *meth);
CONF_METHOD *NCONF_default(void);
#ifndef OPENSSL_NO_DEPRECATED_3_0

View File

@ -5418,3 +5418,4 @@ EVP_MAC_CTX_get_block_size 5545 3_0_0 EXIST::FUNCTION:
BIO_debug_callback_ex 5546 3_0_0 EXIST::FUNCTION:
b2i_PVK_bio_ex 5547 3_0_0 EXIST::FUNCTION:
i2b_PVK_bio_ex 5548 3_0_0 EXIST::FUNCTION:
NCONF_get0_libctx 5547 3_0_0 EXIST::FUNCTION: