if (i > 0)
return;
ossl_provider_free(cipher->prov);
+ OPENSSL_free(cipher->name);
CRYPTO_THREAD_lock_free(cipher->lock);
OPENSSL_free(cipher);
}
return 0;
}
-static void *evp_md_from_dispatch(const OSSL_DISPATCH *fns,
+static void *evp_md_from_dispatch(const char *name, const OSSL_DISPATCH *fns,
OSSL_PROVIDER *prov)
{
EVP_MD *md = NULL;
int fncnt = 0;
/* EVP_MD_fetch() will set the legacy NID if available */
- if ((md = EVP_MD_meth_new(NID_undef, NID_undef)) == NULL)
+ if ((md = EVP_MD_meth_new(NID_undef, NID_undef)) == NULL
+ || (md->name = OPENSSL_strdup(name)) == NULL) {
+ EVP_MD_meth_free(md);
+ EVPerr(0, ERR_R_MALLOC_FAILURE);
return NULL;
+ }
for (; fns->function_id != 0; fns++) {
switch (fns->function_id) {
return 1;
}
-static void *evp_cipher_from_dispatch(const OSSL_DISPATCH *fns,
+static void *evp_cipher_from_dispatch(const char *name,
+ const OSSL_DISPATCH *fns,
OSSL_PROVIDER *prov)
{
EVP_CIPHER *cipher = NULL;
* The legacy NID is set by EVP_CIPHER_fetch() if the name exists in
* the object database.
*/
- if ((cipher = EVP_CIPHER_meth_new(0, 0, 0)) == NULL)
+ if ((cipher = EVP_CIPHER_meth_new(0, 0, 0)) == NULL
+ || (cipher->name = OPENSSL_strdup(name)) == NULL) {
+ EVP_CIPHER_meth_free(cipher);
+ EVPerr(0, ERR_R_MALLOC_FAILURE);
return NULL;
+ }
for (; fns->function_id != 0; fns++) {
switch (fns->function_id) {
OPENSSL_CTX *libctx;
const char *name;
OSSL_METHOD_CONSTRUCT_METHOD *mcm;
- void *(*method_from_dispatch)(const OSSL_DISPATCH *, OSSL_PROVIDER *);
+ void *(*method_from_dispatch)(const char *, const OSSL_DISPATCH *,
+ OSSL_PROVIDER *);
int (*refcnt_up_method)(void *method);
void (*destruct_method)(void *method);
};
{
struct method_data_st *methdata = data;
- return methdata->method_from_dispatch(fns, prov);
+ return methdata->method_from_dispatch(name, fns, prov);
}
static void destruct_method(void *method, void *data)
void *evp_generic_fetch(OPENSSL_CTX *libctx, int operation_id,
const char *name, const char *properties,
- void *(*new_method)(const OSSL_DISPATCH *fns,
+ void *(*new_method)(const char *name,
+ const OSSL_DISPATCH *fns,
OSSL_PROVIDER *prov),
int (*up_ref_method)(void *),
void (*free_method)(void *))
if (i > 0)
return;
ossl_provider_free(md->prov);
+ OPENSSL_free(md->name);
CRYPTO_THREAD_lock_free(md->lock);
OPENSSL_free(md);
}
struct evp_keymgmt_st {
int id; /* libcrypto internal */
- const char *name;
+ char *name;
OSSL_PROVIDER *prov;
CRYPTO_REF_COUNT refcnt;
CRYPTO_RWLOCK *lock;
} /* EVP_KEYMGMT */ ;
struct evp_keyexch_st {
+ char *name;
OSSL_PROVIDER *prov;
CRYPTO_REF_COUNT refcnt;
CRYPTO_RWLOCK *lock;
void *evp_generic_fetch(OPENSSL_CTX *ctx, int operation_id,
const char *algorithm, const char *properties,
- void *(*new_method)(const OSSL_DISPATCH *fns,
+ void *(*new_method)(const char *name,
+ const OSSL_DISPATCH *fns,
OSSL_PROVIDER *prov),
int (*up_ref_method)(void *),
void (*free_method)(void *));
return exchange;
}
-static void *evp_keyexch_from_dispatch(const OSSL_DISPATCH *fns,
+static void *evp_keyexch_from_dispatch(const char *name,
+ const OSSL_DISPATCH *fns,
OSSL_PROVIDER *prov)
{
EVP_KEYEXCH *exchange = NULL;
int fncnt = 0;
- if ((exchange = evp_keyexch_new(prov)) == NULL)
+ if ((exchange = evp_keyexch_new(prov)) == NULL
+ || (exchange->name = OPENSSL_strdup(name)) == NULL) {
+ EVP_KEYEXCH_free(exchange);
+ EVPerr(0, ERR_R_MALLOC_FAILURE);
return NULL;
+ }
for (; fns->function_id != 0; fns++) {
switch (fns->function_id) {
if (i > 0)
return;
ossl_provider_free(exchange->prov);
+ OPENSSL_free(exchange->name);
CRYPTO_THREAD_lock_free(exchange->lock);
OPENSSL_free(exchange);
}
if ((keymgmt = OPENSSL_zalloc(sizeof(*keymgmt))) == NULL
|| (keymgmt->lock = CRYPTO_THREAD_lock_new()) == NULL) {
EVP_KEYMGMT_free(keymgmt);
+ EVPerr(0, ERR_R_MALLOC_FAILURE);
return NULL;
}
return keymgmt;
}
-static void *keymgmt_from_dispatch(const OSSL_DISPATCH *fns,
+static void *keymgmt_from_dispatch(const char *name, const OSSL_DISPATCH *fns,
OSSL_PROVIDER *prov)
{
EVP_KEYMGMT *keymgmt = NULL;
- if ((keymgmt = keymgmt_new()) == NULL)
+ if ((keymgmt = keymgmt_new()) == NULL
+ || (keymgmt->name = OPENSSL_strdup(name)) == NULL) {
+ EVP_KEYMGMT_free(keymgmt);
return NULL;
+ }
for (; fns->function_id != 0; fns++) {
switch (fns->function_id) {
if (ref > 0)
return;
ossl_provider_free(keymgmt->prov);
+ OPENSSL_free(keymgmt->name);
CRYPTO_THREAD_lock_free(keymgmt->lock);
OPENSSL_free(keymgmt);
}
/* New structure members */
/* TODO(3.0): Remove above comment when legacy has gone */
+ char *name;
OSSL_PROVIDER *prov;
CRYPTO_REF_COUNT refcnt;
CRYPTO_RWLOCK *lock;
/* New structure members */
/* TODO(3.0): Remove above comment when legacy has gone */
+ char *name;
OSSL_PROVIDER *prov;
CRYPTO_REF_COUNT refcnt;
CRYPTO_RWLOCK *lock;