summaryrefslogtreecommitdiffstats
path: root/crypto/core_fetch.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2021-10-04 15:33:37 +0200
committerRichard Levitte <levitte@openssl.org>2021-10-27 12:46:16 +0200
commit6e87830ebcbab6b03970da6a4f1070adb938a5ec (patch)
tree3229ee62d8ad969a623ab2d98b8c8c89508f8f30 /crypto/core_fetch.c
parent29a007870ed639fb6ba7547095d53f241a3ee7fd (diff)
CORE: Encure that cached fetches can be done per provider
This mostly entails passing around a provider pointer, and handling queries that includes a pointer to a provider, where NULL means "any". This also means that there's a need to pass the provider pointer, not just down to the cache functions, but also be able to get it from ossl_method_store_fetch(). To this end, that function's OSSL_PROVIDER pointer argument is modified to be a pointer reference, so the function can answer back what provider the method comes from. Test added. Fixes #16614 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16725) (cherry picked from commit dc010ca6ec01d313a84c3c4b040232655a1772ad)
Diffstat (limited to 'crypto/core_fetch.c')
-rw-r--r--crypto/core_fetch.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/crypto/core_fetch.c b/crypto/core_fetch.c
index 26eeaba3b7..367f6ba8a4 100644
--- a/crypto/core_fetch.c
+++ b/crypto/core_fetch.c
@@ -105,12 +105,14 @@ static void ossl_method_construct_this(OSSL_PROVIDER *provider,
}
void *ossl_method_construct(OSSL_LIB_CTX *libctx, int operation_id,
- OSSL_PROVIDER *provider, int force_store,
+ OSSL_PROVIDER **provider_rw, int force_store,
OSSL_METHOD_CONSTRUCT_METHOD *mcm, void *mcm_data)
{
void *method = NULL;
- if ((method = mcm->get(NULL, mcm_data)) == NULL) {
+ if ((method = mcm->get(NULL, (const OSSL_PROVIDER **)provider_rw,
+ mcm_data)) == NULL) {
+ OSSL_PROVIDER *provider = provider_rw != NULL ? *provider_rw : NULL;
struct construct_data_st cbdata;
cbdata.store = NULL;
@@ -125,11 +127,12 @@ void *ossl_method_construct(OSSL_LIB_CTX *libctx, int operation_id,
/* If there is a temporary store, try there first */
if (cbdata.store != NULL)
- method = mcm->get(cbdata.store, mcm_data);
+ method = mcm->get(cbdata.store, (const OSSL_PROVIDER **)provider_rw,
+ mcm_data);
/* If no method was found yet, try the global store */
if (method == NULL)
- method = mcm->get(NULL, mcm_data);
+ method = mcm->get(NULL, (const OSSL_PROVIDER **)provider_rw, mcm_data);
}
return method;