1 Star 0 Fork 18

Younger/libwd

forked from src-openEuler/libwd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0025-hisi-sec-bugfix-for-out_bytes-checking.patch 1.50 KB
一键复制 编辑 原始数据 按行查看 历史
From 5927f19669247d738dfd4a687b5f134a2d289784 Mon Sep 17 00:00:00 2001
From: Kai Ye <yekai13@huawei.com>
Date: Wed, 29 Dec 2021 17:14:11 +0800
Subject: [PATCH 27/28] hisi-sec: bugfix for out_bytes checking
1. Add out_bytes checking for digest alg. and modify some log
information.
2. Optimize the in_bytes length checking.
Signed-off-by: Kai Ye <yekai13@huawei.com>
---
drv/hisi_sec.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c
index 603bdda..d31a1b9 100644
--- a/drv/hisi_sec.c
+++ b/drv/hisi_sec.c
@@ -1279,9 +1279,9 @@ static void parse_digest_bd2(struct hisi_sec_sqe *sqe, struct wd_digest_msg *rec
static int digest_long_bd_check(struct wd_digest_msg *msg)
{
- if (msg->alg >= WD_DIGEST_SHA512 && msg->in_bytes % SHA512_ALIGN_SZ)
+ if (msg->alg >= WD_DIGEST_SHA512 && msg->in_bytes & (SHA512_ALIGN_SZ - 1))
return -WD_EINVAL;
- else if (msg->in_bytes % SHA1_ALIGN_SZ)
+ else if (msg->in_bytes & (SHA1_ALIGN_SZ - 1))
return -WD_EINVAL;
return 0;
@@ -1298,7 +1298,12 @@ static int digest_len_check(struct wd_digest_msg *msg, enum sec_bd_type type)
}
if (unlikely(msg->in_bytes > MAX_INPUT_DATA_LEN)) {
- WD_ERR("input data length is too long, size:%u!\n", msg->in_bytes);
+ WD_ERR("digest input length is too long, size:%u!\n", msg->in_bytes);
+ return -WD_EINVAL;
+ }
+
+ if (unlikely(msg->out_bytes & WORD_ALIGNMENT_MASK)) {
+ WD_ERR("digest out length is error, size:%u!\n", msg->out_bytes);
return -WD_EINVAL;
}
--
2.31.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/aichixxbg/libwd.git
git@gitee.com:aichixxbg/libwd.git
aichixxbg
libwd
libwd
master

搜索帮助