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)
}
void *ossl_method_construct(OSSL_LIB_CTX *libctx, int operation_id,
- int force_store,
+ OSSL_PROVIDER *provider, int force_store,
OSSL_METHOD_CONSTRUCT_METHOD *mcm, void *mcm_data)
{
void *method = NULL;
cbdata.force_store = force_store;
cbdata.mcm = mcm;
cbdata.mcm_data = mcm_data;
- ossl_algorithm_do_all(libctx, operation_id, NULL,
+ ossl_algorithm_do_all(libctx, operation_id, provider,
ossl_method_construct_precondition,
ossl_method_construct_this,
ossl_method_construct_postcondition,
methdata->propquery = properties;
methdata->flag_construct_error_occurred = 0;
if ((method = ossl_method_construct(methdata->libctx, OSSL_OP_DECODER,
- 0 /* !force_cache */,
+ NULL, 0 /* !force_cache */,
&mcm, methdata)) != NULL) {
/*
* If construction did create a method for us, we know that
methdata->propquery = properties;
methdata->flag_construct_error_occurred = 0;
if ((method = ossl_method_construct(methdata->libctx, OSSL_OP_ENCODER,
- 0 /* !force_cache */,
+ NULL, 0 /* !force_cache */,
&mcm, methdata)) != NULL) {
/*
* If construction did create a method for us, we know that
}
static void *
-inner_evp_generic_fetch(struct evp_method_data_st *methdata, int operation_id,
+inner_evp_generic_fetch(struct evp_method_data_st *methdata,
+ OSSL_PROVIDER *prov, int operation_id,
int name_id, const char *name,
const char *properties,
void *(*new_method)(int name_id,
methdata->destruct_method = free_method;
methdata->flag_construct_error_occurred = 0;
if ((method = ossl_method_construct(methdata->libctx, operation_id,
- 0 /* !force_cache */,
+ prov, 0 /* !force_cache */,
&mcm, methdata)) != NULL) {
/*
* If construction did create a method for us, we know that
methdata.libctx = libctx;
methdata.tmp_store = NULL;
- method = inner_evp_generic_fetch(&methdata,
- operation_id, 0, name, properties,
+ method = inner_evp_generic_fetch(&methdata, NULL, operation_id,
+ 0, name, properties,
new_method, up_ref_method, free_method);
dealloc_tmp_evp_method_store(methdata.tmp_store);
return method;
methdata.libctx = libctx;
methdata.tmp_store = NULL;
- method = inner_evp_generic_fetch(&methdata,
- operation_id, name_id, NULL, properties,
+ method = inner_evp_generic_fetch(&methdata, NULL, operation_id,
+ name_id, NULL, properties,
new_method, up_ref_method, free_method);
dealloc_tmp_evp_method_store(methdata.tmp_store);
return method;
methdata.libctx = libctx;
methdata.tmp_store = NULL;
- (void)inner_evp_generic_fetch(&methdata, operation_id, 0, NULL, NULL,
+ (void)inner_evp_generic_fetch(&methdata, NULL, operation_id, 0, NULL, NULL,
new_method, up_ref_method, free_method);
data.operation_id = operation_id;
methdata->propquery = properties;
methdata->flag_construct_error_occurred = 0;
if ((method = ossl_method_construct(methdata->libctx, OSSL_OP_STORE,
- 0 /* !force_cache */,
+ NULL, 0 /* !force_cache */,
&mcm, methdata)) != NULL) {
/*
* If construction did create a method for us, we know that there
typedef struct ossl_method_construct_method OSSL_METHOD_CONSTRUCT_METHOD;
void *ossl_method_construct(OSSL_LIB_CTX *ctx, int operation_id,
- int force_cache,
+ OSSL_PROVIDER *prov, int force_cache,
OSSL_METHOD_CONSTRUCT_METHOD *mcm, void *mcm_data);
calling the appropriate functions given by the subsystem specific
method creator through I<mcm> and the data in I<mcm_data> (which is
passed by ossl_method_construct()).
+If I<prov> is not NULL, only that provider is considered, which is
+useful in the case a method must be found in that particular
+provider.
This function assumes that the subsystem method creator implements
reference counting and acts accordingly (i.e. it will call the
} OSSL_METHOD_CONSTRUCT_METHOD;
void *ossl_method_construct(OSSL_LIB_CTX *ctx, int operation_id,
- int force_cache,
+ OSSL_PROVIDER *prov, int force_cache,
OSSL_METHOD_CONSTRUCT_METHOD *mcm, void *mcm_data);
void ossl_algorithm_do_all(OSSL_LIB_CTX *libctx, int operation_id,