diff options
author | Pauli <ppzgs1@gmail.com> | 2021-02-18 00:16:26 +0100 |
---|---|---|
committer | Pauli <ppzgs1@gmail.com> | 2021-02-23 14:24:41 +0100 |
commit | 299f5ff3b5f2a5a9b5666e36a6a01fc430de9198 (patch) | |
tree | a522f985b02749c53b628f193c767de3c9fb93f6 /crypto/provider.c | |
parent | test: update tests to use the fake random number generator (diff) | |
download | openssl-299f5ff3b5f2a5a9b5666e36a6a01fc430de9198.tar.xz openssl-299f5ff3b5f2a5a9b5666e36a6a01fc430de9198.zip |
provider: add option to load a provider without disabling the fallbacks.
Add an argument to PROVIDER_try_load() that permits a provider to be
loaded without changing the fallback status. This is useful when an
additional provider needs to be loaded without perturbing any other setup.
E.g. adding mock providers as part of unit testing.
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13652)
Diffstat (limited to 'crypto/provider.c')
-rw-r--r-- | crypto/provider.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/crypto/provider.c b/crypto/provider.c index bd8f75a2c1..90c31f3ac5 100644 --- a/crypto/provider.c +++ b/crypto/provider.c @@ -13,7 +13,8 @@ #include <openssl/core_names.h> #include "internal/provider.h" -OSSL_PROVIDER *OSSL_PROVIDER_try_load(OSSL_LIB_CTX *libctx, const char *name) +OSSL_PROVIDER *OSSL_PROVIDER_try_load(OSSL_LIB_CTX *libctx, const char *name, + int retain_fallbacks) { OSSL_PROVIDER *prov = NULL; @@ -22,7 +23,7 @@ OSSL_PROVIDER *OSSL_PROVIDER_try_load(OSSL_LIB_CTX *libctx, const char *name) && (prov = ossl_provider_new(libctx, name, NULL, 0)) == NULL) return NULL; - if (!ossl_provider_activate(prov)) { + if (!ossl_provider_activate(prov, retain_fallbacks)) { ossl_provider_free(prov); return NULL; } @@ -34,7 +35,7 @@ OSSL_PROVIDER *OSSL_PROVIDER_load(OSSL_LIB_CTX *libctx, const char *name) { /* Any attempt to load a provider disables auto-loading of defaults */ if (ossl_provider_disable_fallback_loading(libctx)) - return OSSL_PROVIDER_try_load(libctx, name); + return OSSL_PROVIDER_try_load(libctx, name, 0); return NULL; } |