!10 [sync] PR-8: 从社区同步代码
From: @openeuler-sync-bot Reviewed-by: @hao-fang Signed-off-by: @hao-fang
This commit is contained in:
commit
6087bf1aae
32
0024-rsa-fix-interface-name.patch
Normal file
32
0024-rsa-fix-interface-name.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From 63c9bc75f229057657ff8b09c556bf416a493607 Mon Sep 17 00:00:00 2001
|
||||
From: Junchong Pan <panjunchong@hisilicon.com>
|
||||
Date: Wed, 2 Mar 2022 08:30:50 +0000
|
||||
Subject: [PATCH 24/31] rsa: fix interface name
|
||||
|
||||
The name of the function wd_rsa_key_bits()
|
||||
has been changed to wd_rsa_get_key_bits()
|
||||
in uadk driver, so it needs to be modified
|
||||
in engine synchronously.
|
||||
|
||||
Signed-off-by: Junchong Pan <panjunchong@hisilicon.com>
|
||||
Signed-off-by: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
---
|
||||
src/uadk_rsa.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/uadk_rsa.c b/src/uadk_rsa.c
|
||||
index 8cad2f7..90cc535 100644
|
||||
--- a/src/uadk_rsa.c
|
||||
+++ b/src/uadk_rsa.c
|
||||
@@ -986,7 +986,7 @@ static int rsa_get_keygen_param(struct wd_rsa_req *req,
|
||||
struct wd_dtb wd_dq;
|
||||
struct wd_dtb wd_dp;
|
||||
|
||||
- key_bits = wd_rsa_key_bits(ctx);
|
||||
+ key_bits = wd_rsa_get_key_bits(ctx);
|
||||
key_size = key_bits >> BIT_BYTES_SHIFT;
|
||||
wd_rsa_get_kg_out_params(out, &wd_d, &wd_n);
|
||||
wd_rsa_get_kg_out_crt_params(out, &wd_qinv, &wd_dq, &wd_dp);
|
||||
--
|
||||
2.24.4
|
||||
|
||||
28
0025-ecc-cleanup-sm2-unreachable-code.patch
Normal file
28
0025-ecc-cleanup-sm2-unreachable-code.patch
Normal file
@ -0,0 +1,28 @@
|
||||
From dcceb7e8f77306dda7dea31798ea8ab952fbe8ea Mon Sep 17 00:00:00 2001
|
||||
From: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
Date: Thu, 3 Mar 2022 02:00:46 +0000
|
||||
Subject: [PATCH 25/31] ecc: cleanup sm2 unreachable code
|
||||
|
||||
The variable "b_s" should be judged, rather than "b_r".
|
||||
|
||||
Signed-off-by: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
---
|
||||
src/uadk_sm2.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/uadk_sm2.c b/src/uadk_sm2.c
|
||||
index b39c418..8c75611 100644
|
||||
--- a/src/uadk_sm2.c
|
||||
+++ b/src/uadk_sm2.c
|
||||
@@ -422,7 +422,7 @@ static int sig_ber_to_bin(EC_KEY *ec, unsigned char *sig, size_t sig_len,
|
||||
}
|
||||
|
||||
b_s = (void *)ECDSA_SIG_get0_s((const ECDSA_SIG *)e_sig);
|
||||
- if (!b_r) {
|
||||
+ if (!b_s) {
|
||||
fprintf(stderr, "failed to get s\n");
|
||||
ret = -EINVAL;
|
||||
goto free_der;
|
||||
--
|
||||
2.24.4
|
||||
|
||||
68
0026-rsa-cleanup-of-code-style.patch
Normal file
68
0026-rsa-cleanup-of-code-style.patch
Normal file
@ -0,0 +1,68 @@
|
||||
From 4bcecc067ed99f2323f1568779c34b858b5863a1 Mon Sep 17 00:00:00 2001
|
||||
From: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
Date: Thu, 3 Mar 2022 02:32:44 +0000
|
||||
Subject: [PATCH 26/31] rsa: cleanup of code style
|
||||
|
||||
Fix the following problems:
|
||||
1. Macro replacement list should be enclosed in parentheses.
|
||||
2. Return value judgment should follow the function call.
|
||||
3. Remove redundant judgment.
|
||||
|
||||
Signed-off-by: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
---
|
||||
src/uadk_rsa.c | 12 +++---------
|
||||
1 file changed, 3 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/src/uadk_rsa.c b/src/uadk_rsa.c
|
||||
index 90cc535..f7755e3 100644
|
||||
--- a/src/uadk_rsa.c
|
||||
+++ b/src/uadk_rsa.c
|
||||
@@ -49,7 +49,7 @@
|
||||
#define UADK_DO_SOFT (-0xE0)
|
||||
#define UADK_E_POLL_SUCCESS 0
|
||||
#define UADK_E_INIT_SUCCESS 0
|
||||
-#define CHECK_PADDING_FAIL -1
|
||||
+#define CHECK_PADDING_FAIL (-1)
|
||||
#define ENV_ENABLED 1
|
||||
|
||||
static RSA_METHOD *rsa_hw_meth;
|
||||
@@ -312,7 +312,6 @@ static int check_rsa_prime_useful(const int *n, struct rsa_prime_param *param,
|
||||
return UADK_E_SUCCESS;
|
||||
|
||||
err = ERR_peek_last_error();
|
||||
-
|
||||
if (ERR_GET_LIB(err) == ERR_LIB_BN &&
|
||||
ERR_GET_REASON(err) == BN_R_NO_INVERSE)
|
||||
ERR_pop_to_mark();
|
||||
@@ -500,18 +499,13 @@ static int add_rsa_pubenc_padding(int flen, const unsigned char *from,
|
||||
fprintf(stderr, "RSA_PKCS1_PADDING err\n");
|
||||
break;
|
||||
case RSA_PKCS1_OAEP_PADDING:
|
||||
- ret = RSA_padding_add_PKCS1_OAEP(buf, num, from, flen,
|
||||
- NULL, 0);
|
||||
+ ret = RSA_padding_add_PKCS1_OAEP(buf, num, from, flen, NULL, 0);
|
||||
if (!ret)
|
||||
fprintf(stderr, "RSA_PKCS1_OAEP_PADDING err\n");
|
||||
break;
|
||||
default:
|
||||
ret = UADK_E_FAIL;
|
||||
}
|
||||
- if (ret <= 0)
|
||||
- ret = UADK_E_FAIL;
|
||||
- else
|
||||
- ret = UADK_E_SUCCESS;
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -530,7 +524,7 @@ static int check_rsa_pridec_padding(unsigned char *to, int num,
|
||||
break;
|
||||
case RSA_PKCS1_OAEP_PADDING:
|
||||
ret = RSA_padding_check_PKCS1_OAEP(to, num, buf, len, num,
|
||||
- NULL, 0);
|
||||
+ NULL, 0);
|
||||
if (!ret)
|
||||
fprintf(stderr, "RSA_PKCS1_OAEP_PADDING err\n");
|
||||
break;
|
||||
--
|
||||
2.24.4
|
||||
|
||||
62
0027-v1-fixup-about-uninitialized-variable.patch
Normal file
62
0027-v1-fixup-about-uninitialized-variable.patch
Normal file
@ -0,0 +1,62 @@
|
||||
From fe44bced638c7d3d3084f4e788478b2faa35ffa4 Mon Sep 17 00:00:00 2001
|
||||
From: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
Date: Thu, 3 Mar 2022 02:53:01 +0000
|
||||
Subject: [PATCH 27/31] v1: fixup about uninitialized variable
|
||||
|
||||
Fix the compile warning of uninitialized variable.
|
||||
|
||||
Signed-off-by: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
---
|
||||
src/v1/alg/pkey/hpre_rsa.c | 12 ++++++++----
|
||||
1 file changed, 8 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/v1/alg/pkey/hpre_rsa.c b/src/v1/alg/pkey/hpre_rsa.c
|
||||
index 93ba99a..6c1d96d 100644
|
||||
--- a/src/v1/alg/pkey/hpre_rsa.c
|
||||
+++ b/src/v1/alg/pkey/hpre_rsa.c
|
||||
@@ -316,7 +316,9 @@ static int hpre_rsa_public_encrypt(int flen, const unsigned char *from,
|
||||
BIGNUM *ret_bn = NULL;
|
||||
hpre_engine_ctx_t *eng_ctx = NULL;
|
||||
unsigned char *in_buf = NULL;
|
||||
- int key_bits, num_bytes;
|
||||
+ BN_CTX *bn_ctx = NULL;
|
||||
+ int num_bytes = 0;
|
||||
+ int key_bits;
|
||||
int ret;
|
||||
|
||||
if (hpre_rsa_check_para(flen, from, to, rsa) != HPRE_CRYPTO_SUCC)
|
||||
@@ -340,7 +342,7 @@ static int hpre_rsa_public_encrypt(int flen, const unsigned char *from,
|
||||
GOTOEND_IF(ret != HPRE_CRYPTO_SUCC, "check public key fail",
|
||||
KAE_F_HPRE_RSA_PUBENC, KAE_R_PUBLIC_KEY_INVALID);
|
||||
|
||||
- BN_CTX *bn_ctx = BN_CTX_new();
|
||||
+ bn_ctx = BN_CTX_new();
|
||||
|
||||
GOTOEND_IF(bn_ctx == NULL, "bn_ctx MALLOC FAILED!",
|
||||
KAE_F_HPRE_RSA_PUBENC, KAE_R_MALLOC_FAILURE);
|
||||
@@ -403,7 +405,9 @@ static int hpre_rsa_private_encrypt(int flen, const unsigned char *from,
|
||||
const BIGNUM *dmq1 = (const BIGNUM *)NULL;
|
||||
const BIGNUM *iqmp = (const BIGNUM *)NULL;
|
||||
unsigned char *in_buf = (unsigned char *)NULL;
|
||||
+ int num_bytes = 0;
|
||||
int key_bits;
|
||||
+ int version;
|
||||
|
||||
if (hpre_rsa_check_para(flen, from, to, rsa) != HPRE_CRYPTO_SUCC)
|
||||
return HPRE_CRYPTO_FAIL;
|
||||
@@ -431,10 +435,10 @@ static int hpre_rsa_private_encrypt(int flen, const unsigned char *from,
|
||||
bn_ret = BN_CTX_get(bn_ctx);
|
||||
RSA_get0_factors(rsa, &p, &q);
|
||||
RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp);
|
||||
- int version = RSA_get_version(rsa);
|
||||
+ version = RSA_get_version(rsa);
|
||||
|
||||
RSA_get0_key(rsa, &n, &e, &d);
|
||||
- int num_bytes = BN_num_bytes(n);
|
||||
+ num_bytes = BN_num_bytes(n);
|
||||
|
||||
in_buf = (unsigned char *)OPENSSL_malloc(num_bytes);
|
||||
GOTOEND_IF(bn_ret == NULL || in_buf == NULL, "OpenSSL malloc failure",
|
||||
--
|
||||
2.24.4
|
||||
|
||||
42
0028-ecc-fix-checking-conditions.patch
Normal file
42
0028-ecc-fix-checking-conditions.patch
Normal file
@ -0,0 +1,42 @@
|
||||
From 8ce0ba841358d85eb89bf726d229dfaf4cd13156 Mon Sep 17 00:00:00 2001
|
||||
From: Weili Qian <qianweili@huawei.com>
|
||||
Date: Thu, 3 Mar 2022 02:59:13 +0000
|
||||
Subject: [PATCH 28/31] ecc: fix checking conditions
|
||||
|
||||
When initializing, the process is guaranteed
|
||||
not to be initialized repeatedly. And when
|
||||
uninitializing, the resource is released according
|
||||
to whether the pid is equal or not.
|
||||
|
||||
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||
Signed-off-by: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
---
|
||||
src/uadk_pkey.c | 5 +----
|
||||
1 file changed, 1 insertion(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/uadk_pkey.c b/src/uadk_pkey.c
|
||||
index 14e0b8f..ceb7a8f 100644
|
||||
--- a/src/uadk_pkey.c
|
||||
+++ b/src/uadk_pkey.c
|
||||
@@ -184,9 +184,6 @@ static int uadk_e_wd_ecc_general_init(struct uacce_dev *dev,
|
||||
struct wd_ctx_config *ctx_cfg;
|
||||
int ret, i;
|
||||
|
||||
- if (ecc_res.ctx_res)
|
||||
- return 0;
|
||||
-
|
||||
ctx_cfg = calloc(1, sizeof(struct wd_ctx_config));
|
||||
if (!ctx_cfg)
|
||||
return -ENOMEM;
|
||||
@@ -256,7 +253,7 @@ static void uadk_wd_ecc_uninit(void)
|
||||
struct wd_ctx_config *ctx_cfg = ecc_res.ctx_res;
|
||||
int i, ret;
|
||||
|
||||
- if (!ctx_cfg)
|
||||
+ if (ecc_res.pid != getpid())
|
||||
return;
|
||||
|
||||
ret = uadk_e_is_env_enabled("ecc");
|
||||
--
|
||||
2.24.4
|
||||
|
||||
55
0029-ecc-cleanup-print-log.patch
Normal file
55
0029-ecc-cleanup-print-log.patch
Normal file
@ -0,0 +1,55 @@
|
||||
From a19b11343facb6ff073cb01bf3583c8bf6cbb009 Mon Sep 17 00:00:00 2001
|
||||
From: Weili Qian <qianweili@huawei.com>
|
||||
Date: Thu, 3 Mar 2022 03:08:45 +0000
|
||||
Subject: [PATCH 29/31] ecc: cleanup print log
|
||||
|
||||
print with '\n'
|
||||
|
||||
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||
---
|
||||
src/uadk_pkey.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/uadk_pkey.c b/src/uadk_pkey.c
|
||||
index ceb7a8f..216ccc3 100644
|
||||
--- a/src/uadk_pkey.c
|
||||
+++ b/src/uadk_pkey.c
|
||||
@@ -572,7 +572,7 @@ static int get_pkey_meths(ENGINE *e, EVP_PKEY_METHOD **pmeth,
|
||||
case EVP_PKEY_SM2:
|
||||
ret = uadk_sm2_create_pmeth(&pkey_meth);
|
||||
if (!ret) {
|
||||
- fprintf(stderr, "failed to register sm2 pmeth");
|
||||
+ fprintf(stderr, "failed to register sm2 pmeth.\n");
|
||||
return 0;
|
||||
}
|
||||
*pmeth = pkey_meth.sm2;
|
||||
@@ -580,7 +580,7 @@ static int get_pkey_meths(ENGINE *e, EVP_PKEY_METHOD **pmeth,
|
||||
case EVP_PKEY_EC:
|
||||
ret = uadk_ec_create_pmeth(&pkey_meth);
|
||||
if (!ret) {
|
||||
- fprintf(stderr, "failed to register ec pmeth");
|
||||
+ fprintf(stderr, "failed to register ec pmeth.\n");
|
||||
return 0;
|
||||
}
|
||||
*pmeth = pkey_meth.ec;
|
||||
@@ -588,7 +588,7 @@ static int get_pkey_meths(ENGINE *e, EVP_PKEY_METHOD **pmeth,
|
||||
case EVP_PKEY_X448:
|
||||
ret = uadk_x448_create_pmeth(&pkey_meth);
|
||||
if (!ret) {
|
||||
- fprintf(stderr, "failed to register x448 pmeth");
|
||||
+ fprintf(stderr, "failed to register x448 pmeth.\n");
|
||||
return 0;
|
||||
}
|
||||
*pmeth = pkey_meth.x448;
|
||||
@@ -596,7 +596,7 @@ static int get_pkey_meths(ENGINE *e, EVP_PKEY_METHOD **pmeth,
|
||||
case EVP_PKEY_X25519:
|
||||
ret = uadk_x25519_create_pmeth(&pkey_meth);
|
||||
if (!ret) {
|
||||
- fprintf(stderr, "failed to register x25519 pmeth");
|
||||
+ fprintf(stderr, "failed to register x25519 pmeth.\n");
|
||||
return 0;
|
||||
}
|
||||
*pmeth = pkey_meth.x25519;
|
||||
--
|
||||
2.24.4
|
||||
|
||||
218
0030-engine-fix-function-return-type.patch
Normal file
218
0030-engine-fix-function-return-type.patch
Normal file
@ -0,0 +1,218 @@
|
||||
From 26360660c516fe54b48502a3ca9eb1bbf47146d5 Mon Sep 17 00:00:00 2001
|
||||
From: Weili Qian <qianweili@huawei.com>
|
||||
Date: Thu, 3 Mar 2022 03:11:24 +0000
|
||||
Subject: [PATCH 30/31] engine: fix function return type
|
||||
|
||||
The async_register_poll_fn() is an internal
|
||||
function, and the probability of parameter
|
||||
error is low. If the parameter is wrong,
|
||||
a log will be printed, there is no need to
|
||||
return an error code. And 'MAX_ALG_SIZE' is
|
||||
chenged to 'ASYNC_TASK_MAX'.
|
||||
|
||||
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||
Signed-off-by: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
---
|
||||
src/uadk_async.c | 13 ++++++-------
|
||||
src/uadk_async.h | 5 +++--
|
||||
src/uadk_cipher.c | 9 ++++++---
|
||||
src/uadk_dh.c | 8 ++++++--
|
||||
src/uadk_digest.c | 9 ++++++---
|
||||
src/uadk_pkey.c | 8 ++++++--
|
||||
src/uadk_rsa.c | 8 ++++++--
|
||||
7 files changed, 39 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/src/uadk_async.c b/src/uadk_async.c
|
||||
index 5320ae6..c98153b 100644
|
||||
--- a/src/uadk_async.c
|
||||
+++ b/src/uadk_async.c
|
||||
@@ -22,11 +22,9 @@
|
||||
#include "uadk.h"
|
||||
#include "uadk_async.h"
|
||||
|
||||
-#define MAX_ALG_SIZE 6
|
||||
-
|
||||
static struct async_poll_queue poll_queue;
|
||||
|
||||
-static async_recv_t async_recv_func[MAX_ALG_SIZE];
|
||||
+static async_recv_t async_recv_func[ASYNC_TASK_MAX];
|
||||
|
||||
static void async_fd_cleanup(ASYNC_WAIT_CTX *ctx, const void *key,
|
||||
OSSL_ASYNC_FD readfd, void *custom)
|
||||
@@ -292,13 +290,14 @@ int async_wake_job(ASYNC_JOB *job)
|
||||
return ret;
|
||||
}
|
||||
|
||||
-int async_register_poll_fn(int type, async_recv_t func)
|
||||
+void async_register_poll_fn(int type, async_recv_t func)
|
||||
{
|
||||
- if (type < 0 || type >= MAX_ALG_SIZE)
|
||||
- return -1;
|
||||
+ if (type < 0 || type >= ASYNC_TASK_MAX) {
|
||||
+ fprintf(stderr, "alg type is error, type= %d.\n", type);
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
async_recv_func[type] = func;
|
||||
- return 0;
|
||||
}
|
||||
|
||||
static void *async_poll_process_func(void *args)
|
||||
diff --git a/src/uadk_async.h b/src/uadk_async.h
|
||||
index cbb4b62..9836dbb 100644
|
||||
--- a/src/uadk_async.h
|
||||
+++ b/src/uadk_async.h
|
||||
@@ -42,7 +42,8 @@ enum task_type {
|
||||
ASYNC_TASK_DIGEST,
|
||||
ASYNC_TASK_RSA,
|
||||
ASYNC_TASK_DH,
|
||||
- ASYNC_TASK_ECC
|
||||
+ ASYNC_TASK_ECC,
|
||||
+ ASYNC_TASK_MAX
|
||||
};
|
||||
|
||||
struct async_poll_task {
|
||||
@@ -66,7 +67,7 @@ struct async_poll_queue {
|
||||
extern int async_setup_async_event_notification(struct async_op *op);
|
||||
extern int async_clear_async_event_notification(void);
|
||||
extern int async_pause_job(void *ctx, struct async_op *op, enum task_type type, int id);
|
||||
-extern int async_register_poll_fn(int type, async_recv_t func);
|
||||
+extern void async_register_poll_fn(int type, async_recv_t func);
|
||||
extern void async_module_init(void);
|
||||
extern int async_wake_job(ASYNC_JOB *job);
|
||||
extern void async_free_poll_task(int id, bool is_cb);
|
||||
diff --git a/src/uadk_cipher.c b/src/uadk_cipher.c
|
||||
index 6e09a8c..8f8af7e 100644
|
||||
--- a/src/uadk_cipher.c
|
||||
+++ b/src/uadk_cipher.c
|
||||
@@ -550,8 +550,9 @@ static int uadk_e_wd_cipher_env_init(struct uacce_dev *dev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
- return async_register_poll_fn(ASYNC_TASK_CIPHER,
|
||||
- uadk_e_cipher_env_poll);
|
||||
+ async_register_poll_fn(ASYNC_TASK_CIPHER, uadk_e_cipher_env_poll);
|
||||
+
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static int uadk_e_wd_cipher_init(struct uacce_dev *dev)
|
||||
@@ -596,7 +597,9 @@ static int uadk_e_wd_cipher_init(struct uacce_dev *dev)
|
||||
if (ret)
|
||||
goto err_freectx;
|
||||
|
||||
- return async_register_poll_fn(ASYNC_TASK_CIPHER, uadk_e_cipher_poll);
|
||||
+ async_register_poll_fn(ASYNC_TASK_CIPHER, uadk_e_cipher_poll);
|
||||
+
|
||||
+ return 0;
|
||||
|
||||
err_freectx:
|
||||
for (j = 0; j < i; j++)
|
||||
diff --git a/src/uadk_dh.c b/src/uadk_dh.c
|
||||
index 989c9ec..40fb583 100644
|
||||
--- a/src/uadk_dh.c
|
||||
+++ b/src/uadk_dh.c
|
||||
@@ -296,7 +296,9 @@ static int uadk_e_wd_dh_env_init(struct uacce_dev *dev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
- return async_register_poll_fn(ASYNC_TASK_DH, uadk_e_dh_env_poll);
|
||||
+ async_register_poll_fn(ASYNC_TASK_DH, uadk_e_dh_env_poll);
|
||||
+
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static int uadk_e_wd_dh_init(struct dh_res_config *config, struct uacce_dev *dev)
|
||||
@@ -335,7 +337,9 @@ static int uadk_e_wd_dh_init(struct dh_res_config *config, struct uacce_dev *dev
|
||||
if (ret)
|
||||
goto free_ctx;
|
||||
|
||||
- return async_register_poll_fn(ASYNC_TASK_DH, uadk_e_dh_poll);
|
||||
+ async_register_poll_fn(ASYNC_TASK_DH, uadk_e_dh_poll);
|
||||
+
|
||||
+ return 0;
|
||||
|
||||
free_ctx:
|
||||
for (i = 0; i < CTX_NUM; i++) {
|
||||
diff --git a/src/uadk_digest.c b/src/uadk_digest.c
|
||||
index 5b843a0..ad24168 100644
|
||||
--- a/src/uadk_digest.c
|
||||
+++ b/src/uadk_digest.c
|
||||
@@ -374,8 +374,9 @@ static int uadk_e_wd_digest_env_init(struct uacce_dev *dev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
- return async_register_poll_fn(ASYNC_TASK_DIGEST,
|
||||
- uadk_e_digest_env_poll);
|
||||
+ async_register_poll_fn(ASYNC_TASK_DIGEST, uadk_e_digest_env_poll);
|
||||
+
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static int uadk_e_wd_digest_init(struct uacce_dev *dev)
|
||||
@@ -415,7 +416,9 @@ static int uadk_e_wd_digest_init(struct uacce_dev *dev)
|
||||
if (ret)
|
||||
goto err_freectx;
|
||||
|
||||
- return async_register_poll_fn(ASYNC_TASK_DIGEST, uadk_e_digest_poll);
|
||||
+ async_register_poll_fn(ASYNC_TASK_DIGEST, uadk_e_digest_poll);
|
||||
+
|
||||
+ return 0;
|
||||
|
||||
err_freectx:
|
||||
for (j = 0; j < i; j++)
|
||||
diff --git a/src/uadk_pkey.c b/src/uadk_pkey.c
|
||||
index 216ccc3..f27e2f5 100644
|
||||
--- a/src/uadk_pkey.c
|
||||
+++ b/src/uadk_pkey.c
|
||||
@@ -175,7 +175,9 @@ static int uadk_e_wd_ecc_env_init(struct uacce_dev *dev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
- return async_register_poll_fn(ASYNC_TASK_ECC, uadk_e_ecc_env_poll);
|
||||
+ async_register_poll_fn(ASYNC_TASK_ECC, uadk_e_ecc_env_poll);
|
||||
+
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static int uadk_e_wd_ecc_general_init(struct uacce_dev *dev,
|
||||
@@ -209,7 +211,9 @@ static int uadk_e_wd_ecc_general_init(struct uacce_dev *dev,
|
||||
if (ret)
|
||||
goto free_ctx;
|
||||
|
||||
- return async_register_poll_fn(ASYNC_TASK_ECC, uadk_ecc_poll);
|
||||
+ async_register_poll_fn(ASYNC_TASK_ECC, uadk_ecc_poll);
|
||||
+
|
||||
+ return 0;
|
||||
|
||||
free_ctx:
|
||||
for (i = 0; i < CTX_NUM; i++) {
|
||||
diff --git a/src/uadk_rsa.c b/src/uadk_rsa.c
|
||||
index f7755e3..c5d4dbb 100644
|
||||
--- a/src/uadk_rsa.c
|
||||
+++ b/src/uadk_rsa.c
|
||||
@@ -713,7 +713,9 @@ static int uadk_e_wd_rsa_env_init(struct uacce_dev *dev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
- return async_register_poll_fn(ASYNC_TASK_RSA, uadk_e_rsa_env_poll);
|
||||
+ async_register_poll_fn(ASYNC_TASK_RSA, uadk_e_rsa_env_poll);
|
||||
+
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static int uadk_e_wd_rsa_init(struct rsa_res_config *config,
|
||||
@@ -753,7 +755,9 @@ static int uadk_e_wd_rsa_init(struct rsa_res_config *config,
|
||||
if (ret)
|
||||
goto free_ctx;
|
||||
|
||||
- return async_register_poll_fn(ASYNC_TASK_RSA, uadk_e_rsa_poll);
|
||||
+ async_register_poll_fn(ASYNC_TASK_RSA, uadk_e_rsa_poll);
|
||||
+
|
||||
+ return 0;
|
||||
|
||||
free_ctx:
|
||||
for (i = 0; i < CTX_NUM; i++) {
|
||||
--
|
||||
2.24.4
|
||||
|
||||
30
0031-rsa-fixup-about-the-wrong-copy.patch
Normal file
30
0031-rsa-fixup-about-the-wrong-copy.patch
Normal file
@ -0,0 +1,30 @@
|
||||
From 2c99863001cbb39838d983d76171ac131930c310 Mon Sep 17 00:00:00 2001
|
||||
From: Weili Qian <qianweili@huawei.com>
|
||||
Date: Thu, 3 Mar 2022 03:25:03 +0000
|
||||
Subject: [PATCH 31/31] rsa: fixup about the wrong copy
|
||||
|
||||
The pointer of 'req.src' is NULL, and the
|
||||
direct memcpy operation will fail. Therefore,
|
||||
delete the memcpy and assign a value directly later.
|
||||
|
||||
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
||||
Signed-off-by: Zhiqi Song <songzhiqi1@huawei.com>
|
||||
---
|
||||
src/uadk_rsa.c | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/src/uadk_rsa.c b/src/uadk_rsa.c
|
||||
index c5d4dbb..1488b98 100644
|
||||
--- a/src/uadk_rsa.c
|
||||
+++ b/src/uadk_rsa.c
|
||||
@@ -902,7 +902,6 @@ static int rsa_fill_pubkey(struct rsa_pubkey_param *pubkey_param,
|
||||
if (!rsa_sess->is_pubkey_ready) {
|
||||
wd_rsa_get_pubkey(rsa_sess->sess, &pubkey);
|
||||
wd_rsa_get_pubkey_params(pubkey, &wd_e, &wd_n);
|
||||
- memcpy(rsa_sess->req.src, in_buf, rsa_sess->req.src_bytes);
|
||||
wd_e->dsize = BN_bn2bin(pubkey_param->e,
|
||||
(unsigned char *)wd_e->data);
|
||||
wd_n->dsize = BN_bn2bin(pubkey_param->n,
|
||||
--
|
||||
2.24.4
|
||||
|
||||
164
0032-README-modify-the-engine-id-name.patch
Normal file
164
0032-README-modify-the-engine-id-name.patch
Normal file
@ -0,0 +1,164 @@
|
||||
From a476a9881ed143f16eb579f3a34446ea24cb20f8 Mon Sep 17 00:00:00 2001
|
||||
From: Kai Ye <yekai13@huawei.com>
|
||||
Date: Fri, 4 Mar 2022 14:44:07 +0800
|
||||
Subject: [PATCH 32/32] README: modify the engine id name
|
||||
|
||||
The new engine id name is 'uadk_engine'. So need to update
|
||||
the README.
|
||||
|
||||
Signed-off-by: Kai Ye <yekai13@huawei.com>
|
||||
---
|
||||
README | 98 +++++++++++++++++++++++++++++-----------------------------
|
||||
1 file changed, 49 insertions(+), 49 deletions(-)
|
||||
|
||||
diff --git a/README b/README
|
||||
index e02de8f..562a859 100644
|
||||
--- a/README
|
||||
+++ b/README
|
||||
@@ -67,60 +67,60 @@ Testing
|
||||
```
|
||||
1. Cipher
|
||||
```
|
||||
-openssl enc -aes-128-cbc -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -aes-128-cbc -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -aes-192-cbc -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -aes-192-cbc -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -aes-256-cbc -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -aes-256-cbc -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -aes-128-ecb -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -aes-128-ecb -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -aes-192-ecb -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -aes-192-ecb -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -aes-256-ecb -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -aes-256-ecb -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -aes-128-ctr -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -aes-128-ctr -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -aes-192-ctr -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -aes-192-ctr -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -aes-256-ctr -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -aes-256-ctr -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -sm4-cbc -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -sm4-cbc -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -sm4-ecb -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -sm4-ecb -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -des-ede3-cbc -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -des-ede3-cbc -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -des-ede3-ecb -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl enc -des-ede3-ecb -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk -p
|
||||
-openssl speed -engine uadk -async_jobs 1 -evp aes-128-cbc
|
||||
-openssl speed -engine uadk -async_jobs 1 -evp sm4-cbc
|
||||
-openssl speed -engine uadk -async_jobs 1 -evp des-ede3-cbc
|
||||
+openssl enc -aes-128-cbc -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -aes-128-cbc -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -aes-192-cbc -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -aes-192-cbc -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -aes-256-cbc -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -aes-256-cbc -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -aes-128-ecb -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -aes-128-ecb -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -aes-192-ecb -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -aes-192-ecb -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -aes-256-ecb -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -aes-256-ecb -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -aes-128-ctr -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -aes-128-ctr -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -aes-192-ctr -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -aes-192-ctr -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -aes-256-ctr -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -aes-256-ctr -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -sm4-cbc -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -sm4-cbc -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -sm4-ecb -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -sm4-ecb -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -des-ede3-cbc -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -des-ede3-cbc -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -des-ede3-ecb -a -in data -out data.en -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl enc -des-ede3-ecb -a -d -in data.en -out data.de -pass pass:123456 -K abc -iv abc -engine uadk_engine -p
|
||||
+openssl speed -engine uadk_engine -async_jobs 1 -evp aes-128-cbc
|
||||
+openssl speed -engine uadk_engine -async_jobs 1 -evp sm4-cbc
|
||||
+openssl speed -engine uadk_engine -async_jobs 1 -evp des-ede3-cbc
|
||||
```
|
||||
2. RSA
|
||||
```
|
||||
-openssl genrsa -out prikey.pem -engine uadk 2048
|
||||
-openssl rsa -in prikey.pem -pubout -out pubkey.pem -engine uadk
|
||||
-openssl rsautl -encrypt -in plain.txt -inkey pubkey.pem -pubin -out enc.txt -engine uadk
|
||||
-openssl rsautl -decrypt -in enc.txt -inkey prikey.pem -out dec.txt -engine uadk
|
||||
-openssl rsautl -sign -in msg.txt -inkey prikey.pem -out signed.txt -engine uadk
|
||||
-openssl rsautl -verify -in signed.txt -inkey pubkey.pem -pubin -out verified.txt -engine uadk
|
||||
-openssl speed -elapsed -engine uadk rsa2048
|
||||
-openssl speed -elapsed -engine uadk -async_jobs 10 rsa2048
|
||||
+openssl genrsa -out prikey.pem -engine uadk_engine 2048
|
||||
+openssl rsa -in prikey.pem -pubout -out pubkey.pem -engine uadk_engine
|
||||
+openssl rsautl -encrypt -in plain.txt -inkey pubkey.pem -pubin -out enc.txt -engine uadk_engine
|
||||
+openssl rsautl -decrypt -in enc.txt -inkey prikey.pem -out dec.txt -engine uadk_engine
|
||||
+openssl rsautl -sign -in msg.txt -inkey prikey.pem -out signed.txt -engine uadk_engine
|
||||
+openssl rsautl -verify -in signed.txt -inkey pubkey.pem -pubin -out verified.txt -engine uadk_engine
|
||||
+openssl speed -elapsed -engine uadk_engine rsa2048
|
||||
+openssl speed -elapsed -engine uadk_engine -async_jobs 10 rsa2048
|
||||
```
|
||||
3. SM3
|
||||
```
|
||||
-openssl sm3 -engine uadk data
|
||||
+openssl sm3 -engine uadk_engine data
|
||||
```
|
||||
4. MD5
|
||||
```
|
||||
-openssl speed -engine uadk -async_jobs 1 -evp md5
|
||||
+openssl speed -engine uadk_engine -async_jobs 1 -evp md5
|
||||
```
|
||||
5. SHA
|
||||
```
|
||||
-openssl sha1 -engine uadk data
|
||||
-openssl sha256 -engine uadk data
|
||||
-openssl sha512 -engine uadk data
|
||||
+openssl sha1 -engine uadk_engine data
|
||||
+openssl sha256 -engine uadk_engine data
|
||||
+openssl sha512 -engine uadk_engine data
|
||||
```
|
||||
6. DH
|
||||
|
||||
@@ -142,9 +142,9 @@ openssl pkey -in privatekey2.pem -pubout -out publickey2.pem -engine uadk
|
||||
[step 4] After exchanging public key, each user can derive the shared secret:
|
||||
```
|
||||
openssl pkeyutl -derive -inkey privatekey1.pem -peerkey publickey2.pem -out
|
||||
-secret1.bin -engine uadk
|
||||
+secret1.bin -engine uadk_engine
|
||||
openssl pkeyutl -derive -inkey privatekey2.pem -peerkey publickey1.pem -out
|
||||
-secret2.bin -engine uadk
|
||||
+secret2.bin -engine uadk_engine
|
||||
```
|
||||
[step 5] Check secret1.bin and secret2.bin:
|
||||
```
|
||||
@@ -156,15 +156,15 @@ secret1.bin and secret2.bin should be the same.
|
||||
|
||||
7. SM2
|
||||
```
|
||||
-openssl speed -elapsed -engine uadk sm2
|
||||
-openssl speed -elapsed -engine uadk -async_jobs 1 sm2
|
||||
+openssl speed -elapsed -engine uadk_engine sm2
|
||||
+openssl speed -elapsed -engine uadk_engine -async_jobs 1 sm2
|
||||
openssl ecparam -genkey -name SM2 -out SM2PrivateKey.pem
|
||||
openssl ec -in SM2PrivateKey.pem -pubout -out SM2PublicKey.pem
|
||||
```
|
||||
8. ECDSA
|
||||
```
|
||||
-openssl speed -elapsed -engine uadk ecdsap256
|
||||
-openssl speed -elapsed -engine uadk -async_jobs 1 ecdsap256
|
||||
+openssl speed -elapsed -engine uadk_engine ecdsap256
|
||||
+openssl speed -elapsed -engine uadk_engine -async_jobs 1 ecdsap256
|
||||
```
|
||||
|
||||
Environment variable of uadk engine
|
||||
@@ -184,7 +184,7 @@ openssl_cnf = openssl_def
|
||||
[openssl_def]
|
||||
engines = engine_section
|
||||
[engine_section]
|
||||
-uadk = uadk_section
|
||||
+uadk_engine = uadk_section
|
||||
[uadk_section]
|
||||
UADK_CMD_ENABLE_RSA_ENV = 1
|
||||
UADK_CMD_ENABLE_DH_ENV = 1
|
||||
--
|
||||
2.24.4
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
Name: uadk_engine
|
||||
Summary: UADK Accelerator Engine
|
||||
Version: 1.0.0
|
||||
Release: 4
|
||||
Release: 5
|
||||
License: Apache-2.0
|
||||
Source: %{name}-%{version}.tar.gz
|
||||
ExclusiveOS: linux
|
||||
@ -39,6 +39,15 @@ Patch0020: 0020-rsa-fixup-a-code-check-warning.patch
|
||||
Patch0021: 0021-cipher-delete-a-redundant-branch.patch
|
||||
Patch0022: 0022-engine-fix-engine-can-t-work-under-hybrid-mode.patch
|
||||
Patch0023: 0023-engine-add-the-kae-log-feature.patch
|
||||
Patch0024: 0024-rsa-fix-interface-name.patch
|
||||
Patch0025: 0025-ecc-cleanup-sm2-unreachable-code.patch
|
||||
Patch0026: 0026-rsa-cleanup-of-code-style.patch
|
||||
Patch0027: 0027-v1-fixup-about-uninitialized-variable.patch
|
||||
Patch0028: 0028-ecc-fix-checking-conditions.patch
|
||||
Patch0029: 0029-ecc-cleanup-print-log.patch
|
||||
Patch0030: 0030-engine-fix-function-return-type.patch
|
||||
Patch0031: 0031-rsa-fixup-about-the-wrong-copy.patch
|
||||
Patch0032: 0032-README-modify-the-engine-id-name.patch
|
||||
|
||||
%description
|
||||
This package contains the UADK Accelerator Engine
|
||||
@ -88,6 +97,9 @@ fi
|
||||
/sbin/ldconfig
|
||||
|
||||
%changelog
|
||||
* Thu Mar 3 2022 linwenkai <linwenkai6@hisilicon.com> 1.0.0-5
|
||||
- Backport uadk engine patch for v1.0.0
|
||||
|
||||
* Mon Feb 21 2022 linwenkai <linwenkai6@hisilicon.com> 1.0.0-4
|
||||
- Backport uadk engine patch for v1.0.0
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user