]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crypto: hisilicon/sec2 - fix for aead auth key length
authorWenkai Lin <linwenkai6@hisilicon.com>
Wed, 5 Feb 2025 03:56:26 +0000 (11:56 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 22 Feb 2025 07:56:02 +0000 (15:56 +0800)
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>
drivers/crypto/hisilicon/sec2/sec_crypto.c

index 66bc07da9eb6f7ae3983991505f3f954219c4e31..472c5c52bf3da2c3a87c278058e0219cf5183862 100644 (file)
@@ -1090,11 +1090,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) {
@@ -1106,7 +1101,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;
        }