diff options
author | Richard Levitte <levitte@openssl.org> | 2020-05-11 11:10:41 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-05-12 11:32:40 +0200 |
commit | 914db66d2337d560b042ac710817c69b89045d52 (patch) | |
tree | cfbe5f51054b357065719d542ab9d71b467a4c71 | |
parent | Fix some misunderstandings in our providers' main modules (diff) | |
download | openssl-914db66d2337d560b042ac710817c69b89045d52.tar.xz openssl-914db66d2337d560b042ac710817c69b89045d52.zip |
CORE: Attach the provider context to the provider late
There are concerns that if |prov->provctx| is populated early,
sensitive information may leak from the provider. Therefore, we use a
temporary variable, and only assign it to |prov->provctx| when the
provider init function has returned successfully.
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11777)
-rw-r--r-- | crypto/provider_core.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/provider_core.c b/crypto/provider_core.c index b100e5a15d..1cbe369754 100644 --- a/crypto/provider_core.c +++ b/crypto/provider_core.c @@ -418,6 +418,7 @@ int OSSL_PROVIDER_set_default_search_path(OPENSSL_CTX *libctx, const char *path) static int provider_activate(OSSL_PROVIDER *prov) { const OSSL_DISPATCH *provider_dispatch = NULL; + void *tmp_provctx = NULL; /* safety measure */ #ifndef OPENSSL_NO_ERR # ifndef FIPS_MODULE OSSL_provider_get_reason_strings_fn *p_get_reason_strings = NULL; @@ -488,7 +489,7 @@ static int provider_activate(OSSL_PROVIDER *prov) /* Call the initialise function for the provider. */ if (prov->init_function == NULL || !prov->init_function(prov, core_dispatch, &provider_dispatch, - &prov->provctx)) { + &tmp_provctx)) { ERR_raise_data(ERR_LIB_CRYPTO, ERR_R_INIT_FAIL, NULL, "name=%s", prov->name); #ifndef FIPS_MODULE @@ -497,6 +498,7 @@ static int provider_activate(OSSL_PROVIDER *prov) #endif return 0; } + prov->provctx = tmp_provctx; for (; provider_dispatch->function_id != 0; provider_dispatch++) { switch (provider_dispatch->function_id) { |