libwd/0049-hisi-sec-delete-some-dummy-parameter-checking.patch
Yang Shen aa2d7cce3f libwd: backport for uadk from 2.3.24 to 2.3.27
Update some patch for uadk from mainline.
To get more infomation, please visit the homepage:
https://github.com/Linaro/uadk

Signed-off-by: Yang Shen <shenyang39@huawei.com>
2022-02-21 06:32:14 +00:00

120 lines
3.2 KiB
Diff

From 7d208baa2ea3b3adb161683e9e2446dd01ae14a0 Mon Sep 17 00:00:00 2001
From: Kai Ye <yekai13@huawei.com>
Date: Thu, 27 Jan 2022 10:16:59 +0800
Subject: [PATCH 53/53] hisi-sec: delete some dummy parameter checking
1. If an error is detected, the system exits rather than
continues. here is fix it.
2. Due to the auth length checking logic same as the api
layer. So this code is reduntant and needs to be deleted.
Signed-off-by: Kai Ye <yekai13@huawei.com>
---
drv/hisi_sec.c | 56 +++++++++++++++++---------------------------------
1 file changed, 19 insertions(+), 37 deletions(-)
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c
index 14656c8..61e0698 100644
--- a/drv/hisi_sec.c
+++ b/drv/hisi_sec.c
@@ -1618,6 +1618,17 @@ static int aead_get_aes_key_len(struct wd_aead_msg *msg, __u8 *key_len)
return 0;
}
+static int aead_bd_msg_check(struct wd_aead_msg *msg)
+{
+ if (unlikely(msg->akey_bytes & WORD_ALIGNMENT_MASK)) {
+ WD_ERR("failed to check aead auth key bytes, size = %u\n",
+ msg->akey_bytes);
+ return -WD_EINVAL;
+ }
+
+ return 0;
+}
+
static int fill_aead_bd2_alg(struct wd_aead_msg *msg,
struct hisi_sec_sqe *sqe)
{
@@ -1633,26 +1644,19 @@ static int fill_aead_bd2_alg(struct wd_aead_msg *msg,
break;
default:
WD_ERR("failed to check aead calg type, calg = %u\n", msg->calg);
- ret = -WD_EINVAL;
+ return -WD_EINVAL;
}
/* CCM/GCM this region is set to 0 */
- if (msg->cmode == WD_CIPHER_CCM ||
- msg->cmode == WD_CIPHER_GCM)
+ if (msg->cmode == WD_CIPHER_CCM || msg->cmode == WD_CIPHER_GCM)
return ret;
- if (unlikely(msg->auth_bytes & WORD_ALIGNMENT_MASK)) {
- WD_ERR("failed to check aead auth_bytes, size = %u\n",
- msg->auth_bytes);
- return -WD_EINVAL;
- }
sqe->type2.mac_key_alg = msg->auth_bytes / WORD_BYTES;
- if (unlikely(msg->akey_bytes & WORD_ALIGNMENT_MASK)) {
- WD_ERR("failed to check aead auth key bytes, size = %u\n",
- msg->akey_bytes);
- return -WD_EINVAL;
- }
+ ret = aead_bd_msg_check(msg);
+ if (ret)
+ return ret;
+
sqe->type2.mac_key_alg |= (__u32)(msg->akey_bytes /
WORD_BYTES) << MAC_LEN_OFFSET;
@@ -1957,28 +1961,6 @@ static struct wd_aead_driver hisi_aead_driver = {
WD_AEAD_SET_DRIVER(hisi_aead_driver);
-static int aead_bd3_msg_check(struct wd_aead_msg *msg)
-{
- if (unlikely(!msg->in_bytes)) {
- WD_ERR("failed to check aead in_bytes 0 length!\n");
- return -WD_EINVAL;
- }
-
- if (unlikely(msg->auth_bytes & WORD_ALIGNMENT_MASK)) {
- WD_ERR("failed to check aead auth_bytes, size = %u\n",
- msg->auth_bytes);
- return -WD_EINVAL;
- }
-
- if (unlikely(msg->akey_bytes & WORD_ALIGNMENT_MASK)) {
- WD_ERR("failed to check aead auth key bytes, size = %u\n",
- msg->akey_bytes);
- return -WD_EINVAL;
- }
-
- return 0;
-}
-
static int fill_aead_bd3_alg(struct wd_aead_msg *msg,
struct hisi_sec_sqe3 *sqe)
{
@@ -1998,14 +1980,14 @@ static int fill_aead_bd3_alg(struct wd_aead_msg *msg,
break;
default:
WD_ERR("failed to check aead calg type, calg = %u\n", msg->calg);
- ret = -WD_EINVAL;
+ return -WD_EINVAL;
}
/* CCM/GCM this region is set to 0 */
if (msg->cmode == WD_CIPHER_CCM || msg->cmode == WD_CIPHER_GCM)
return ret;
- ret = aead_bd3_msg_check(msg);
+ ret = aead_bd_msg_check(msg);
if (ret)
return ret;
--
2.25.1