summaryrefslogtreecommitdiffstats
path: root/crypto/evp/keymgmt_meth.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2019-07-10 22:22:16 +0200
committerRichard Levitte <levitte@openssl.org>2019-07-23 06:34:09 +0200
commit6b9e37246d5fd8e701b825c71fa1a018916af33c (patch)
treefc451bc5eeab4d6b1eb569c31fd912e7f20d083a /crypto/evp/keymgmt_meth.c
parentda2addc515d547b0d724a4fc730c4345ed713221 (diff)
Add a mechnism to save the name of fetched methods
This will be useful for information display, as well as for code that want to check the name of an algorithm. This can eventually replace all NID checks. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/9356)
Diffstat (limited to 'crypto/evp/keymgmt_meth.c')
-rw-r--r--crypto/evp/keymgmt_meth.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/crypto/evp/keymgmt_meth.c b/crypto/evp/keymgmt_meth.c
index 9723820203..67c33eb78b 100644
--- a/crypto/evp/keymgmt_meth.c
+++ b/crypto/evp/keymgmt_meth.c
@@ -24,6 +24,7 @@ static void *keymgmt_new(void)
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;
}
@@ -32,13 +33,16 @@ static void *keymgmt_new(void)
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) {
@@ -178,6 +182,7 @@ void EVP_KEYMGMT_free(EVP_KEYMGMT *keymgmt)
if (ref > 0)
return;
ossl_provider_free(keymgmt->prov);
+ OPENSSL_free(keymgmt->name);
CRYPTO_THREAD_lock_free(keymgmt->lock);
OPENSSL_free(keymgmt);
}