An API function for obtaining the global default lib ctx.
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14890)
+#ifndef FIPS_MODULE
+OSSL_LIB_CTX *OSSL_LIB_CTX_get0_global_default(void)
+{
+ if (!RUN_ONCE(&default_context_init, default_context_do_init))
+ return NULL;
+
+ return &default_context_int;
+}
+
OSSL_LIB_CTX *OSSL_LIB_CTX_set0_default(OSSL_LIB_CTX *libctx)
{
OSSL_LIB_CTX *OSSL_LIB_CTX_set0_default(OSSL_LIB_CTX *libctx)
{
OSSL_LIB_CTX *current_defctx;
if ((current_defctx = get_default_context()) != NULL) {
OSSL_LIB_CTX *current_defctx;
if ((current_defctx = get_default_context()) != NULL) {
set_default_context(libctx);
return current_defctx;
}
set_default_context(libctx);
return current_defctx;
}
OSSL_LIB_CTX *ossl_lib_ctx_get_concrete(OSSL_LIB_CTX *ctx)
{
OSSL_LIB_CTX *ossl_lib_ctx_get_concrete(OSSL_LIB_CTX *ctx)
{
=head1 NAME
OSSL_LIB_CTX, OSSL_LIB_CTX_new, OSSL_LIB_CTX_free, OSSL_LIB_CTX_load_config,
=head1 NAME
OSSL_LIB_CTX, OSSL_LIB_CTX_new, OSSL_LIB_CTX_free, OSSL_LIB_CTX_load_config,
-OSSL_LIB_CTX_set0_default
+OSSL_LIB_CTX_get0_global_default, OSSL_LIB_CTX_set0_default
- OpenSSL library context
=head1 SYNOPSIS
- OpenSSL library context
=head1 SYNOPSIS
OSSL_LIB_CTX *OSSL_LIB_CTX_new(void);
int OSSL_LIB_CTX_load_config(OSSL_LIB_CTX *ctx, const char *config_file);
void OSSL_LIB_CTX_free(OSSL_LIB_CTX *ctx);
OSSL_LIB_CTX *OSSL_LIB_CTX_new(void);
int OSSL_LIB_CTX_load_config(OSSL_LIB_CTX *ctx, const char *config_file);
void OSSL_LIB_CTX_free(OSSL_LIB_CTX *ctx);
+ OSSL_LIB_CTX *OSSL_LIB_CTX_get0_global_default(void);
OSSL_LIB_CTX *OSSL_LIB_CTX_set0_default(OSSL_LIB_CTX *ctx);
=head1 DESCRIPTION
OSSL_LIB_CTX *OSSL_LIB_CTX_set0_default(OSSL_LIB_CTX *ctx);
=head1 DESCRIPTION
OSSL_LIB_CTX_free() frees the given I<ctx>, unless it happens to be the
default OpenSSL library context.
OSSL_LIB_CTX_free() frees the given I<ctx>, unless it happens to be the
default OpenSSL library context.
+OSSL_LIB_CTX_get0_global_default() returns a concrete (non NULL) reference to
+the global default library context.
+
OSSL_LIB_CTX_set0_default() sets the default OpenSSL library context to be
I<ctx> in the current thread. The previous default library context is
returned. Care should be taken by the caller to restore the previous
default library context with a subsequent call of this function. If I<ctx> is
NULL then no change is made to the default library context, but a pointer to
OSSL_LIB_CTX_set0_default() sets the default OpenSSL library context to be
I<ctx> in the current thread. The previous default library context is
returned. Care should be taken by the caller to restore the previous
default library context with a subsequent call of this function. If I<ctx> is
NULL then no change is made to the default library context, but a pointer to
-the current library context is still returned.
+the current library context is still returned. On a successful call of this
+function the returned value will always be a concrete (non NULL) library
+context.
Care should be taken when changing the default library context and starting
async jobs (see L<ASYNC_start_job(3)>), as the default library context when
Care should be taken when changing the default library context and starting
async jobs (see L<ASYNC_start_job(3)>), as the default library context when
-OSSL_LIB_CTX_new() and OSSL_LIB_CTX_set0_default() return a library context
-pointer on success, or NULL on error.
+OSSL_LIB_CTX_new(), OSSL_LIB_CTX_get0_global_default() and
+OSSL_LIB_CTX_set0_default() return a library context pointer on success, or NULL
+on error.
OSSL_LIB_CTX_free() doesn't return any value.
=head1 HISTORY
OSSL_LIB_CTX_free() doesn't return any value.
=head1 HISTORY
-OSSL_LIB_CTX, OSSL_LIB_CTX_new(), OSSL_LIB_CTX_load_config(), OSSL_LIB_CTX_free()
-and OSSL_LIB_CTX_set0_default() were added in OpenSSL 3.0.
+OSSL_LIB_CTX, OSSL_LIB_CTX_new(), OSSL_LIB_CTX_load_config(),
+OSSL_LIB_CTX_free(), OSSL_LIB_CTX_get0_global_default() and
+OSSL_LIB_CTX_set0_default() were added in OpenSSL 3.0.
OSSL_LIB_CTX *OSSL_LIB_CTX_new(void);
int OSSL_LIB_CTX_load_config(OSSL_LIB_CTX *ctx, const char *config_file);
void OSSL_LIB_CTX_free(OSSL_LIB_CTX *);
OSSL_LIB_CTX *OSSL_LIB_CTX_new(void);
int OSSL_LIB_CTX_load_config(OSSL_LIB_CTX *ctx, const char *config_file);
void OSSL_LIB_CTX_free(OSSL_LIB_CTX *);
+OSSL_LIB_CTX *OSSL_LIB_CTX_get0_global_default(void);
OSSL_LIB_CTX *OSSL_LIB_CTX_set0_default(OSSL_LIB_CTX *libctx);
# ifdef __cplusplus
OSSL_LIB_CTX *OSSL_LIB_CTX_set0_default(OSSL_LIB_CTX *libctx);
# ifdef __cplusplus
EVP_MD_CTX_get1_md ? 3_0_0 EXIST::FUNCTION:
EVP_CIPHER_CTX_get0_cipher ? 3_0_0 EXIST::FUNCTION:
EVP_CIPHER_CTX_get1_cipher ? 3_0_0 EXIST::FUNCTION:
EVP_MD_CTX_get1_md ? 3_0_0 EXIST::FUNCTION:
EVP_CIPHER_CTX_get0_cipher ? 3_0_0 EXIST::FUNCTION:
EVP_CIPHER_CTX_get1_cipher ? 3_0_0 EXIST::FUNCTION:
+OSSL_LIB_CTX_get0_global_default ? 3_0_0 EXIST::FUNCTION: