!53 [sync] PR-52: Synchronize pr to NEXT branch
From: @openeuler-sync-bot Reviewed-by: @hao-fang Signed-off-by: @hao-fang
This commit is contained in:
commit
362407a9b8
343
0004-uadk_engine-cleanup-code-style-of-async-functions.patch
Normal file
343
0004-uadk_engine-cleanup-code-style-of-async-functions.patch
Normal file
@ -0,0 +1,343 @@
|
||||
From 54e2cf93c7a362031e7dacf550afe286b5a4656a Mon Sep 17 00:00:00 2001
|
||||
From: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
Date: Fri, 29 Mar 2024 10:13:22 +0800
|
||||
Subject: [PATCH 4/7] uadk_engine: cleanup code style of async functions
|
||||
|
||||
Cleanup the return value and judgment code style
|
||||
of async mode functions.
|
||||
|
||||
Signed-off-by: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
Signed-off-by: JiangShui Yang <yangjiangshui@h-partners.com>
|
||||
---
|
||||
src/uadk_async.c | 126 +++++++++++++++++++++++------------------------
|
||||
src/uadk_async.h | 3 ++
|
||||
2 files changed, 64 insertions(+), 65 deletions(-)
|
||||
|
||||
diff --git a/src/uadk_async.c b/src/uadk_async.c
|
||||
index 726ee09..1558996 100644
|
||||
--- a/src/uadk_async.c
|
||||
+++ b/src/uadk_async.c
|
||||
@@ -50,83 +50,79 @@ static void async_fd_cleanup(ASYNC_WAIT_CTX *ctx, const void *key,
|
||||
int async_setup_async_event_notification(struct async_op *op)
|
||||
{
|
||||
ASYNC_WAIT_CTX *waitctx;
|
||||
+ void *custom = NULL;
|
||||
OSSL_ASYNC_FD efd;
|
||||
- void *custom;
|
||||
|
||||
memset(op, 0, sizeof(struct async_op));
|
||||
op->job = ASYNC_get_current_job();
|
||||
- if (op->job == NULL)
|
||||
- return 1;
|
||||
+ if (!op->job)
|
||||
+ return DO_SYNC;
|
||||
|
||||
waitctx = ASYNC_get_wait_ctx(op->job);
|
||||
- if (waitctx == NULL)
|
||||
- return 0;
|
||||
+ if (!waitctx)
|
||||
+ return UADK_E_FAIL;
|
||||
|
||||
- if (ASYNC_WAIT_CTX_get_fd(waitctx, uadk_async_key,
|
||||
- &efd, &custom) == 0) {
|
||||
+ if (!ASYNC_WAIT_CTX_get_fd(waitctx, uadk_async_key, &efd, &custom)) {
|
||||
efd = eventfd(0, EFD_NONBLOCK);
|
||||
if (efd == -1)
|
||||
- return 0;
|
||||
+ return UADK_E_FAIL;
|
||||
|
||||
- if (ASYNC_WAIT_CTX_set_wait_fd(waitctx, uadk_async_key, efd,
|
||||
- custom, async_fd_cleanup) == 0) {
|
||||
+ if (!ASYNC_WAIT_CTX_set_wait_fd(waitctx, uadk_async_key, efd,
|
||||
+ custom, async_fd_cleanup)) {
|
||||
async_fd_cleanup(waitctx, uadk_async_key, efd, NULL);
|
||||
- return 0;
|
||||
+ return UADK_E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
- return 1;
|
||||
+ return UADK_E_SUCCESS;
|
||||
}
|
||||
|
||||
int async_clear_async_event_notification(void)
|
||||
{
|
||||
- ASYNC_JOB *job;
|
||||
+ size_t num_add_fds, num_del_fds;
|
||||
ASYNC_WAIT_CTX *waitctx;
|
||||
- OSSL_ASYNC_FD efd;
|
||||
- size_t num_add_fds;
|
||||
- size_t num_del_fds;
|
||||
void *custom = NULL;
|
||||
+ OSSL_ASYNC_FD efd;
|
||||
+ ASYNC_JOB *job;
|
||||
|
||||
job = ASYNC_get_current_job();
|
||||
- if (job == NULL)
|
||||
- return 0;
|
||||
+ if (!job)
|
||||
+ return UADK_E_FAIL;
|
||||
|
||||
waitctx = ASYNC_get_wait_ctx(job);
|
||||
- if (waitctx == NULL)
|
||||
- return 0;
|
||||
+ if (!waitctx)
|
||||
+ return UADK_E_FAIL;
|
||||
|
||||
- if (ASYNC_WAIT_CTX_get_changed_fds(waitctx, NULL, &num_add_fds,
|
||||
- NULL, &num_del_fds) == 0)
|
||||
- return 0;
|
||||
+ if (!ASYNC_WAIT_CTX_get_changed_fds(waitctx, NULL, &num_add_fds, NULL, &num_del_fds))
|
||||
+ return UADK_E_FAIL;
|
||||
|
||||
if (num_add_fds > 0) {
|
||||
- if (ASYNC_WAIT_CTX_get_fd(waitctx, uadk_async_key,
|
||||
- &efd, &custom) == 0)
|
||||
- return 0;
|
||||
+ if (!ASYNC_WAIT_CTX_get_fd(waitctx, uadk_async_key, &efd, &custom))
|
||||
+ return UADK_E_FAIL;
|
||||
|
||||
async_fd_cleanup(waitctx, uadk_async_key, efd, NULL);
|
||||
|
||||
- if (ASYNC_WAIT_CTX_clear_fd(waitctx, uadk_async_key) == 0)
|
||||
- return 0;
|
||||
+ if (!ASYNC_WAIT_CTX_clear_fd(waitctx, uadk_async_key))
|
||||
+ return UADK_E_FAIL;
|
||||
}
|
||||
|
||||
- return 1;
|
||||
+ return UADK_E_SUCCESS;
|
||||
}
|
||||
|
||||
void async_poll_task_free(void)
|
||||
{
|
||||
- int error;
|
||||
struct async_poll_task *task;
|
||||
+ int error;
|
||||
|
||||
/* Disable async poll state first */
|
||||
uadk_e_set_async_poll_state(DISABLE_ASYNC_POLLING);
|
||||
|
||||
error = pthread_mutex_lock(&poll_queue.async_task_mutex);
|
||||
- if (error != 0)
|
||||
+ if (error)
|
||||
return;
|
||||
|
||||
task = poll_queue.head;
|
||||
- if (task != NULL)
|
||||
+ if (task)
|
||||
OPENSSL_free(task);
|
||||
|
||||
poll_queue.head = NULL;
|
||||
@@ -146,13 +142,13 @@ static int async_get_poll_task(int *id)
|
||||
while (!poll_queue.status[idx]) {
|
||||
idx = (idx + 1) % ASYNC_QUEUE_TASK_NUM;
|
||||
if (cnt++ == ASYNC_QUEUE_TASK_NUM)
|
||||
- return 0;
|
||||
+ return UADK_E_FAIL;
|
||||
}
|
||||
|
||||
*id = idx;
|
||||
poll_queue.rid = (idx + 1) % ASYNC_QUEUE_TASK_NUM;
|
||||
|
||||
- return 1;
|
||||
+ return UADK_E_SUCCESS;
|
||||
}
|
||||
|
||||
static struct async_poll_task *async_get_queue_task(void)
|
||||
@@ -161,11 +157,11 @@ static struct async_poll_task *async_get_queue_task(void)
|
||||
struct async_poll_task *task_queue;
|
||||
int idx, ret;
|
||||
|
||||
- if (pthread_mutex_lock(&poll_queue.async_task_mutex) != 0)
|
||||
+ if (pthread_mutex_lock(&poll_queue.async_task_mutex))
|
||||
return NULL;
|
||||
|
||||
ret = async_get_poll_task(&idx);
|
||||
- if (!ret)
|
||||
+ if (ret == UADK_E_FAIL)
|
||||
goto err;
|
||||
|
||||
task_queue = poll_queue.head;
|
||||
@@ -173,10 +169,10 @@ static struct async_poll_task *async_get_queue_task(void)
|
||||
poll_queue.is_recv = 0;
|
||||
|
||||
err:
|
||||
- if (pthread_mutex_unlock(&poll_queue.async_task_mutex) != 0)
|
||||
+ if (pthread_mutex_unlock(&poll_queue.async_task_mutex))
|
||||
return NULL;
|
||||
|
||||
- if (cur_task && cur_task->op == NULL)
|
||||
+ if (cur_task && !cur_task->op)
|
||||
return NULL;
|
||||
|
||||
return cur_task;
|
||||
@@ -184,7 +180,7 @@ err:
|
||||
|
||||
void async_free_poll_task(int id, bool is_cb)
|
||||
{
|
||||
- if (pthread_mutex_lock(&poll_queue.async_task_mutex) != 0)
|
||||
+ if (pthread_mutex_lock(&poll_queue.async_task_mutex))
|
||||
return;
|
||||
|
||||
poll_queue.status[id] = 0;
|
||||
@@ -192,7 +188,7 @@ void async_free_poll_task(int id, bool is_cb)
|
||||
if (is_cb)
|
||||
poll_queue.is_recv = 1;
|
||||
|
||||
- if (pthread_mutex_unlock(&poll_queue.async_task_mutex) != 0)
|
||||
+ if (pthread_mutex_unlock(&poll_queue.async_task_mutex))
|
||||
return;
|
||||
|
||||
(void)sem_post(&poll_queue.empty_sem);
|
||||
@@ -205,17 +201,17 @@ int async_get_free_task(int *id)
|
||||
int idx, ret;
|
||||
int cnt = 0;
|
||||
|
||||
- if (sem_wait(&poll_queue.empty_sem) != 0)
|
||||
- return 0;
|
||||
+ if (sem_wait(&poll_queue.empty_sem))
|
||||
+ return UADK_E_FAIL;
|
||||
|
||||
- if (pthread_mutex_lock(&poll_queue.async_task_mutex) != 0)
|
||||
- return 0;
|
||||
+ if (pthread_mutex_lock(&poll_queue.async_task_mutex))
|
||||
+ return UADK_E_FAIL;
|
||||
|
||||
idx = poll_queue.sid;
|
||||
while (poll_queue.status[idx]) {
|
||||
idx = (idx + 1) % ASYNC_QUEUE_TASK_NUM;
|
||||
if (cnt++ == ASYNC_QUEUE_TASK_NUM) {
|
||||
- ret = 0;
|
||||
+ ret = UADK_E_FAIL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@@ -226,11 +222,11 @@ int async_get_free_task(int *id)
|
||||
task_queue = poll_queue.head;
|
||||
task = &task_queue[idx];
|
||||
task->op = NULL;
|
||||
- ret = 1;
|
||||
+ ret = UADK_E_SUCCESS;
|
||||
|
||||
out:
|
||||
- if (pthread_mutex_unlock(&poll_queue.async_task_mutex) != 0)
|
||||
- return 0;
|
||||
+ if (pthread_mutex_unlock(&poll_queue.async_task_mutex))
|
||||
+ return UADK_E_FAIL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -249,9 +245,9 @@ static int async_add_poll_task(void *ctx, struct async_op *op, enum task_type ty
|
||||
|
||||
ret = sem_post(&poll_queue.full_sem);
|
||||
if (ret)
|
||||
- return 0;
|
||||
+ return UADK_E_FAIL;
|
||||
|
||||
- return 1;
|
||||
+ return UADK_E_SUCCESS;
|
||||
}
|
||||
|
||||
int async_pause_job(void *ctx, struct async_op *op, enum task_type type)
|
||||
@@ -263,16 +259,16 @@ int async_pause_job(void *ctx, struct async_op *op, enum task_type type)
|
||||
int ret;
|
||||
|
||||
ret = async_add_poll_task(ctx, op, type);
|
||||
- if (ret == 0)
|
||||
+ if (!ret)
|
||||
return ret;
|
||||
|
||||
waitctx = ASYNC_get_wait_ctx((ASYNC_JOB *)op->job);
|
||||
- if (waitctx == NULL)
|
||||
- return 0;
|
||||
+ if (!waitctx)
|
||||
+ return UADK_E_FAIL;
|
||||
|
||||
do {
|
||||
- if (ASYNC_pause_job() == 0)
|
||||
- return 0;
|
||||
+ if (!ASYNC_pause_job())
|
||||
+ return UADK_E_FAIL;
|
||||
|
||||
ret = ASYNC_WAIT_CTX_get_fd(waitctx, uadk_async_key, &efd, &custom);
|
||||
if (ret <= 0)
|
||||
@@ -293,13 +289,13 @@ int async_wake_job(ASYNC_JOB *job)
|
||||
{
|
||||
ASYNC_WAIT_CTX *waitctx;
|
||||
OSSL_ASYNC_FD efd;
|
||||
- void *custom;
|
||||
uint64_t buf = 1;
|
||||
+ void *custom;
|
||||
int ret;
|
||||
|
||||
waitctx = ASYNC_get_wait_ctx(job);
|
||||
- if (waitctx == NULL)
|
||||
- return 0;
|
||||
+ if (!waitctx)
|
||||
+ return UADK_E_FAIL;
|
||||
|
||||
ret = ASYNC_WAIT_CTX_get_fd(waitctx, uadk_async_key, &efd, &custom);
|
||||
if (ret > 0) {
|
||||
@@ -329,7 +325,7 @@ static void *async_poll_process_func(void *args)
|
||||
int ret, idx;
|
||||
|
||||
while (uadk_e_get_async_poll_state()) {
|
||||
- if (sem_wait(&poll_queue.full_sem) != 0) {
|
||||
+ if (sem_wait(&poll_queue.full_sem)) {
|
||||
if (errno == EINTR) {
|
||||
/* sem_wait is interrupted by interrupt, continue */
|
||||
continue;
|
||||
@@ -337,7 +333,7 @@ static void *async_poll_process_func(void *args)
|
||||
}
|
||||
|
||||
task = async_get_queue_task();
|
||||
- if (task == NULL) {
|
||||
+ if (!task) {
|
||||
(void)sem_post(&poll_queue.full_sem);
|
||||
usleep(1);
|
||||
continue;
|
||||
@@ -364,11 +360,11 @@ int async_module_init(void)
|
||||
memset(&poll_queue, 0, sizeof(struct async_poll_queue));
|
||||
|
||||
if (pthread_mutex_init(&(poll_queue.async_task_mutex), NULL) < 0)
|
||||
- return 0;
|
||||
+ return UADK_E_FAIL;
|
||||
|
||||
poll_queue.head = OPENSSL_malloc(ASYNC_QUEUE_TASK_NUM * sizeof(struct async_poll_task));
|
||||
- if (poll_queue.head == NULL)
|
||||
- return 0;
|
||||
+ if (!poll_queue.head)
|
||||
+ return UADK_E_FAIL;
|
||||
|
||||
if (sem_init(&poll_queue.empty_sem, 0, ASYNC_QUEUE_TASK_NUM) != 0)
|
||||
goto err;
|
||||
@@ -384,9 +380,9 @@ int async_module_init(void)
|
||||
goto err;
|
||||
|
||||
poll_queue.thread_id = thread_id;
|
||||
- return 1;
|
||||
+ return UADK_E_SUCCESS;
|
||||
|
||||
err:
|
||||
async_poll_task_free();
|
||||
- return 0;
|
||||
+ return UADK_E_FAIL;
|
||||
}
|
||||
diff --git a/src/uadk_async.h b/src/uadk_async.h
|
||||
index 6857927..5d73b60 100644
|
||||
--- a/src/uadk_async.h
|
||||
+++ b/src/uadk_async.h
|
||||
@@ -23,6 +23,9 @@
|
||||
#include <openssl/async.h>
|
||||
|
||||
#define ASYNC_QUEUE_TASK_NUM 1024
|
||||
+#define UADK_E_SUCCESS 1
|
||||
+#define UADK_E_FAIL 0
|
||||
+#define DO_SYNC 1
|
||||
|
||||
struct async_op {
|
||||
ASYNC_JOB *job;
|
||||
--
|
||||
2.25.1
|
||||
|
||||
49
0005-cipher-cleanup-repeated-function-invoking.patch
Normal file
49
0005-cipher-cleanup-repeated-function-invoking.patch
Normal file
@ -0,0 +1,49 @@
|
||||
From 1cfb48c6d086fc82ea6b72bd9b8cb3c5cacac2b8 Mon Sep 17 00:00:00 2001
|
||||
From: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
Date: Fri, 29 Mar 2024 10:13:23 +0800
|
||||
Subject: [PATCH 5/7] cipher: cleanup repeated function invoking
|
||||
|
||||
Cleanup repeated function invoking of EVP_CIPHER_CTX_nid().
|
||||
|
||||
Signed-off-by: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
Signed-off-by: JiangShui Yang <yangjiangshui@h-partners.com>
|
||||
---
|
||||
src/uadk_cipher.c | 7 +++----
|
||||
1 file changed, 3 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/uadk_cipher.c b/src/uadk_cipher.c
|
||||
index 7b4ebd8..b506c22 100644
|
||||
--- a/src/uadk_cipher.c
|
||||
+++ b/src/uadk_cipher.c
|
||||
@@ -39,6 +39,7 @@
|
||||
#define IV_LEN 16
|
||||
#define ENV_ENABLED 1
|
||||
#define MAX_KEY_LEN 64
|
||||
+#define SMALL_PACKET_OFFLOAD_THRESHOLD_DEFAULT 192
|
||||
|
||||
struct cipher_engine {
|
||||
struct wd_ctx_config ctx_cfg;
|
||||
@@ -75,8 +76,6 @@ struct cipher_info {
|
||||
__u32 out_bytes;
|
||||
};
|
||||
|
||||
-#define SMALL_PACKET_OFFLOAD_THRESHOLD_DEFAULT 192
|
||||
-
|
||||
static EVP_CIPHER *uadk_aes_128_cbc;
|
||||
static EVP_CIPHER *uadk_aes_192_cbc;
|
||||
static EVP_CIPHER *uadk_aes_256_cbc;
|
||||
@@ -189,9 +188,9 @@ static int uadk_e_cipher_sw_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
return 0;
|
||||
}
|
||||
|
||||
- sw_cipher = sec_ciphers_get_cipher_sw_impl(EVP_CIPHER_CTX_nid(ctx));
|
||||
+ nid = EVP_CIPHER_CTX_nid(ctx);
|
||||
+ sw_cipher = sec_ciphers_get_cipher_sw_impl(nid);
|
||||
if (unlikely(sw_cipher == NULL)) {
|
||||
- nid = EVP_CIPHER_CTX_nid(ctx);
|
||||
fprintf(stderr, "get openssl software cipher failed, nid = %d.\n", nid);
|
||||
return 0;
|
||||
}
|
||||
--
|
||||
2.25.1
|
||||
|
||||
29
0006-digest-add-ctx-allocation-check.patch
Normal file
29
0006-digest-add-ctx-allocation-check.patch
Normal file
@ -0,0 +1,29 @@
|
||||
From 07324a0cdcad935e7d3449b8ff8907ca1c2a6b58 Mon Sep 17 00:00:00 2001
|
||||
From: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
Date: Fri, 29 Mar 2024 10:13:24 +0800
|
||||
Subject: [PATCH 6/7] digest: add ctx allocation check
|
||||
|
||||
Add result check of EVP_MD_CTX_new().
|
||||
|
||||
Signed-off-by: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
Signed-off-by: JiangShui Yang <yangjiangshui@h-partners.com>
|
||||
---
|
||||
src/uadk_digest.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/uadk_digest.c b/src/uadk_digest.c
|
||||
index 8ab1b83..43bbf60 100644
|
||||
--- a/src/uadk_digest.c
|
||||
+++ b/src/uadk_digest.c
|
||||
@@ -204,6 +204,8 @@ static int digest_soft_init(struct digest_priv_ctx *md_ctx)
|
||||
/* Allocate a soft ctx for hardware engine */
|
||||
if (md_ctx->soft_ctx == NULL)
|
||||
md_ctx->soft_ctx = EVP_MD_CTX_new();
|
||||
+ if (md_ctx->soft_ctx == NULL)
|
||||
+ return 0;
|
||||
|
||||
ctx = md_ctx->soft_ctx;
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
||||
35
0007-sm2-add-ctx-allocation-check.patch
Normal file
35
0007-sm2-add-ctx-allocation-check.patch
Normal file
@ -0,0 +1,35 @@
|
||||
From 75ee064d69f687aa43cff40ce2061db1afe75f85 Mon Sep 17 00:00:00 2001
|
||||
From: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
Date: Fri, 29 Mar 2024 10:13:25 +0800
|
||||
Subject: [PATCH 7/7] sm2: add ctx allocation check
|
||||
|
||||
Add result check of EVP_MD_CTX_new().
|
||||
|
||||
Signed-off-by: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
Signed-off-by: JiangShui Yang <yangjiangshui@h-partners.com>
|
||||
---
|
||||
src/uadk_sm2.c | 6 +++++-
|
||||
1 file changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/uadk_sm2.c b/src/uadk_sm2.c
|
||||
index 8421931..c0a5303 100644
|
||||
--- a/src/uadk_sm2.c
|
||||
+++ b/src/uadk_sm2.c
|
||||
@@ -152,9 +152,13 @@ static int compute_hash(const char *in, size_t in_len,
|
||||
char *out, size_t out_len, void *usr)
|
||||
{
|
||||
const EVP_MD *digest = (const EVP_MD *)usr;
|
||||
- EVP_MD_CTX *hash = EVP_MD_CTX_new();
|
||||
+ EVP_MD_CTX *hash;
|
||||
int ret = 0;
|
||||
|
||||
+ hash = EVP_MD_CTX_new();
|
||||
+ if (!hash)
|
||||
+ return -1;
|
||||
+
|
||||
if (EVP_DigestInit(hash, digest) == 0 ||
|
||||
EVP_DigestUpdate(hash, in, in_len) == 0 ||
|
||||
EVP_DigestFinal(hash, (void *)out, NULL) == 0) {
|
||||
--
|
||||
2.25.1
|
||||
|
||||
70
0008-uadk_prov_cipher-enable-padding-for-block-mode.patch
Normal file
70
0008-uadk_prov_cipher-enable-padding-for-block-mode.patch
Normal file
@ -0,0 +1,70 @@
|
||||
From f7b123a4b93a70390c97b7118d25b1ae32fbba2a Mon Sep 17 00:00:00 2001
|
||||
From: Zhangfei Gao <zhangfei.gao@linaro.org>
|
||||
Date: Fri, 22 Mar 2024 11:41:34 +0000
|
||||
Subject: [PATCH] uadk_prov_cipher: enable padding for block mode
|
||||
|
||||
Enable padding by default for block mode
|
||||
|
||||
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
|
||||
---
|
||||
src/uadk_prov_cipher.c | 29 ++++++++++++++++-------------
|
||||
1 file changed, 16 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/src/uadk_prov_cipher.c b/src/uadk_prov_cipher.c
|
||||
index 5cb91f6..fc41104 100644
|
||||
--- a/src/uadk_prov_cipher.c
|
||||
+++ b/src/uadk_prov_cipher.c
|
||||
@@ -679,27 +679,28 @@ static int uadk_prov_do_cipher(struct cipher_priv_ctx *priv, unsigned char *out,
|
||||
out += blksz;
|
||||
}
|
||||
|
||||
- if (nextblocks == 0)
|
||||
- goto out;
|
||||
+ if (nextblocks > 0) {
|
||||
+ if (!priv->enc && priv->pad && nextblocks == inlen)
|
||||
+ nextblocks -= blksz;
|
||||
+ outlint += nextblocks;
|
||||
+ }
|
||||
|
||||
- if (!priv->enc && priv->pad && nextblocks == inlen)
|
||||
- nextblocks -= blksz;
|
||||
+ if (nextblocks > 0) {
|
||||
+ ret = uadk_prov_hw_cipher(priv, out, outl, outsize, in, nextblocks);
|
||||
+ if (ret != 1) {
|
||||
+ fprintf(stderr, "do hw ciphers failed.\n");
|
||||
+ return ret;
|
||||
+ }
|
||||
|
||||
- ret = uadk_prov_hw_cipher(priv, out, outl, outsize, in, nextblocks);
|
||||
- if (ret != 1) {
|
||||
- fprintf(stderr, "do hw ciphers failed.\n");
|
||||
- return ret;
|
||||
+ in += nextblocks;
|
||||
+ inlen -= nextblocks;
|
||||
}
|
||||
|
||||
- outlint += nextblocks;
|
||||
- in += nextblocks;
|
||||
- inlen -= nextblocks;
|
||||
-
|
||||
if (inlen != 0
|
||||
&& !ossl_cipher_trailingdata(priv->buf, &priv->bufsz,
|
||||
blksz, &in, &inlen))
|
||||
return 0;
|
||||
-out:
|
||||
+
|
||||
*outl = outlint;
|
||||
return inlen == 0;
|
||||
}
|
||||
@@ -1125,6 +1126,8 @@ static void *uadk_##nm##_newctx(void *provctx) \
|
||||
if (ctx->sw_ctx == NULL) \
|
||||
fprintf(stderr, "EVP_CIPHER_CTX_new failed.\n"); \
|
||||
strncpy(ctx->alg_name, #algnm, ALG_NAME_SIZE - 1); \
|
||||
+ if (strcmp(#typ, "block") == 0) \
|
||||
+ ctx->pad = 1;\
|
||||
return ctx; \
|
||||
} \
|
||||
static OSSL_FUNC_cipher_get_params_fn uadk_##nm##_get_params; \
|
||||
--
|
||||
2.43.0
|
||||
|
||||
59
0009-uadk_prov_cipher-dec-and-enc-use-same-op.patch
Normal file
59
0009-uadk_prov_cipher-dec-and-enc-use-same-op.patch
Normal file
@ -0,0 +1,59 @@
|
||||
From 4d8e10590405e7ed30a241202624146b18635030 Mon Sep 17 00:00:00 2001
|
||||
From: Zhangfei Gao <zhangfei.gao@linaro.org>
|
||||
Date: Fri, 29 Mar 2024 08:54:32 +0000
|
||||
Subject: [PATCH 09/15] uadk_prov_cipher: dec and enc use same op
|
||||
|
||||
Cipher can use same op for dec and enc, so alloc 1 op.
|
||||
|
||||
Otherwise, there maybe issue in env case, where
|
||||
driver->op_type_num is used,
|
||||
drv/hisi_sec.c:621: .op_type_num = 1,
|
||||
|
||||
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
|
||||
---
|
||||
src/uadk_prov_cipher.c | 10 ++++------
|
||||
1 file changed, 4 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/uadk_prov_cipher.c b/src/uadk_prov_cipher.c
|
||||
index fc41104..91e60d8 100644
|
||||
--- a/src/uadk_prov_cipher.c
|
||||
+++ b/src/uadk_prov_cipher.c
|
||||
@@ -420,14 +420,13 @@ static void uadk_prov_cipher_ctx_init(struct cipher_priv_ctx *priv)
|
||||
struct wd_ctx_nums *ctx_set_num;
|
||||
struct wd_ctx_params cparams = {0};
|
||||
|
||||
- /* 0: enc, 1: dec */
|
||||
- ctx_set_num = calloc(2, sizeof(*ctx_set_num));
|
||||
+ ctx_set_num = calloc(1, sizeof(*ctx_set_num));
|
||||
if (!ctx_set_num) {
|
||||
fprintf(stderr, "failed to alloc ctx_set_size!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
- cparams.op_type_num = 2;
|
||||
+ cparams.op_type_num = 1;
|
||||
cparams.ctx_set_num = ctx_set_num;
|
||||
cparams.bmp = numa_allocate_nodemask();
|
||||
if (!cparams.bmp) {
|
||||
@@ -440,8 +439,6 @@ static void uadk_prov_cipher_ctx_init(struct cipher_priv_ctx *priv)
|
||||
|
||||
ctx_set_num[0].sync_ctx_num = 2;
|
||||
ctx_set_num[0].async_ctx_num = 2;
|
||||
- ctx_set_num[1].sync_ctx_num = 2;
|
||||
- ctx_set_num[1].async_ctx_num = 2;
|
||||
|
||||
ret = wd_cipher_init2_(priv->alg_name, 0, 0, &cparams);
|
||||
numa_free_nodemask(cparams.bmp);
|
||||
@@ -458,7 +455,8 @@ static void uadk_prov_cipher_ctx_init(struct cipher_priv_ctx *priv)
|
||||
}
|
||||
pthread_mutex_unlock(&cipher_mutex);
|
||||
|
||||
- params.type = priv->req.op_type;
|
||||
+ /* dec and enc use the same op */
|
||||
+ params.type = 0;
|
||||
/* Use the default numa parameters */
|
||||
params.numa_id = -1;
|
||||
priv->setup.sched_param = ¶ms;
|
||||
--
|
||||
2.43.0
|
||||
|
||||
51
0010-kmgmt-KEYMGMT-struct-is-different-in-3.2.patch
Normal file
51
0010-kmgmt-KEYMGMT-struct-is-different-in-3.2.patch
Normal file
@ -0,0 +1,51 @@
|
||||
From 43304e09b57473e3925457612d37a321e61fc39c Mon Sep 17 00:00:00 2001
|
||||
From: Zhangfei Gao <zhangfei.gao@linaro.org>
|
||||
Date: Mon, 6 May 2024 14:54:21 +0000
|
||||
Subject: [PATCH 10/15] kmgmt: KEYMGMT struct is different in 3.2
|
||||
|
||||
KEYMGMT struct is different in 3.2 causes Segmentation fault.
|
||||
Fix it by adding version check.
|
||||
|
||||
$ openssl speed -provider uadk provider rsa1024
|
||||
Segmentation fault(core dumped)
|
||||
|
||||
$ openssl version
|
||||
OpenssL 3.2.0-dev (Library: OpenssL 3.2.0-dev)
|
||||
|
||||
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
|
||||
---
|
||||
src/uadk_prov_dh.c | 2 ++
|
||||
src/uadk_prov_rsa.c | 2 ++
|
||||
2 files changed, 4 insertions(+)
|
||||
|
||||
diff --git a/src/uadk_prov_dh.c b/src/uadk_prov_dh.c
|
||||
index 5437c46..c0adc2b 100644
|
||||
--- a/src/uadk_prov_dh.c
|
||||
+++ b/src/uadk_prov_dh.c
|
||||
@@ -248,7 +248,9 @@ typedef struct {
|
||||
OSSL_PROVIDER *prov;
|
||||
|
||||
int refcnt;
|
||||
+# if OPENSSL_VERSION_NUMBER < 0x30200000
|
||||
void *lock;
|
||||
+# endif
|
||||
|
||||
/* Constructor(s), destructor, information */
|
||||
OSSL_FUNC_keymgmt_new_fn *new;
|
||||
diff --git a/src/uadk_prov_rsa.c b/src/uadk_prov_rsa.c
|
||||
index b60de0c..7918b51 100644
|
||||
--- a/src/uadk_prov_rsa.c
|
||||
+++ b/src/uadk_prov_rsa.c
|
||||
@@ -299,7 +299,9 @@ typedef struct{
|
||||
OSSL_PROVIDER *prov;
|
||||
|
||||
int refcnt;
|
||||
+# if OPENSSL_VERSION_NUMBER < 0x30200000
|
||||
void *lock;
|
||||
+# endif
|
||||
|
||||
/* Constructor(s), destructor, information */
|
||||
OSSL_FUNC_keymgmt_new_fn *new;
|
||||
--
|
||||
2.43.0
|
||||
|
||||
196
0011-uadk_prov_cipher-do_soft-when-hw-failed.patch
Normal file
196
0011-uadk_prov_cipher-do_soft-when-hw-failed.patch
Normal file
@ -0,0 +1,196 @@
|
||||
From 04e53b7daedf16c7d50237a54f7f9d5c5b1b044e Mon Sep 17 00:00:00 2001
|
||||
From: Zhangfei Gao <zhangfei.gao@linaro.org>
|
||||
Date: Mon, 29 Apr 2024 15:14:26 +0000
|
||||
Subject: [PATCH 11/15] uadk_prov_cipher: do_soft when hw failed
|
||||
|
||||
By default, do_soft is disabled.
|
||||
To enable sw handling, need set enable_sw_offload = 1 via OPENSSL_CONF
|
||||
|
||||
For example: uadk_provider.cnf
|
||||
|
||||
openssl_conf = openssl_init
|
||||
|
||||
[openssl_init]
|
||||
providers = provider_sect
|
||||
|
||||
[provider_sect]
|
||||
uadk_provider = uadk_sect
|
||||
|
||||
[uadk_sect]
|
||||
activate = 1
|
||||
enable_sw_offload = 1
|
||||
|
||||
export OPENSSL_CONF=uadk_provider.cnf
|
||||
|
||||
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
|
||||
---
|
||||
src/uadk_prov_cipher.c | 83 +++++++++++++++++++++++++++---------------
|
||||
1 file changed, 53 insertions(+), 30 deletions(-)
|
||||
|
||||
diff --git a/src/uadk_prov_cipher.c b/src/uadk_prov_cipher.c
|
||||
index 91e60d8..fa79764 100644
|
||||
--- a/src/uadk_prov_cipher.c
|
||||
+++ b/src/uadk_prov_cipher.c
|
||||
@@ -286,6 +286,7 @@ static int uadk_prov_cipher_init(struct cipher_priv_ctx *priv,
|
||||
|
||||
if (enable_sw_offload)
|
||||
uadk_prov_cipher_sw_init(priv, key, iv);
|
||||
+
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -639,19 +640,7 @@ static int uadk_prov_do_cipher(struct cipher_priv_ctx *priv, unsigned char *out,
|
||||
(priv->switch_flag == UADK_DO_SOFT ||
|
||||
(priv->switch_flag != UADK_DO_HW &&
|
||||
inlen <= priv->switch_threshold))) {
|
||||
- /*
|
||||
- * Using soft only if enable_sw_offload, which is set in conf file,
|
||||
- * then sw_cipher is initialzied
|
||||
- * 1. small packets
|
||||
- * 2. already choose DO_SOFT, can be hw fail case or following sw case
|
||||
- */
|
||||
- ret = uadk_prov_cipher_soft_work(priv, out, &outlint, in, inlen);
|
||||
- if (ret) {
|
||||
- *outl = outlint;
|
||||
- return 1;
|
||||
- }
|
||||
-
|
||||
- fprintf(stderr, "do soft ciphers failed.\n");
|
||||
+ goto do_soft;
|
||||
}
|
||||
|
||||
if (priv->bufsz != 0)
|
||||
@@ -669,6 +658,8 @@ static int uadk_prov_do_cipher(struct cipher_priv_ctx *priv, unsigned char *out,
|
||||
ret = uadk_prov_hw_cipher(priv, out, outl, outsize, priv->buf, blksz);
|
||||
if (ret != 1) {
|
||||
fprintf(stderr, "do hw ciphers failed.\n");
|
||||
+ if (priv->sw_cipher)
|
||||
+ goto do_soft;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -687,6 +678,8 @@ static int uadk_prov_do_cipher(struct cipher_priv_ctx *priv, unsigned char *out,
|
||||
ret = uadk_prov_hw_cipher(priv, out, outl, outsize, in, nextblocks);
|
||||
if (ret != 1) {
|
||||
fprintf(stderr, "do hw ciphers failed.\n");
|
||||
+ if (priv->sw_cipher)
|
||||
+ goto do_soft;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -701,6 +694,22 @@ static int uadk_prov_do_cipher(struct cipher_priv_ctx *priv, unsigned char *out,
|
||||
|
||||
*outl = outlint;
|
||||
return inlen == 0;
|
||||
+
|
||||
+do_soft:
|
||||
+ /*
|
||||
+ * Using soft only if enable_sw_offload, which is set in conf file,
|
||||
+ * then sw_cipher is initialzied
|
||||
+ * 1. small packets
|
||||
+ * 2. already choose DO_SOFT, can be hw fail case or following sw case
|
||||
+ */
|
||||
+ ret = uadk_prov_cipher_soft_work(priv, out, &outlint, in, inlen);
|
||||
+ if (ret) {
|
||||
+ *outl = outlint;
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ fprintf(stderr, "do soft ciphers failed.\n");
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
void uadk_prov_destroy_cipher(void)
|
||||
@@ -756,12 +765,7 @@ static int uadk_prov_cipher_block_final(void *vctx, unsigned char *out,
|
||||
|
||||
if (priv->sw_cipher &&
|
||||
priv->switch_flag == UADK_DO_SOFT) {
|
||||
- if (!EVP_CipherFinal_ex(priv->sw_ctx, out, &sw_final_len)) {
|
||||
- fprintf(stderr, "EVP_CipherFinal_ex sw_ctx failed.\n");
|
||||
- return 0;
|
||||
- }
|
||||
- *outl = sw_final_len;
|
||||
- return 1;
|
||||
+ goto do_soft;
|
||||
}
|
||||
|
||||
if (priv->enc) {
|
||||
@@ -783,6 +787,8 @@ static int uadk_prov_cipher_block_final(void *vctx, unsigned char *out,
|
||||
ret = uadk_prov_hw_cipher(priv, out, outl, outsize, priv->buf, blksz);
|
||||
if (ret != 1) {
|
||||
fprintf(stderr, "do hw ciphers failed.\n");
|
||||
+ if (priv->sw_cipher)
|
||||
+ goto do_soft;
|
||||
return ret;
|
||||
}
|
||||
*outl = blksz;
|
||||
@@ -802,6 +808,8 @@ static int uadk_prov_cipher_block_final(void *vctx, unsigned char *out,
|
||||
ret = uadk_prov_hw_cipher(priv, priv->buf, outl, outsize, priv->buf, blksz);
|
||||
if (ret != 1) {
|
||||
fprintf(stderr, "do hw ciphers failed.\n");
|
||||
+ if (priv->sw_cipher)
|
||||
+ goto do_soft;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -820,6 +828,14 @@ static int uadk_prov_cipher_block_final(void *vctx, unsigned char *out,
|
||||
priv->bufsz = 0;
|
||||
|
||||
return 1;
|
||||
+
|
||||
+do_soft:
|
||||
+ if (!EVP_CipherFinal_ex(priv->sw_ctx, out, &sw_final_len)) {
|
||||
+ fprintf(stderr, "EVP_CipherFinal_ex sw_ctx failed.\n");
|
||||
+ return 0;
|
||||
+ }
|
||||
+ *outl = sw_final_len;
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
static int uadk_prov_cipher_block_update(void *vctx, unsigned char *out,
|
||||
@@ -867,24 +883,31 @@ static int uadk_prov_cipher_stream_update(void *vctx, unsigned char *out,
|
||||
(priv->switch_flag == UADK_DO_SOFT ||
|
||||
(priv->switch_flag != UADK_DO_HW &&
|
||||
inl <= priv->switch_threshold))) {
|
||||
- int len = 0;
|
||||
-
|
||||
- /* have isseu if both using hw and soft partly */
|
||||
- ret = uadk_prov_cipher_soft_work(priv, out, &len, in, inl);
|
||||
- if (ret) {
|
||||
- *outl = len;
|
||||
- return 1;
|
||||
- }
|
||||
-
|
||||
- fprintf(stderr, "do soft ciphers failed.\n");
|
||||
+ goto do_soft;
|
||||
}
|
||||
|
||||
ret = uadk_prov_hw_cipher(priv, out, outl, outsize, in, inl);
|
||||
- if (ret != 1)
|
||||
+ if (ret != 1) {
|
||||
+ if (priv->sw_cipher)
|
||||
+ goto do_soft;
|
||||
return ret;
|
||||
+ }
|
||||
|
||||
*outl = inl;
|
||||
return 1;
|
||||
+
|
||||
+do_soft:
|
||||
+ int len = 0;
|
||||
+
|
||||
+ /* have isseu if both using hw and soft partly */
|
||||
+ ret = uadk_prov_cipher_soft_work(priv, out, &len, in, inl);
|
||||
+ if (ret) {
|
||||
+ *outl = len;
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ fprintf(stderr, "do soft ciphers failed.\n");
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static int uadk_prov_cipher_stream_final(void *vctx, unsigned char *out,
|
||||
--
|
||||
2.43.0
|
||||
|
||||
32
0012-uadk_digest-solve-build-warning.patch
Normal file
32
0012-uadk_digest-solve-build-warning.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From da203ad894a33f1b06c01794947532d1cb36af7d Mon Sep 17 00:00:00 2001
|
||||
From: Zhangfei Gao <zhangfei.gao@linaro.org>
|
||||
Date: Tue, 30 Apr 2024 04:14:18 +0000
|
||||
Subject: [PATCH 12/15] uadk_digest: solve build warning
|
||||
|
||||
solve build warning since no {}
|
||||
|
||||
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
|
||||
---
|
||||
src/uadk_digest.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/uadk_digest.c b/src/uadk_digest.c
|
||||
index 43bbf60..9a583b4 100644
|
||||
--- a/src/uadk_digest.c
|
||||
+++ b/src/uadk_digest.c
|
||||
@@ -202,10 +202,11 @@ static int digest_soft_init(struct digest_priv_ctx *md_ctx)
|
||||
int app_datasize;
|
||||
|
||||
/* Allocate a soft ctx for hardware engine */
|
||||
- if (md_ctx->soft_ctx == NULL)
|
||||
+ if (md_ctx->soft_ctx == NULL) {
|
||||
md_ctx->soft_ctx = EVP_MD_CTX_new();
|
||||
if (md_ctx->soft_ctx == NULL)
|
||||
return 0;
|
||||
+ }
|
||||
|
||||
ctx = md_ctx->soft_ctx;
|
||||
|
||||
--
|
||||
2.43.0
|
||||
|
||||
33
0013-cipher-remove-aead-in-v2-temporarily-for-nginx.patch
Normal file
33
0013-cipher-remove-aead-in-v2-temporarily-for-nginx.patch
Normal file
@ -0,0 +1,33 @@
|
||||
From 2432c3f2c3014ffd3cab7ed2405e988a3a533387 Mon Sep 17 00:00:00 2001
|
||||
From: Zhangfei Gao <zhangfei.gao@linaro.org>
|
||||
Date: Sat, 11 May 2024 08:10:51 +0000
|
||||
Subject: [PATCH 13/15] cipher: remove aead in v2 temporarily for nginx
|
||||
|
||||
The aead has issues causing nginx failure.
|
||||
log:
|
||||
do aead update operation failed, ret: -22, state: 0!
|
||||
|
||||
Temporarily, remove aead support to make nginx work.
|
||||
|
||||
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
|
||||
---
|
||||
src/uadk_cipher_adapter.c | 3 ---
|
||||
1 file changed, 3 deletions(-)
|
||||
|
||||
diff --git a/src/uadk_cipher_adapter.c b/src/uadk_cipher_adapter.c
|
||||
index caf8af3..b4a7a0e 100644
|
||||
--- a/src/uadk_cipher_adapter.c
|
||||
+++ b/src/uadk_cipher_adapter.c
|
||||
@@ -34,9 +34,6 @@ static int cipher_hw_v2_nids[] = {
|
||||
NID_sm4_ecb,
|
||||
NID_des_ede3_cbc,
|
||||
NID_des_ede3_ecb,
|
||||
- NID_aes_128_gcm,
|
||||
- NID_aes_192_gcm,
|
||||
- NID_aes_256_gcm
|
||||
};
|
||||
|
||||
static int cipher_hw_v3_nids[] = {
|
||||
--
|
||||
2.43.0
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
From b840e2d5d9ff7b828b0e82047e06fa374aa6354c Mon Sep 17 00:00:00 2001
|
||||
From: Zhangfei Gao <zhangfei.gao@linaro.org>
|
||||
Date: Sun, 26 May 2024 01:17:38 +0000
|
||||
Subject: [PATCH 14/15] sm2: fix build warning in openssl 3.0 of incompatible
|
||||
pointer type
|
||||
|
||||
openssl 3.0 introduce const, fixed by version check
|
||||
|
||||
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
|
||||
---
|
||||
src/uadk_sm2.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/src/uadk_sm2.c b/src/uadk_sm2.c
|
||||
index c0a5303..b8548d1 100644
|
||||
--- a/src/uadk_sm2.c
|
||||
+++ b/src/uadk_sm2.c
|
||||
@@ -1605,7 +1605,11 @@ static int sm2_digest_custom(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx)
|
||||
return EVP_DigestUpdate(mctx, z, (size_t)mdlen);
|
||||
}
|
||||
|
||||
+# if OPENSSL_VERSION_NUMBER < 0x30000000
|
||||
static int sm2_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
|
||||
+# else
|
||||
+static int sm2_copy(EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src)
|
||||
+# endif
|
||||
{
|
||||
struct sm2_ctx *dctx, *sctx;
|
||||
|
||||
--
|
||||
2.43.0
|
||||
|
||||
101
0015-aead-fix-build-warning-of-storing-address-of-local-v.patch
Normal file
101
0015-aead-fix-build-warning-of-storing-address-of-local-v.patch
Normal file
@ -0,0 +1,101 @@
|
||||
From ee30a80cf45d0c165a3a993d29ffca94a3747111 Mon Sep 17 00:00:00 2001
|
||||
From: Zhangfei Gao <zhangfei.gao@linaro.org>
|
||||
Date: Sun, 26 May 2024 01:59:06 +0000
|
||||
Subject: [PATCH 15/15] aead: fix build warning of storing address of local
|
||||
variable
|
||||
|
||||
uadk_aead.c:280:33: warning: storing the address of local variable \
|
||||
'params' in '*priv.setup.sched_param' [-Wdangling-pointer=]
|
||||
|
||||
The local variable will disappear when func returns, so its address
|
||||
should not be stored.
|
||||
|
||||
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
|
||||
---
|
||||
src/uadk_aead.c | 33 +++++++++++++++++----------------
|
||||
1 file changed, 17 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/src/uadk_aead.c b/src/uadk_aead.c
|
||||
index c7527ed..2a5c024 100644
|
||||
--- a/src/uadk_aead.c
|
||||
+++ b/src/uadk_aead.c
|
||||
@@ -46,7 +46,6 @@
|
||||
|
||||
struct aead_priv_ctx {
|
||||
handle_t sess;
|
||||
- struct wd_aead_sess_setup setup;
|
||||
struct wd_aead_req req;
|
||||
unsigned char *data;
|
||||
unsigned char iv[AES_GCM_BLOCK_SIZE];
|
||||
@@ -262,24 +261,17 @@ static int uadk_e_init_aead_cipher(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
-static int uadk_e_ctx_init(struct aead_priv_ctx *priv, const unsigned char *ckey, int ckey_len)
|
||||
+static int uadk_e_ctx_init(struct aead_priv_ctx *priv, const unsigned char *ckey,
|
||||
+ int ckey_len, struct wd_aead_sess_setup *setup)
|
||||
{
|
||||
- struct sched_params params = {0};
|
||||
int ret;
|
||||
|
||||
ret = uadk_e_init_aead_cipher();
|
||||
if (!ret)
|
||||
return 0;
|
||||
|
||||
- params.type = priv->req.op_type;
|
||||
- ret = uadk_e_is_env_enabled("aead");
|
||||
- if (ret)
|
||||
- params.type = 0;
|
||||
-
|
||||
- params.numa_id = g_aead_engine.numa_id;
|
||||
- priv->setup.sched_param = ¶ms;
|
||||
if (!priv->sess) {
|
||||
- priv->sess = wd_aead_alloc_sess(&priv->setup);
|
||||
+ priv->sess = wd_aead_alloc_sess(setup);
|
||||
if (!priv->sess) {
|
||||
fprintf(stderr, "uadk engine failed to alloc aead session!\n");
|
||||
return 0;
|
||||
@@ -316,6 +308,8 @@ out:
|
||||
static int uadk_e_aes_gcm_init(EVP_CIPHER_CTX *ctx, const unsigned char *ckey,
|
||||
const unsigned char *iv, int enc)
|
||||
{
|
||||
+ struct wd_aead_sess_setup setup;
|
||||
+ struct sched_params params = {0};
|
||||
struct aead_priv_ctx *priv;
|
||||
int ret, ckey_len;
|
||||
|
||||
@@ -331,10 +325,10 @@ static int uadk_e_aes_gcm_init(EVP_CIPHER_CTX *ctx, const unsigned char *ckey,
|
||||
if (iv)
|
||||
memcpy(priv->iv, iv, AES_GCM_IV_LEN);
|
||||
|
||||
- priv->setup.calg = WD_CIPHER_AES;
|
||||
- priv->setup.cmode = WD_CIPHER_GCM;
|
||||
- priv->setup.dalg = 0;
|
||||
- priv->setup.dmode = 0;
|
||||
+ setup.calg = WD_CIPHER_AES;
|
||||
+ setup.cmode = WD_CIPHER_GCM;
|
||||
+ setup.dalg = 0;
|
||||
+ setup.dmode = 0;
|
||||
|
||||
priv->req.assoc_bytes = 0;
|
||||
priv->req.out_bytes = 0;
|
||||
@@ -354,8 +348,15 @@ static int uadk_e_aes_gcm_init(EVP_CIPHER_CTX *ctx, const unsigned char *ckey,
|
||||
else
|
||||
priv->req.op_type = WD_CIPHER_DECRYPTION_DIGEST;
|
||||
|
||||
+ params.type = priv->req.op_type;
|
||||
+ ret = uadk_e_is_env_enabled("aead");
|
||||
+ if (ret)
|
||||
+ params.type = 0;
|
||||
+ params.numa_id = g_aead_engine.numa_id;
|
||||
+ setup.sched_param = ¶ms;
|
||||
+
|
||||
ckey_len = EVP_CIPHER_CTX_key_length(ctx);
|
||||
- ret = uadk_e_ctx_init(priv, ckey, ckey_len);
|
||||
+ ret = uadk_e_ctx_init(priv, ckey, ckey_len, &setup);
|
||||
if (!ret)
|
||||
return 0;
|
||||
|
||||
--
|
||||
2.43.0
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Name: uadk_engine
|
||||
Summary: UADK Accelerator Engine
|
||||
Version: 1.3.0
|
||||
Release: 1
|
||||
Release: 3
|
||||
License: Apache-2.0
|
||||
Source: %{name}-%{version}.tar.gz
|
||||
ExclusiveOS: linux
|
||||
@ -16,6 +16,18 @@ ExclusiveArch: aarch64
|
||||
Patch0001: 0001-v1-dh-add-iova_map-and-iova_unmap-ops.patch
|
||||
Patch0002: 0002-uadk_util-fix-clang-build-error.patch
|
||||
Patch0003: 0003-uadk_engine-add-secure-compilation-option.patch
|
||||
Patch0004: 0004-uadk_engine-cleanup-code-style-of-async-functions.patch
|
||||
Patch0005: 0005-cipher-cleanup-repeated-function-invoking.patch
|
||||
Patch0006: 0006-digest-add-ctx-allocation-check.patch
|
||||
Patch0007: 0007-sm2-add-ctx-allocation-check.patch
|
||||
Patch0008: 0008-uadk_prov_cipher-enable-padding-for-block-mode.patch
|
||||
Patch0009: 0009-uadk_prov_cipher-dec-and-enc-use-same-op.patch
|
||||
Patch0010: 0010-kmgmt-KEYMGMT-struct-is-different-in-3.2.patch
|
||||
Patch0011: 0011-uadk_prov_cipher-do_soft-when-hw-failed.patch
|
||||
Patch0012: 0012-uadk_digest-solve-build-warning.patch
|
||||
Patch0013: 0013-cipher-remove-aead-in-v2-temporarily-for-nginx.patch
|
||||
Patch0014: 0014-sm2-fix-build-warning-in-openssl-3.0-of-incompatible.patch
|
||||
Patch0015: 0015-aead-fix-build-warning-of-storing-address-of-local-v.patch
|
||||
|
||||
%description
|
||||
This package contains the UADK Accelerator Engine
|
||||
@ -66,6 +78,12 @@ fi
|
||||
/sbin/ldconfig
|
||||
|
||||
%changelog
|
||||
* Fri Nov 22 2024 JiangShui Yang <yangjiangshui@h-partners.com> 1.3.0-3
|
||||
- Backport uadk engine patch
|
||||
|
||||
* Thu Nov 21 2024 JiangShui Yang <yangjiangshui@h-partners.com> 1.3.0-2
|
||||
- Backport uadk engine patch
|
||||
|
||||
* Mon Jan 22 2024 Zhangfei Gao <zhangfei.gao@linaro.org> 1.3.0-1
|
||||
- uadk_eingine: update to 1.3.0
|
||||
|
||||
@ -81,7 +99,7 @@ fi
|
||||
* Fri Dec 16 2022 JiangShui Yang <yangjiangshui@h-partners.com> 1.0.0-8
|
||||
- Backport uadk engine patch for v1.0.1
|
||||
|
||||
* Tus Jul 26 2022 Yang Shen <shenyang39@huawei.com> 1.0.0-7
|
||||
* Tue Jul 26 2022 Yang Shen <shenyang39@huawei.com> 1.0.0-7
|
||||
- Backport uadk engine patch from v1.0.0 to v1.0.1
|
||||
|
||||
* Mon Mar 21 2022 linwenkai <linwenkai6@hisilicon.com> 1.0.0-6
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user