const OSSL_ALGORITHM *thismap = map++;
void *method = NULL;
- if ((method = data->mcm->construct(thismap->implementation, provider,
- data->mcm_data)) == NULL)
+ if ((method = data->mcm->construct(thismap->algorithm_name,
+ thismap->implementation, provider,
+ data->mcm_data)) == NULL)
continue;
/*
EVP_MD_meth_free(md);
}
+static int evp_md_nid(void *vmd)
+{
+ EVP_MD *md = vmd;
+
+ return md->type;
+}
+
EVP_MD *EVP_MD_fetch(OPENSSL_CTX *ctx, const char *algorithm,
const char *properties)
{
return evp_generic_fetch(ctx, OSSL_OP_DIGEST, algorithm, properties,
evp_md_from_dispatch, evp_md_upref,
- evp_md_free);
+ evp_md_free, evp_md_nid);
}
OSSL_PROVIDER *);
int (*refcnt_up_method)(void *method);
void (*destruct_method)(void *method);
+ int (*nid_method)(void *method);
};
/*
}
static int put_method_in_store(OPENSSL_CTX *libctx, void *store,
- const char *propdef, void *method,
- void *data)
+ const char *propdef,
+ void *method, void *data)
{
struct method_data_st *methdata = data;
+ int nid = methdata->nid_method(method);
+
+ if (nid == NID_undef)
+ return 0;
if (store == NULL
&& (store = get_default_method_store(libctx)) == NULL)
return 0;
if (methdata->refcnt_up_method(method)
- && ossl_method_store_add(store, methdata->nid, propdef, method,
+ && ossl_method_store_add(store, nid, propdef, method,
methdata->destruct_method))
return 1;
return 0;
}
-static void *construct_method(const OSSL_DISPATCH *fns, OSSL_PROVIDER *prov,
+static void *construct_method(const char *algorithm_name,
+ const OSSL_DISPATCH *fns, OSSL_PROVIDER *prov,
void *data)
{
struct method_data_st *methdata = data;
void *method = NULL;
+ int nid = OBJ_sn2nid(algorithm_name);
- if (methdata->nid == NID_undef) {
+ if (nid == NID_undef) {
/* Create a new NID for that name on the fly */
ASN1_OBJECT tmpobj;
tmpobj.length = 0;
tmpobj.data = NULL;
- methdata->nid = OBJ_add_object(&tmpobj);
+ nid = OBJ_add_object(&tmpobj);
}
- if (methdata->nid == NID_undef)
+ if (nid == NID_undef)
return NULL;
- method = methdata->method_from_dispatch(methdata->nid, fns, prov);
+ method = methdata->method_from_dispatch(nid, fns, prov);
if (method == NULL)
return NULL;
return method;
void *(*new_method)(int nid, const OSSL_DISPATCH *fns,
OSSL_PROVIDER *prov),
int (*upref_method)(void *),
- void (*free_method)(void *))
+ void (*free_method)(void *),
+ int (*nid_method)(void *))
{
int nid = OBJ_sn2nid(algorithm);
void *method = NULL;
mcmdata.destruct_method = free_method;
mcmdata.refcnt_up_method = upref_method;
mcmdata.destruct_method = free_method;
+ mcmdata.nid_method = nid_method;
method = ossl_method_construct(libctx, operation_id, algorithm,
properties, 0 /* !force_cache */,
&mcm, &mcmdata);
void *(*new_method)(int nid, const OSSL_DISPATCH *fns,
OSSL_PROVIDER *prov),
int (*upref_method)(void *),
- void (*free_method)(void *));
+ void (*free_method)(void *),
+ int (*nid_method)(void *));
void *(*new_method)(int nid, const OSSL_DISPATCH *fns,
OSSL_PROVIDER *prov),
int (*upref_method)(void *),
- void (*free_method)(void *));
+ void (*free_method)(void *),
+ int (*nid_method)(void *));
=head1 DESCRIPTION
frees the given method.
+=item nid_method()
+
+returns the nid associated with the given method.
+
=back
=head1 RETURN VALUES
int (*put)(OPENSSL_CTX *libctx, void *store, const char *propdef,
void *method, void *data);
/* Construct a new method */
- void *(*construct)(const OSSL_DISPATCH *fns, OSSL_PROVIDER *prov,
- void *data);
+ void *(*construct)(const char *algorithm_name, const OSSL_DISPATCH *fns,
+ OSSL_PROVIDER *prov, void *data);
/* Destruct a method */
void (*destruct)(void *method);
};
=item construct()
-Constructs a sub-system method given a dispatch table C<fns>.
+Constructs a sub-system method for the given C<algorithm_name> and the given
+dispatch table C<fns>.
The associated I<provider object> C<prov> is passed as well, to make
it possible for the sub-system constructor to keep a reference, which
int (*put)(OPENSSL_CTX *libctx, void *store, const char *propdef,
void *method, void *data);
/* Construct a new method */
- void *(*construct)(const OSSL_DISPATCH *fns, OSSL_PROVIDER *prov,
- void *data);
+ void *(*construct)(const char *algorithm_name, const OSSL_DISPATCH *fns,
+ OSSL_PROVIDER *prov, void *data);
/* Destruct a method */
void (*destruct)(void *method, void *data);
} OSSL_METHOD_CONSTRUCT_METHOD;