diff options
author | Richard Levitte <levitte@openssl.org> | 2021-09-30 09:32:57 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2021-10-27 12:41:10 +0200 |
commit | cfce50f791511c8fee7dec90c57f02d9410d039f (patch) | |
tree | d257942e05382ba861d046068ebf70bb268a3bbd /crypto/core_algorithm.c | |
parent | 8c590a219fe30b97cfde2efdd8ea94c03a90a8c6 (diff) | |
download | openssl-new-cfce50f791511c8fee7dec90c57f02d9410d039f.tar.gz |
CORE: add a provider argument to ossl_method_construct()
This makes it possible to limit the search of methods to that
particular provider. This uses already available possibilities in
ossl_algorithm_do_all().
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16725)
Diffstat (limited to 'crypto/core_algorithm.c')
-rw-r--r-- | crypto/core_algorithm.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/crypto/core_algorithm.c b/crypto/core_algorithm.c index 1a2e798c2c..5ff33eff7c 100644 --- a/crypto/core_algorithm.c +++ b/crypto/core_algorithm.c @@ -105,10 +105,23 @@ void ossl_algorithm_do_all(OSSL_LIB_CTX *libctx, int operation_id, cbdata.post = post; cbdata.data = data; - if (provider == NULL) + if (provider == NULL) { ossl_provider_doall_activated(libctx, algorithm_do_this, &cbdata); - else + } else { + OSSL_LIB_CTX *libctx2 = ossl_provider_libctx(provider); + + /* + * If a provider is given, its library context MUST match the library + * context we're passed. If this turns out not to be true, there is + * a programming error in the functions up the call stack. + */ + if (!ossl_assert(ossl_lib_ctx_get_concrete(libctx) + == ossl_lib_ctx_get_concrete(libctx2))) + return; + + cbdata.libctx = libctx2; algorithm_do_this(provider, &cbdata); + } } char *ossl_algorithm_get1_first_name(const OSSL_ALGORITHM *algo) |