From: Simo Sorce Date: Tue, 28 Jan 2025 18:06:28 +0000 (-0500) Subject: Add skeymgmt helper to fetch from a provider X-Git-Tag: openssl-3.5.0-alpha1~484 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=787a083d4225dce06da0f7447255df2cd83f37af;p=thirdparty%2Fopenssl.git Add skeymgmt helper to fetch from a provider This allows to fetch efficiently directly from the same provider that can handle the EVP_SKEY at hand. Signed-off-by: Simo Sorce Reviewed-by: Tomas Mraz Reviewed-by: Tim Hudson Reviewed-by: Dmitry Belyavskiy (Merged from https://github.com/openssl/openssl/pull/26753) --- diff --git a/crypto/evp/skeymgmt_meth.c b/crypto/evp/skeymgmt_meth.c index 435d96d4058..67d6ea3446a 100644 --- a/crypto/evp/skeymgmt_meth.c +++ b/crypto/evp/skeymgmt_meth.c @@ -122,6 +122,18 @@ static void *skeymgmt_from_algorithm(int name_id, return skeymgmt; } +EVP_SKEYMGMT *evp_skeymgmt_fetch_from_prov(OSSL_PROVIDER *prov, + const char *name, + const char *properties) +{ + return evp_generic_fetch_from_prov(prov, + OSSL_OP_SKEYMGMT, + name, properties, + skeymgmt_from_algorithm, + (int (*)(void *))EVP_SKEYMGMT_up_ref, + (void (*)(void *))EVP_SKEYMGMT_free); +} + EVP_SKEYMGMT *EVP_SKEYMGMT_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, const char *properties) { diff --git a/include/crypto/evp.h b/include/crypto/evp.h index db83aab40b2..443fc66852a 100644 --- a/include/crypto/evp.h +++ b/include/crypto/evp.h @@ -873,6 +873,10 @@ void *evp_skeymgmt_import(const EVP_SKEYMGMT *skeymgmt, int selection, const OSS int evp_skeymgmt_export(const EVP_SKEYMGMT *skeymgmt, void *keydata, int selection, OSSL_CALLBACK *param_cb, void *cbarg); void *evp_skeymgmt_generate(const EVP_SKEYMGMT *skeymgmt, const OSSL_PARAM params[]); +EVP_SKEYMGMT *evp_skeymgmt_fetch_from_prov(OSSL_PROVIDER *prov, + const char *name, + const char *properties); + /* Pulling defines out of C source files */ # define EVP_RC4_KEY_SIZE 16