57 lines
1.6 KiB
Diff
57 lines
1.6 KiB
Diff
From c8f3d1d021f028a9ca500d079c4158038e1b22c9 Mon Sep 17 00:00:00 2001
|
|
From: taoqi <taoqi10@huawei.com>
|
|
Date: Tue, 20 Jun 2023 23:05:06 +0800
|
|
Subject: [PATCH 09/10] cipher: fix set key error
|
|
|
|
Initialize the algorithm type again to prevent
|
|
the algorithm type from being changed.
|
|
|
|
Signed-off-by: taoqi <taoqi10@huawei.com>
|
|
---
|
|
src/uadk_cipher.c | 20 +++++++++++++++++++-
|
|
1 file changed, 19 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/uadk_cipher.c b/src/uadk_cipher.c
|
|
index 1905e47..cc13823 100644
|
|
--- a/src/uadk_cipher.c
|
|
+++ b/src/uadk_cipher.c
|
|
@@ -840,8 +840,10 @@ static int do_cipher_async(struct cipher_priv_ctx *priv, struct async_op *op)
|
|
|
|
static void uadk_e_ctx_init(EVP_CIPHER_CTX *ctx, struct cipher_priv_ctx *priv)
|
|
{
|
|
+ __u32 cipher_counts = ARRAY_SIZE(cipher_info_table);
|
|
struct sched_params params = {0};
|
|
- int ret;
|
|
+ int nid, ret;
|
|
+ __u32 i;
|
|
|
|
priv->req.iv_bytes = EVP_CIPHER_CTX_iv_length(ctx);
|
|
priv->req.iv = priv->iv;
|
|
@@ -869,7 +871,23 @@ static void uadk_e_ctx_init(EVP_CIPHER_CTX *ctx, struct cipher_priv_ctx *priv)
|
|
/* Use the default numa parameters */
|
|
params.numa_id = -1;
|
|
priv->setup.sched_param = ¶ms;
|
|
+
|
|
if (!priv->sess) {
|
|
+ nid = EVP_CIPHER_CTX_nid(ctx);
|
|
+
|
|
+ for (i = 0; i < cipher_counts; i++) {
|
|
+ if (nid == cipher_info_table[i].nid) {
|
|
+ cipher_priv_ctx_setup(priv, cipher_info_table[i].alg,
|
|
+ cipher_info_table[i].mode, cipher_info_table[i].out_bytes);
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (i == cipher_counts) {
|
|
+ fprintf(stderr, "failed to setup the private ctx.\n");
|
|
+ return;
|
|
+ }
|
|
+
|
|
priv->sess = wd_cipher_alloc_sess(&priv->setup);
|
|
if (!priv->sess)
|
|
fprintf(stderr, "uadk failed to alloc session!\n");
|
|
--
|
|
2.25.1
|
|
|