Skip to content

Commit 1b284ff

Browse files
lin755herbertx
authored andcommitted
crypto: hisilicon/sec2 - fix for aead auth key length
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: 2f072d7 ("crypto: hisilicon - Add aead support on SEC2") Signed-off-by: Wenkai Lin <[email protected]> Signed-off-by: Chenghai Huang <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent d454874 commit 1b284ff

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

drivers/crypto/hisilicon/sec2/sec_crypto.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,11 +1090,6 @@ static int sec_aead_auth_set_key(struct sec_auth_ctx *ctx,
10901090
struct crypto_shash *hash_tfm = ctx->hash_tfm;
10911091
int blocksize, digestsize, ret;
10921092

1093-
if (!keys->authkeylen) {
1094-
pr_err("hisi_sec2: aead auth key error!\n");
1095-
return -EINVAL;
1096-
}
1097-
10981093
blocksize = crypto_shash_blocksize(hash_tfm);
10991094
digestsize = crypto_shash_digestsize(hash_tfm);
11001095
if (keys->authkeylen > blocksize) {
@@ -1106,7 +1101,8 @@ static int sec_aead_auth_set_key(struct sec_auth_ctx *ctx,
11061101
}
11071102
ctx->a_key_len = digestsize;
11081103
} else {
1109-
memcpy(ctx->a_key, keys->authkey, keys->authkeylen);
1104+
if (keys->authkeylen)
1105+
memcpy(ctx->a_key, keys->authkey, keys->authkeylen);
11101106
ctx->a_key_len = keys->authkeylen;
11111107
}
11121108

0 commit comments

Comments
 (0)