summaryrefslogtreecommitdiffstats
path: root/crypto/core_algorithm.c
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2021-04-16 16:22:03 +0200
committerTomas Mraz <tomas@openssl.org>2021-04-26 12:05:05 +0200
commit6c9bc258d2e9e7b500236a1c696da1f384f0b907 (patch)
tree28928eb5dc1acc246c1b3309328aea2031056ce3 /crypto/core_algorithm.c
parentd21224f1adcd948699e536eaf570f42ef9a051f7 (diff)
Add type_name member to provided methods and use it
Fixes #14701 Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14898)
Diffstat (limited to 'crypto/core_algorithm.c')
-rw-r--r--crypto/core_algorithm.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/crypto/core_algorithm.c b/crypto/core_algorithm.c
index 3fcb2226c7..50344fbe2d 100644
--- a/crypto/core_algorithm.c
+++ b/crypto/core_algorithm.c
@@ -111,3 +111,24 @@ void ossl_algorithm_do_all(OSSL_LIB_CTX *libctx, int operation_id,
else
algorithm_do_this(provider, &cbdata);
}
+
+char *ossl_algorithm_get1_first_name(const OSSL_ALGORITHM *algo)
+{
+ const char *first_name_end = NULL;
+ size_t first_name_len = 0;
+ char *ret;
+
+ if (algo->algorithm_names == NULL)
+ return NULL;
+
+ first_name_end = strchr(algo->algorithm_names, ':');
+ if (first_name_end == NULL)
+ first_name_len = strlen(algo->algorithm_names);
+ else
+ first_name_len = first_name_end - algo->algorithm_names;
+
+ ret = OPENSSL_strndup(algo->algorithm_names, first_name_len);
+ if (ret == NULL)
+ ERR_raise(ERR_LIB_EVP, ERR_R_MALLOC_FAILURE);
+ return ret;
+}