summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorWenkai Lin <linwenkai6@hisilicon.com>2025-02-05 11:56:26 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-04-10 14:33:35 +0200
commitd5c51c6445f806b53f168dd882bce71d3945dd0b (patch)
tree34a092367c1b90e6fc91d0ba2f1804f12823639c /drivers
parentd224ed6e90e25479a3d31ad4a0da3d7810ccd248 (diff)
downloadlinux-d5c51c6445f806b53f168dd882bce71d3945dd0b.tar.gz
linux-d5c51c6445f806b53f168dd882bce71d3945dd0b.tar.bz2
linux-d5c51c6445f806b53f168dd882bce71d3945dd0b.zip
crypto: hisilicon/sec2 - fix for aead auth key length
[ Upstream commit 1b284ffc30b02808a0de698667cbcf5ce5f9144e ] According to the HMAC RFC, the authentication key can be 0 bytes, and the hardware can handle this scenario. Therefore, remove the incorrect validation for this case. Fixes: 2f072d75d1ab ("crypto: hisilicon - Add aead support on SEC2") Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com> Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/crypto/hisilicon/sec2/sec_crypto.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c
index 3de8715aad39..292ab0ff2b07 100644
--- a/drivers/crypto/hisilicon/sec2/sec_crypto.c
+++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c
@@ -1094,11 +1094,6 @@ static int sec_aead_auth_set_key(struct sec_auth_ctx *ctx,
struct crypto_shash *hash_tfm = ctx->hash_tfm;
int blocksize, digestsize, ret;
- if (!keys->authkeylen) {
- pr_err("hisi_sec2: aead auth key error!\n");
- return -EINVAL;
- }
-
blocksize = crypto_shash_blocksize(hash_tfm);
digestsize = crypto_shash_digestsize(hash_tfm);
if (keys->authkeylen > blocksize) {
@@ -1110,7 +1105,8 @@ static int sec_aead_auth_set_key(struct sec_auth_ctx *ctx,
}
ctx->a_key_len = digestsize;
} else {
- memcpy(ctx->a_key, keys->authkey, keys->authkeylen);
+ if (keys->authkeylen)
+ memcpy(ctx->a_key, keys->authkey, keys->authkeylen);
ctx->a_key_len = keys->authkeylen;
}