102 lines
3.5 KiB
Diff
102 lines
3.5 KiB
Diff
From 7c975126c71002a87ec91e5e58e84e7009ecd69b Mon Sep 17 00:00:00 2001
|
|
From: Weili Qian <qianweili@huawei.com>
|
|
Date: Thu, 19 Dec 2024 15:57:54 +0800
|
|
Subject: [PATCH 03/10] uadk_provider: add query_operation_name callback for
|
|
keymgmt
|
|
|
|
The key generation process may query the name of the algorithm
|
|
supported by operation_id. If callback is not implemented, task will fail.
|
|
|
|
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
|
Signed-off-by: JiangShui Yang <yangjiangshui@h-partners.com>
|
|
---
|
|
src/uadk_prov_dh.c | 8 ++++++++
|
|
src/uadk_prov_pkey.h | 3 +++
|
|
src/uadk_prov_rsa.c | 8 ++++++++
|
|
src/uadk_prov_sm2.c | 10 ++++++++++
|
|
4 files changed, 29 insertions(+)
|
|
|
|
diff --git a/src/uadk_prov_dh.c b/src/uadk_prov_dh.c
|
|
index e5c956c..8d2c6f6 100644
|
|
--- a/src/uadk_prov_dh.c
|
|
+++ b/src/uadk_prov_dh.c
|
|
@@ -190,6 +190,14 @@ typedef struct {
|
|
char *kdf_cekalg;
|
|
} PROV_DH_KEYEXCH_CTX;
|
|
|
|
+static const char *uadk_keymgmt_dh_query_operation_name(int operation_id)
|
|
+{
|
|
+ if (get_default_dh_keymgmt().query_operation_name == NULL)
|
|
+ return NULL;
|
|
+
|
|
+ return get_default_dh_keymgmt().query_operation_name(operation_id);
|
|
+}
|
|
+
|
|
static void *uadk_keymgmt_dh_new(void *provctx)
|
|
{
|
|
if (get_default_dh_keymgmt().new_fun == NULL)
|
|
diff --git a/src/uadk_prov_pkey.h b/src/uadk_prov_pkey.h
|
|
index 3eb9667..c9ddba1 100644
|
|
--- a/src/uadk_prov_pkey.h
|
|
+++ b/src/uadk_prov_pkey.h
|
|
@@ -168,6 +168,7 @@ static OSSL_FUNC_keymgmt_import_types_fn uadk_keymgmt_##nm##_import_types; \
|
|
static OSSL_FUNC_keymgmt_export_fn uadk_keymgmt_##nm##_export; \
|
|
static OSSL_FUNC_keymgmt_export_types_fn uadk_keymgmt_##nm##_export_types; \
|
|
static OSSL_FUNC_keymgmt_dup_fn uadk_keymgmt_##nm##_dup; \
|
|
+static OSSL_FUNC_keymgmt_query_operation_name_fn uadk_keymgmt_##nm##_query_operation_name; \
|
|
static UADK_PKEY_KEYMGMT get_default_##nm##_keymgmt(void) \
|
|
{ \
|
|
static UADK_PKEY_KEYMGMT s_keymgmt; \
|
|
@@ -215,6 +216,8 @@ const OSSL_DISPATCH uadk_##nm##_keymgmt_functions[] = { \
|
|
{ OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))uadk_keymgmt_##nm##_export }, \
|
|
{ OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))uadk_keymgmt_##nm##_export_types }, \
|
|
{ OSSL_FUNC_KEYMGMT_DUP, (void (*)(void))uadk_keymgmt_##nm##_dup }, \
|
|
+ { OSSL_FUNC_KEYMGMT_QUERY_OPERATION_NAME, \
|
|
+ (void (*)(void))uadk_keymgmt_##nm##_query_operation_name }, \
|
|
{ 0, NULL } \
|
|
} \
|
|
|
|
diff --git a/src/uadk_prov_rsa.c b/src/uadk_prov_rsa.c
|
|
index 9872b27..d1ec153 100644
|
|
--- a/src/uadk_prov_rsa.c
|
|
+++ b/src/uadk_prov_rsa.c
|
|
@@ -2476,6 +2476,14 @@ static const OSSL_PARAM *uadk_asym_cipher_rsa_settable_ctx_params(void *vprsactx
|
|
return get_default_rsa_asym_cipher().settable_ctx_params(vprsactx, provctx);
|
|
}
|
|
|
|
+static const char *uadk_keymgmt_rsa_query_operation_name(int operation_id)
|
|
+{
|
|
+ if (!get_default_rsa_keymgmt().query_operation_name)
|
|
+ return NULL;
|
|
+
|
|
+ return get_default_rsa_keymgmt().query_operation_name(operation_id);
|
|
+}
|
|
+
|
|
static void *uadk_keymgmt_rsa_new(void *provctx)
|
|
{
|
|
if (!get_default_rsa_keymgmt().new_fun)
|
|
diff --git a/src/uadk_prov_sm2.c b/src/uadk_prov_sm2.c
|
|
index e27cccb..df753bd 100644
|
|
--- a/src/uadk_prov_sm2.c
|
|
+++ b/src/uadk_prov_sm2.c
|
|
@@ -191,6 +191,16 @@ ASN1_SEQUENCE(SM2_Ciphertext) = {
|
|
|
|
IMPLEMENT_ASN1_FUNCTIONS(SM2_Ciphertext)
|
|
|
|
+static const char *uadk_keymgmt_sm2_query_operation_name(int operation_id)
|
|
+{
|
|
+ if (!get_default_sm2_keymgmt().query_operation_name) {
|
|
+ fprintf(stderr, "failed to get keymgmt query_operation_name function\n");
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
+ return get_default_sm2_keymgmt().query_operation_name(operation_id);
|
|
+}
|
|
+
|
|
/**
|
|
* Create an uadk provider side sm2 key object.
|
|
*
|
|
--
|
|
2.25.1
|
|
|