Message ID | 20230921124237.2364827-1-gaurav.jain@nxp.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5257908vqi; Thu, 21 Sep 2023 18:36:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElsthECaYCY+f532su90vexnpqyFPzuwFdhkUzHfq3svk3fhEbyQ9JeA2vSRCgbY0M0iIj X-Received: by 2002:a17:903:124d:b0:1c5:6691:4978 with SMTP id u13-20020a170903124d00b001c566914978mr8434007plh.37.1695346614426; Thu, 21 Sep 2023 18:36:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1695346614; cv=pass; d=google.com; s=arc-20160816; b=fzsJgccUFrMWxOsAo8r1N0ZFfET+R9EL4dp8Qm2tZaZPbIx15Pt9raM0DFzlkHSMao XHe8eRO+nRBfe5iT9YIzQdFe2UfNqQ57BvItahOOr776gr5wh+GsVcixr2sGB65uZaOM DfM7SGsZXHKK7E592FRTi8F6BIHcxCl/C2WH/LuvxqOsLprI53a3OnaaVmy+ss1xiwnM ToU6bJCZUWX826wXa99Qg63H+kL4/OE4SgicMseXTQTZoIOd/mC3hZu2p6qVK36s79DP eY9ll28/pxHAk9l0rl9ou/1LQ0VtRwaYuz6NP2x75t9pUXIeS1PjBdcenSfV3PfK0HxD Brtw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=44kUePCEurOOgwMYy/g7ZeaiQvugDdzWMXCOBAU9FXc=; fh=lKko8kpMKjcgwwwuqI5isMWkY40BO5DBObxctkZeXe4=; b=HDPQ3bl6fUGatSmRa/g6kCMIJiua7gtvk/KbndCHZ/0vvkn5pMWIMroBZ9/1hlClun /FM5px7KaWUvQbkflSV3qbd9ID6lS1FpvLzi0GoBrGAoFiT9Tj4Ag9cQHMv5gWwc2mJZ xfTIrTUQLfudhl5jXH9Ay8Xr2pkEs8PipK3OQgkm6Xy/VwB1Pvzg603QVSPAH6jlhooO jkqCfZC2zJTr63+0ULEVqI7PQxyDCt9xND2LiXBF0OWFADvT8W9ZviezcXZD3jfHVgea HDFnbENTNS2RkzWMNZGCKfs2DnRL4Bi0WUizUry4VdpoCHavvODIOWHX+H1+u7EnN6rz ci1Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=KhD1rXPW; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id n8-20020a170902d2c800b001bda1941a8esi2842722plc.582.2023.09.21.18.36.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 18:36:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=KhD1rXPW; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9A704832A00E; Thu, 21 Sep 2023 14:17:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232666AbjIUVQi (ORCPT <rfc822;pwkd43@gmail.com> + 29 others); Thu, 21 Sep 2023 17:16:38 -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 <rfc822;linux-kernel@vger.kernel.org>); 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 <gaurav.jain@nxp.com> To: Horia Geanta <horia.geanta@nxp.com>, Pankaj Gupta <pankaj.gupta@nxp.com>, Varun Sethi <V.Sethi@nxp.com>, Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>, Herbert Xu <herbert@gondor.apana.org.au>, "David S . Miller" <davem@davemloft.net>, Aisheng Dong <aisheng.dong@nxp.com> Cc: Silvano Di Ninno <silvano.dininno@nxp.com>, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com, Gaurav Jain <gaurav.jain@nxp.com> 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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/FrqI7vdZCmktf5rxHjdBtTSvg+JZ/r0DvcOw3qbbHPZLfhlX5+/3noHG+ASS/diyIWv9v7lVNb0Br6fYg741pHbFuvf2oXY/0/L+k4pgv1LKAbCjsiwUy+JB27TJHirfFPaSVBvTj+WuXI0NKukfz+VThdpZLYN/dYxrKsKMmIlbM/JzA51+nFbM5Fff3VXEYC/KYbMr8p9kA1Yg4t0QwgZtkkfMXBwG7bmugDzs0GYzMHjI/U1vK7T9uU6rcD7ETBKsYT1V3jQU4dIIseE6i0A/xX7sCvGbOpdaazNNcx8tthdd6GpSu0a0nSk8UFVymZUfuMwAHowPCMqMkHueM1NyNX/z79LR66618AXLRhjLINX17tXFm31xwuTOJRQROQXoFfk344XFlXCibqZHfHXzlFjqTJ1aQElAkLOIBGCCrWe/ZGHsbpVCczrpW5O3R7G47KdkMe2qxx654/Of9Kw9dsluMzHBsaIPUuLVeHFeoPUYIE0sRTMUErycAfz9a8Db9uqcsQRiQ5uemDFXUe/ZCOjZmOxzrZyoaiEtv4l4+wEBrtJILCF3E91+4eZGasssi+IrknmO6L3l8gsEnlx4qNCmN1djmsUJ0d5+E716/VxASe1fvh0fWRkwwGtUKQCPH3s44U00P2V/J55d+e7ZQz/MX2CAcreJ48bXEQiNg9CJVVAKgHJ+oV00NjTQq8C5W7BYH9UO7X3oDL9To95vQ8y0QK2i8Yxt4KWFsSuE2iWLXjgXjjaubtfAlZHuKLDesHLys89UVru4oIJXDiyPikfCPnCeTMDEwGvUx8cz6i9RIIPZFT9QFvRlqUDrAgZ1R2D6ichxdTf2ZqjcVzt2/Mb5wIG5yFQPTBuHEBKfuXcc9xibX7EC7bAhcWP7S4bRddqycQ4yQ29tqRKCXhXDE4Vm3eX4wrYbH5H7wmg+WaqhpEUKfbtKGCidXwXOsGnhgcXaszyYsx47utfGYRpchyzHJaG5wudm1pjwBjkfmd18nLQIKjgmOc/+lCm+y8jrYTIxr2xr1SNzFBk1Ypqnpu5VBXYoNbBB1QoX3lUboCorHGsO+KbIyjAizvZ4jKBoOFMLduHNx6VGGZ1RcLIAq2KZFh4KzPW1xV0EIyXtFoHA8VcWY3ERmvZWUjGV0DnvB+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 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 21 Sep 2023 14:17:07 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777699771509416509 X-GMAIL-MSGID: 1777699771509416509 |
Series |
crypto: caam/jr - fix Chacha20 + Poly1305 self test failure
|
|
Commit Message
Gaurav Jain
Sept. 21, 2023, 12:42 p.m. UTC
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 <gaurav.jain@nxp.com>
---
drivers/crypto/caam/caamalg.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Thu, Sep 21, 2023 at 06:12:37PM +0530, Gaurav Jain wrote: > 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 <gaurav.jain@nxp.com> > --- > 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; > Huh, so this driver just ignored the key? Is anyone using the ChaCha20Poly1305 support in this driver? Based on this bug existing, that seems unlikely. If that's the case, wouldn't it be better just to remove the ChaCha20Poly1305 support from this driver so that the code doesn't need to be maintained? - Eric
Hi Eric > -----Original Message----- > From: Eric Biggers <ebiggers@kernel.org> > Sent: Friday, September 22, 2023 8:11 AM > To: Gaurav Jain <gaurav.jain@nxp.com> > Cc: Horia Geanta <horia.geanta@nxp.com>; Pankaj Gupta > <pankaj.gupta@nxp.com>; Varun Sethi <V.Sethi@nxp.com>; Meenakshi > Aggarwal <meenakshi.aggarwal@nxp.com>; Herbert Xu > <herbert@gondor.apana.org.au>; David S . Miller <davem@davemloft.net>; > Aisheng Dong <aisheng.dong@nxp.com>; Silvano Di Ninno > <silvano.dininno@nxp.com>; linux-crypto@vger.kernel.org; linux- > kernel@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com> > Subject: [EXT] Re: [PATCH] crypto: caam/jr - fix Chacha20 + Poly1305 self test > failure > > Caution: This is an external email. Please take care when clicking links or > opening attachments. When in doubt, report the message using the 'Report this > email' button > > > On Thu, Sep 21, 2023 at 06:12:37PM +0530, Gaurav Jain wrote: > > 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 <gaurav.jain@nxp.com> > > --- > > 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; > > > > Huh, so this driver just ignored the key? Is anyone using the ChaCha20Poly1305 > support in this driver? Based on this bug existing, that seems unlikely. If that's > the case, wouldn't it be better just to remove the ChaCha20Poly1305 support > from this driver so that the code doesn't need to be maintained? This algorithm is used in IPSEC and we are also going to use ChaCha20Poly1305 support for Kernel TLS. Gaurav > > - Eric
Gaurav Jain <gaurav.jain@nxp.com> writes: > Hi Eric > >> -----Original Message----- >> From: Eric Biggers <ebiggers@kernel.org> >> Sent: Friday, September 22, 2023 8:11 AM >> To: Gaurav Jain <gaurav.jain@nxp.com> >> Cc: Horia Geanta <horia.geanta@nxp.com>; Pankaj Gupta >> <pankaj.gupta@nxp.com>; Varun Sethi <V.Sethi@nxp.com>; Meenakshi >> Aggarwal <meenakshi.aggarwal@nxp.com>; Herbert Xu >> <herbert@gondor.apana.org.au>; David S . Miller <davem@davemloft.net>; >> Aisheng Dong <aisheng.dong@nxp.com>; Silvano Di Ninno >> <silvano.dininno@nxp.com>; linux-crypto@vger.kernel.org; linux- >> kernel@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com> >> Subject: [EXT] Re: [PATCH] crypto: caam/jr - fix Chacha20 + Poly1305 self test >> failure >> >> Caution: This is an external email. Please take care when clicking links or >> opening attachments. When in doubt, report the message using the 'Report this >> email' button >> >> >> On Thu, Sep 21, 2023 at 06:12:37PM +0530, Gaurav Jain wrote: >> > 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 Not sure, but do you mean array*? >> > >> > Fixes: d6bbd4eea243 ("crypto: caam/jr - add support for Chacha20 + >> > Poly1305") >> > Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com> >> > --- >> > 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; >> > >> >> Huh, so this driver just ignored the key? Is anyone using the ChaCha20Poly1305 >> support in this driver? Based on this bug existing, that seems unlikely. If that's >> the case, wouldn't it be better just to remove the ChaCha20Poly1305 support >> from this driver so that the code doesn't need to be maintained? > > This algorithm is used in IPSEC and we are also going to use ChaCha20Poly1305 support for Kernel TLS. > Gaurav Does this mean IPSEC doesn't call setkey() or the key value was such that it didn't affect even after failing to actually set the key? -Kamlesh
Hi Kamlesh > -----Original Message----- > From: Kamlesh Gurudasani <kamlesh@ti.com> > Sent: Friday, September 22, 2023 12:47 PM > To: Gaurav Jain <gaurav.jain@nxp.com>; Eric Biggers <ebiggers@kernel.org> > Cc: Horia Geanta <horia.geanta@nxp.com>; Pankaj Gupta > <pankaj.gupta@nxp.com>; Varun Sethi <V.Sethi@nxp.com>; Meenakshi > Aggarwal <meenakshi.aggarwal@nxp.com>; Herbert Xu > <herbert@gondor.apana.org.au>; David S . Miller <davem@davemloft.net>; > Aisheng Dong <aisheng.dong@nxp.com>; Silvano Di Ninno > <silvano.dininno@nxp.com>; linux-crypto@vger.kernel.org; linux- > kernel@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com> > Subject: Re: [EXTERNAL] RE: [EXT] Re: [PATCH] crypto: caam/jr - fix Chacha20 + > Poly1305 self test failure > > Caution: This is an external email. Please take care when clicking links or > opening attachments. When in doubt, report the message using the 'Report this > email' button > > > Gaurav Jain <gaurav.jain@nxp.com> writes: > > > Hi Eric > > > >> -----Original Message----- > >> From: Eric Biggers <ebiggers@kernel.org> > >> Sent: Friday, September 22, 2023 8:11 AM > >> To: Gaurav Jain <gaurav.jain@nxp.com> > >> Cc: Horia Geanta <horia.geanta@nxp.com>; Pankaj Gupta > >> <pankaj.gupta@nxp.com>; Varun Sethi <V.Sethi@nxp.com>; Meenakshi > >> Aggarwal <meenakshi.aggarwal@nxp.com>; Herbert Xu > >> <herbert@gondor.apana.org.au>; David S . Miller > >> <davem@davemloft.net>; Aisheng Dong <aisheng.dong@nxp.com>; Silvano > >> Di Ninno <silvano.dininno@nxp.com>; linux-crypto@vger.kernel.org; > >> linux- kernel@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com> > >> Subject: [EXT] Re: [PATCH] crypto: caam/jr - fix Chacha20 + Poly1305 > >> self test failure > >> > >> Caution: This is an external email. Please take care when clicking > >> links or opening attachments. When in doubt, report the message using > >> the 'Report this email' button > >> > >> > >> On Thu, Sep 21, 2023 at 06:12:37PM +0530, Gaurav Jain wrote: > >> > 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 > Not sure, but do you mean array*? > > >> > > >> > Fixes: d6bbd4eea243 ("crypto: caam/jr - add support for Chacha20 + > >> > Poly1305") > >> > Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com> > >> > --- > >> > 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; > >> > > >> > >> Huh, so this driver just ignored the key? Is anyone using the > >> ChaCha20Poly1305 support in this driver? Based on this bug existing, > >> that seems unlikely. If that's the case, wouldn't it be better just > >> to remove the ChaCha20Poly1305 support from this driver so that the code > doesn't need to be maintained? > > > > This algorithm is used in IPSEC and we are also going to use > ChaCha20Poly1305 support for Kernel TLS. > > Gaurav > Does this mean IPSEC doesn't call setkey() or the key value was such that it didn't > affect even after failing to actually set the key? Our test passed with older kernel versions, This issue was caught in testing with the latest kernel version only. Regards Gaurav > > -Kamlesh
On Thu, Sep 21, 2023 at 06:12:37PM +0530, Gaurav Jain wrote: > 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 <gaurav.jain@nxp.com> > --- > drivers/crypto/caam/caamalg.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) Patch applied. Thanks.
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);