Release the drbg in the global default context before engines

Fixes #17995
Fixes #18578

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/19386)
This commit is contained in:
Tomas Mraz 2022-10-11 17:26:23 +02:00
parent bd363ef324
commit a88e97fcac
3 changed files with 11 additions and 0 deletions

View File

@ -472,6 +472,15 @@ OSSL_LIB_CTX *OSSL_LIB_CTX_set0_default(OSSL_LIB_CTX *libctx)
return NULL;
}
void ossl_release_default_drbg_ctx(void)
{
/* early release of the DRBG in global default libctx */
if (default_context_int.drbg != NULL) {
ossl_rand_ctx_free(default_context_int.drbg);
default_context_int.drbg = NULL;
}
}
#endif
OSSL_LIB_CTX *ossl_lib_ctx_get_concrete(OSSL_LIB_CTX *ctx)

View File

@ -97,6 +97,7 @@ void ossl_rand_cleanup_int(void)
CRYPTO_THREAD_lock_free(rand_meth_lock);
rand_meth_lock = NULL;
# endif
ossl_release_default_drbg_ctx();
rand_inited = 0;
}

View File

@ -41,6 +41,7 @@ void ossl_self_test_set_callback_free(void *);
void ossl_rand_crng_ctx_free(void *);
void ossl_thread_event_ctx_free(void *);
void ossl_fips_prov_ossl_ctx_free(void *);
void ossl_release_default_drbg_ctx(void);
#if defined(OPENSSL_THREADS)
void ossl_threads_ctx_free(void *);
#endif