From patchwork Thu Sep 21 12:42:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaurav Jain X-Patchwork-Id: 724927 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 675D4E7D0AA for ; Thu, 21 Sep 2023 21:16:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232667AbjIUVQH (ORCPT ); Thu, 21 Sep 2023 17:16:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233228AbjIUVP2 (ORCPT ); Thu, 21 Sep 2023 17:15:28 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on0614.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0e::614]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D75061713; Thu, 21 Sep 2023 10:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NXvsGFIDhJiTgxsX0PpE8J/lhq1tyHC41fb19oDJjj4qm2zFfyMuUNBNTDYa0GKfQSK/Ydd0PExXjMlIZxceIQ8Me8Q7tvzs6tHgTqmLLG72PSwG2KIWAxWh2ivJnDlGqwl+v9sa4ip/ErwXuWU2FWtooHm9OYRKG8QqobRhm/C97c5dHl4v1f9V0jSUPqqOyBFVau+Am3doenfWiZiGPY1arAo8y2NAIPPaONz6uLyd9JFly0GSG9Q4uCeEKcjtwTpl2WvGcjMnIUj3ECv93pfmyPk8+zjeBYmHo2kCwoubo+kkojLmU5YiRoTMxQa6iWYwnNhzgQiWlEXERNidXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=44kUePCEurOOgwMYy/g7ZeaiQvugDdzWMXCOBAU9FXc=; b=gzFSPMxTYrIHUzLhKDOO9nHDJV2idBfSIEl0LmMH1ans48GpQMZ7bEIbDY92HHGoVGldGvCJhy9Po3F/HMZtcpX0/zH5toG0aoBrSb7G/uPmskiqz/rbFysZeIvFUkwGBJyL3oWJlMXEVQxs/bHeyeU6fQDMTtkrpcxQtTtW+nSrtT8H5Nq4OLCSF5mEdmWEOV5uYAQb1OgBND+iSerQ9W0LkKDrncbjXwOEMM+7LxY++Li+BsDtHPSf5N3DSeJaQnAefJ6HcDAufNSTYdY6ItXA3pdFj4dgVxyG1I+k98fmmU0OGcB1YrGNnR9N2dFqypqyknhghbjE5/+d6IoHQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=44kUePCEurOOgwMYy/g7ZeaiQvugDdzWMXCOBAU9FXc=; b=KhD1rXPWKK+Ru+lheGKutFuCSmkgvKPy/d4OtGol7qgt/y6xTzYGTSZyOAkf8Kkv2Kt8gvq5TNnfU8gIFP0qXcvLSRwnEDrQcfECrNgGX/4aw8WPT4Kb+86lrV8ZPH0qlhmRvdEwH5Ep05OOrfsgGOdni7OwgX3zIKl/fwLm1HQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6004.eurprd04.prod.outlook.com (2603:10a6:208:11a::11) by DB9PR04MB9776.eurprd04.prod.outlook.com (2603:10a6:10:4f0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Thu, 21 Sep 2023 12:43:01 +0000 Received: from AM0PR04MB6004.eurprd04.prod.outlook.com ([fe80::86b7:e0cc:dd24:12c0]) by AM0PR04MB6004.eurprd04.prod.outlook.com ([fe80::86b7:e0cc:dd24:12c0%7]) with mapi id 15.20.6813.017; Thu, 21 Sep 2023 12:43:01 +0000 From: Gaurav Jain To: Horia Geanta , Pankaj Gupta , Varun Sethi , Meenakshi Aggarwal , Herbert Xu , "David S . Miller" , Aisheng Dong Cc: Silvano Di Ninno , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com, Gaurav Jain Subject: [PATCH] crypto: caam/jr - fix Chacha20 + Poly1305 self test failure Date: Thu, 21 Sep 2023 18:12:37 +0530 Message-Id: <20230921124237.2364827-1-gaurav.jain@nxp.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: SG2PR01CA0176.apcprd01.prod.exchangelabs.com (2603:1096:4:28::32) To AM0PR04MB6004.eurprd04.prod.outlook.com (2603:10a6:208:11a::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6004:EE_|DB9PR04MB9776:EE_ X-MS-Office365-Filtering-Correlation-Id: dc573aea-51c0-4f49-264d-08dbbaa049e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CdHgm64dgOns7JEY14Sbpn7OjUzCciwH/Q+DkU2sZLrNDpCpHxcdWYjTCkYVJGMMrLTYEfAo/BbbVPQCm2pU0wpfksS4MYUAA37m0oVM49jlkr16aLgGT6KI+HzdNNINUYXdPIalfGHOSD44xvRZdKmIZ5eZJxM1rKKBBS04lHuR2HZ95jCPa9AuxtkZI8o0SyOFZ+PAr3itko997Emu+57KjRHIouFB/Csr6XtayaRL3z4JYGFtViXk0s6/xPa/KjcM0DNX31de0HxR0OhvzFSh0N5JtEO67fANKWi12+wWXJzVAKJPrlSLmwe2Phxcid2w3Hi2RgJdDPDap0QocF9e3aJGVAFsYRGESVgHAQsBW7ALj6vBC5xBzajPYU/qXF5WgBJOHJhB4lvPDI8+812zsbp5NzhO5OGWXDbzJKjIcwMBdq0NRVxEZXWkvdWCV4ubCfFdIPjfRMItDOVcnEXqb9HA6l/hnMYC6/Z8XSuFHWH/1gIa8Ong/Jir4TJwAtr86PIlPXhAY/mVvusjgI1QyNguS1z2nna985NTTKXmD155fYNq3UrZ9tW7mF23xrLQE93wP/Y0eCQ5iGYBE4k22Z3kxUs6vI5NKIs0DD9aAYAnwosr0l6oGEtEg06B X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB6004.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(396003)(39860400002)(136003)(346002)(366004)(376002)(1800799009)(186009)(451199024)(52116002)(6512007)(6486002)(6506007)(6666004)(83380400001)(38100700002)(86362001)(38350700002)(36756003)(2616005)(1076003)(26005)(4744005)(110136005)(66476007)(6636002)(54906003)(316002)(66556008)(66946007)(41300700001)(2906002)(44832011)(5660300002)(8936002)(8676002)(4326008)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pxGTBpdEb9uwCgiKKmXtgcx2Cx5oS8NqQp8uEX0jWDsKKgUN42HymCmjxuBGZBvd5S90DVUOwndCOFaYgWY0yNqcY0IPzrLxmq6Sixfu+Qz0Vfg9StGdD8MkxvUaKfI/L6Hw9ZYvbhU0X161A2xcT9MHWkGDKST6Xx73JoSZHqWkwEVHaoXIA0ghS8Jl/wNWM2iYl+Eb3K/+Cy3k0Trqn9e+NLLq/st43JyUi+uOc/voz4WD/FrqI7v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vZ4jKBoOFMLduHNx6VGGZ1RcLIAq2KZFh4KzPW1xV0EIyXtFoHA8VcWY3ERmvZWUjGV0DnvB+z0dkyR7xSINl3t0WlaqPVp3hPJKbILVC/bAG1/XT71adNANtcAvbJ1gDhQoPVwBkfEkaj2w9IVgrl3ItSxYxhTlcqOOMuDf1g3F2IqTy4Z+Z5cqwSbf913+rP8G++23fNi915bCMPwtXFV/FQ7gCOnijcVJH20+A5wYKqEKJhNhNNzS2TDg0g4W1h/mRe7MvPBTvBC8QH X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc573aea-51c0-4f49-264d-08dbbaa049e0 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6004.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2023 12:43:01.2249 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lBHjn0K46FW4BlUJfgD6ZcfY9lbsi7I9mIs7mzf2L8lJmJdKSWudoFWSZ4y/HZVCm068x8+qdOdXoc3Q8BtKAQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9776 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org key buffer is not copied in chachapoly_setkey function, results in wrong output for encryption/decryption operation. fix this by memcpy the key in caam_ctx key arrary Fixes: d6bbd4eea243 ("crypto: caam/jr - add support for Chacha20 + Poly1305") Signed-off-by: Gaurav Jain --- drivers/crypto/caam/caamalg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index eba2d750c3b0..066f08a3a040 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c @@ -575,7 +575,8 @@ static int chachapoly_setkey(struct crypto_aead *aead, const u8 *key, if (keylen != CHACHA_KEY_SIZE + saltlen) return -EINVAL; - ctx->cdata.key_virt = key; + memcpy(ctx->key, key, keylen); + ctx->cdata.key_virt = ctx->key; ctx->cdata.keylen = keylen - saltlen; return chachapoly_set_sh_desc(aead);