lkml.org 
[lkml]   [2022]   [Aug]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.15 373/779] crypto: hisilicon/sec - fix auth key size error
    Date
    From: Kai Ye <yekai13@huawei.com>

    [ 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 | 6 +++---
    drivers/crypto/hisilicon/sec2/sec_crypto.h | 1 +
    2 files changed, 4 insertions(+), 3 deletions(-)

    diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c
    index 36c789ff1bd4..0d26eda36a52 100644
    --- a/drivers/crypto/hisilicon/sec2/sec_crypto.c
    +++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c
    @@ -617,7 +617,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;
    @@ -629,8 +629,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);
    }

    diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.h b/drivers/crypto/hisilicon/sec2/sec_crypto.h
    index 9f71c358a6d3..ee2edaf5058d 100644
    --- a/drivers/crypto/hisilicon/sec2/sec_crypto.h
    +++ b/drivers/crypto/hisilicon/sec2/sec_crypto.h
    @@ -7,6 +7,7 @@
    #define SEC_AIV_SIZE 12
    #define SEC_IV_SIZE 24
    #define SEC_MAX_KEY_SIZE 64
    +#define SEC_MAX_AKEY_SIZE 128
    #define SEC_COMM_SCENE 0
    #define SEC_MIN_BLOCK_SZ 1

    --
    2.35.1


    \
     
     \ /
      Last update: 2022-08-15 21:04    [W:4.674 / U:0.248 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site