]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
crypto: hisilicon/sec - fix auth key size error
authorKai Ye <yekai13@huawei.com>
Thu, 21 Jul 2022 02:18:31 +0000 (10:18 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 21 Aug 2022 13:15:50 +0000 (15:15 +0200)
[ Upstream commit 45f5d0176d8426cc1ab0bab84fbd8ef5c57526c6 ]

The authentication algorithm supports a maximum of 128-byte keys.
The allocated key memory is insufficient.

Fixes: 2f072d75d1ab ("crypto: hisilicon - Add aead support on SEC2")
Signed-off-by: Kai Ye <yekai13@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/crypto/hisilicon/sec2/sec_crypto.c
drivers/crypto/hisilicon/sec2/sec_crypto.h

index 39d2af84d9531582addc098ca7e1844e69a8d674..2dbec638cca83ba9232c220b035f15ef77b66b01 100644 (file)
@@ -516,7 +516,7 @@ static int sec_auth_init(struct sec_ctx *ctx)
 {
        struct sec_auth_ctx *a_ctx = &ctx->a_ctx;
 
-       a_ctx->a_key = dma_alloc_coherent(ctx->dev, SEC_MAX_KEY_SIZE,
+       a_ctx->a_key = dma_alloc_coherent(ctx->dev, SEC_MAX_AKEY_SIZE,
                                          &a_ctx->a_key_dma, GFP_KERNEL);
        if (!a_ctx->a_key)
                return -ENOMEM;
@@ -528,8 +528,8 @@ static void sec_auth_uninit(struct sec_ctx *ctx)
 {
        struct sec_auth_ctx *a_ctx = &ctx->a_ctx;
 
-       memzero_explicit(a_ctx->a_key, SEC_MAX_KEY_SIZE);
-       dma_free_coherent(ctx->dev, SEC_MAX_KEY_SIZE,
+       memzero_explicit(a_ctx->a_key, SEC_MAX_AKEY_SIZE);
+       dma_free_coherent(ctx->dev, SEC_MAX_AKEY_SIZE,
                          a_ctx->a_key, a_ctx->a_key_dma);
 }
 
index 1db2ae4b7b66ecc50b42645f3c03cefef8c14320..20f11e5bbf1d5aad7aee129381e3f428b6e431a6 100644 (file)
@@ -6,6 +6,7 @@
 
 #define SEC_IV_SIZE            24
 #define SEC_MAX_KEY_SIZE       64
+#define SEC_MAX_AKEY_SIZE      128
 #define SEC_COMM_SCENE         0
 
 enum sec_calg {