提交 bf0f3171 编写于 作者: G GUO Zihua 提交者: Zheng Zengkai

crypto: crct10dif-neon - fix use via crypto_shash_digest()

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I569U8
CVE: NA

Reference: https://lore.kernel.org/lkml/20190609164147.971147667@linuxfoundation.org/

--------------------------------

The digest() hook relies on a crc value from the shash_desc context.
However, this context is not initialized while digest() hook is called,
and an arbitrary value is read causing the algorithm generating wrong
result.

This patch fixes this issue by passing a 0 as the initial crc value in
the digest() hook.
Signed-off-by: NGUO Zihua <guozihua@huawei.com>
Reviewed-by: NYue Haibing <yuehaibing@huawei.com>
Reviewed-by: NWang Weiyang <wangweiyang2@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 e7cad015
......@@ -55,10 +55,10 @@ static int chksum_final(struct shash_desc *desc, u8 *out)
return 0;
}
static int __chksum_finup(__u16 *crcp, const u8 *data, unsigned int len,
static int __chksum_finup(__u16 crc, const u8 *data, unsigned int len,
u8 *out)
{
*(__u16 *)out = crc_t10dif_neon(*crcp, data, len);
*(__u16 *)out = crc_t10dif_neon(crc, data, len);
return 0;
}
......@@ -67,15 +67,13 @@ static int chksum_finup(struct shash_desc *desc, const u8 *data,
{
struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
return __chksum_finup(&ctx->crc, data, len, out);
return __chksum_finup(ctx->crc, data, len, out);
}
static int chksum_digest(struct shash_desc *desc, const u8 *data,
unsigned int length, u8 *out)
{
struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
return __chksum_finup(&ctx->crc, data, length, out);
return __chksum_finup(0, data, length, out);
}
static struct shash_alg alg = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册