From 33561e0d5b89a06d1c03b952196d008b5014914a Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Thu, 30 Sep 2021 17:40:16 +0200 Subject: [PATCH] EVP: Add evp_keymgmt_fetch_from_prov() This is an internal function to fetch a keymgmt method from a specific provider. Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/16725) --- crypto/evp/evp_local.h | 3 +++ crypto/evp/keymgmt_meth.c | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/crypto/evp/evp_local.h b/crypto/evp/evp_local.h index 58c5759120..345bd173c1 100644 --- a/crypto/evp/evp_local.h +++ b/crypto/evp/evp_local.h @@ -298,6 +298,9 @@ void evp_generic_do_all(OSSL_LIB_CTX *libctx, int operation_id, /* Internal fetchers for method types that are to be combined with others */ EVP_KEYMGMT *evp_keymgmt_fetch_by_number(OSSL_LIB_CTX *ctx, int name_id, const char *properties); +EVP_KEYMGMT *evp_keymgmt_fetch_from_prov(OSSL_PROVIDER *prov, + const char *name, + const char *properties); /* Internal structure constructors for fetched methods */ EVP_MD *evp_md_new(void); diff --git a/crypto/evp/keymgmt_meth.c b/crypto/evp/keymgmt_meth.c index 47a0350cc2..fb999c7fd0 100644 --- a/crypto/evp/keymgmt_meth.c +++ b/crypto/evp/keymgmt_meth.c @@ -213,6 +213,17 @@ EVP_KEYMGMT *evp_keymgmt_fetch_by_number(OSSL_LIB_CTX *ctx, int name_id, (void (*)(void *))EVP_KEYMGMT_free); } +EVP_KEYMGMT *evp_keymgmt_fetch_from_prov(OSSL_PROVIDER *prov, + const char *name, + const char *properties) +{ + return evp_generic_fetch_from_prov(prov, OSSL_OP_KEYMGMT, + name, properties, + keymgmt_from_algorithm, + (int (*)(void *))EVP_KEYMGMT_up_ref, + (void (*)(void *))EVP_KEYMGMT_free); +} + EVP_KEYMGMT *EVP_KEYMGMT_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, const char *properties) { -- GitLab