]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Add skeymgmt helper to fetch from a provider
authorSimo Sorce <simo@redhat.com>
Tue, 28 Jan 2025 18:06:28 +0000 (13:06 -0500)
committerDmitry Belyavskiy <beldmit@gmail.com>
Sat, 15 Feb 2025 17:51:30 +0000 (18:51 +0100)
This allows to fetch efficiently directly from the same provider that can
handle the EVP_SKEY at hand.

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/26753)

crypto/evp/skeymgmt_meth.c
include/crypto/evp.h

index 435d96d4058e1a23966f5095d78cdc3fc109690b..67d6ea3446a1addb42b1d57ddd93cb43e3220030 100644 (file)
@@ -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)
 {
index db83aab40b2719209cb9f658ec7a655c48b58d77..443fc66852ac81e0ed4257b4470abb473ef7611d 100644 (file)
@@ -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