Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1537494pxa; Thu, 6 Aug 2020 09:45:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw66/LhcJ3+ti6QTUg6uw0Cutf3b+B0+eNzhF39JRNGisf8xX+NkjFARUzrNTa2BrYKKY7r X-Received: by 2002:a17:906:a153:: with SMTP id bu19mr5165961ejb.142.1596732310207; Thu, 06 Aug 2020 09:45:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1596732310; cv=pass; d=google.com; s=arc-20160816; b=zKxt5BAYsunki6VysnpyywUYHs+bBG3YcMyG1DDUMUttZzQimcLi/6P7avmQhJSfkS GGjkVxPE69WInUX+H41vzhVpt8rCs1BbwkWDMl5kkomgW+MGeNk6efW16wSvJFPPKXWw X14oLZzFRG6lyzweBHT5PPOCuIoExwpXRHIFUKXj+fRSx2+GhgJyaDYdvekyFVd/t1Bq 44xhgEmLbSFGx4CItIrtIxix0jyr2FHU/uIv2vnyULa8KTHD34ANXrGPhrXCuK5tpQ5c 6e9QOcHEk1Qg41OpQlb9gm1y+FgoKi/nDH42lwDnQSaMS1mDJj80QfgzfjwqkhwYHli5 ZqqA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=R6DWGyZrcAc23RA5Q5rukWQiiaO8jxUB3Q0Ppn4lOOc=; b=D3tqpqYvz68DUpVEoArUjMN9c3QYi6NVUoM2MGhLOctL1dGal0O/WPV0sPcULdbltg LtTjSLvvGDWO45o0LmqQLMfDAwOtf92Vac4hh3+b2qyCfnIeGWdILa5RlfuoM9r7cc+h VHBmsWrJMRydcPNLBhprQ2KBoCHAZRlIBAFBbgs+J1fOEBKTuhFuUNiLjTXPoDpY38CF lRNIY+bHIE15g5I8P0OpxXx6Melo4CVoZATOoGDqpL9JzEOEy9qO9BCg5cSOgZW5BKeu T4YJlLt5tFpZu5TFLvQoYblOdvlEj4em3wffIckSva3xM5cE7pmnhI1eAVT2DEBnCw6H fYlQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=Jy6yHHYd; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.com); spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x30si3608302edc.80.2020.08.06.09.44.46; Thu, 06 Aug 2020 09:45:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=Jy6yHHYd; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.com); spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728740AbgHFQkl (ORCPT + 99 others); Thu, 6 Aug 2020 12:40:41 -0400 Received: from mail-eopbgr20041.outbound.protection.outlook.com ([40.107.2.41]:26854 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728211AbgHFQik (ORCPT ); Thu, 6 Aug 2020 12:38:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HPmuvwC0Tk1nSSB2O2YKuAEr5A6U++eFK8x5qkfwS3W0EuHMzl1OGdAPXaZwA1p+XOCpC67+NO6HFUdF2wKs+nxkg2M8UawP8ZBg4TSwGmqMrrC+rmBKiLef18WQVyf/I9qq+GrU4bY2hifgYboGq8xUrXIULTSo+kSWLBp0AsY9efkZ43ttsshRHXK9f11vUFWGpECZsqgi/4Fz6hDbq9Y3cDCwa/v0xh51V8r9JWAFqsoXxNNf6v0qC5Zs+pGnFPvepHNhFrCKxxEBcF0Hyapc7ouT/UAdMfvt4xBlOi23DAXVy/I/LPUaBQ4r8j/WnMp8oiMU+B/pHrKw2wnG0A== 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-SenderADCheck; bh=R6DWGyZrcAc23RA5Q5rukWQiiaO8jxUB3Q0Ppn4lOOc=; b=n2IuKtMHcdMT8B8m5hErMgblSlN+VnsejLZicPJVRnq4XKsWmlKQR+p+kYQDb3D+12xcXVK3zuYyMsKQpVOnnONZTBb4FLY3eqw9iYdPRLW0Rx28t58blFAblj2v+4P7R20+y8cwr5aqwOZ59CF1PBnAFMwz2VZobYfUr7qFS9A54ULTD+RA4moE0J6mnZFoNgfyzPWnjYAWQW7D6Mjz0n026vFT06l2suSgtS7Tuazw/bdOZEOb/vVfB9eXBi4AP86yF9cyudtG1a0Nau2r6BgT0DBd5kEALL+NsNabzCpVd7fHIsssqvmJNfeXQFot+o11mJc6nxZQk4+5WdQCLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R6DWGyZrcAc23RA5Q5rukWQiiaO8jxUB3Q0Ppn4lOOc=; b=Jy6yHHYdLUDnUVzhL4g24prjFe0l9FQWT3/GfmWawTCJle4zgm7XuMihIte3PlTHzXzp3dhov7gGEdyHeX6Hg95gBiolTi5DFLUFqirvI5USSBsZlxfiTmk+6kX8sbJC/06C6NJXYZYJI9Mi2rGWFX7it60jVKV9yut/BsSH17A= Authentication-Results: nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=oss.nxp.com; Received: from VE1PR04MB6608.eurprd04.prod.outlook.com (2603:10a6:803:125::12) by VI1PR04MB4992.eurprd04.prod.outlook.com (2603:10a6:803:51::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.16; Thu, 6 Aug 2020 16:36:18 +0000 Received: from VE1PR04MB6608.eurprd04.prod.outlook.com ([fe80::a856:c104:11c7:258d]) by VE1PR04MB6608.eurprd04.prod.outlook.com ([fe80::a856:c104:11c7:258d%6]) with mapi id 15.20.3261.019; Thu, 6 Aug 2020 16:36:18 +0000 From: Andrei Botila To: Horia Geanta , Aymen Sghaier , Herbert Xu , "David S. Miller" Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND 5/9] crypto: caam/qi - add support for more XTS key lengths Date: Thu, 6 Aug 2020 19:35:47 +0300 Message-Id: <20200806163551.14395-6-andrei.botila@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200806163551.14395-1-andrei.botila@oss.nxp.com> References: <20200806163551.14395-1-andrei.botila@oss.nxp.com> Content-Type: text/plain X-ClientProxiedBy: AM4PR0902CA0015.eurprd09.prod.outlook.com (2603:10a6:200:9b::25) To VE1PR04MB6608.eurprd04.prod.outlook.com (2603:10a6:803:125::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv15007.swis.ro-buh01.nxp.com (83.217.231.2) by AM4PR0902CA0015.eurprd09.prod.outlook.com (2603:10a6:200:9b::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.19 via Frontend Transport; Thu, 6 Aug 2020 16:36:17 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [83.217.231.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 300b8447-c9c1-40d6-5f36-08d83a26d822 X-MS-TrafficTypeDiagnostic: VI1PR04MB4992: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1824; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rQR5yrT0MsZvZTk7j+hK0kq1/WtWRwAMVUpoWNYUqm3z7AN643RCjHluoLcp7XqfQe3n7Hac4QrqaZe6jT2IVvxbv+qi7oCrjqMEn+mtVIM1O+/c411bm8L0VNZ20uXRQT83vZioJuRGGYt8why95lSvJdMm6matDQminKObCymb/vzFuul5Z0jaWgEK5O/pIbWdi31JXOUGyibREiSERdf4pMum85ygKLzlNDzxOqw+g8NnlzHT8rGOW548+ceTrfturoIebFrNLsLPiKcHrsweCNn3A1Y/2E1T7YsdtJ/A7Tbk/J8lvKFwyfl9BgT95pivUoilvZBYmxCYQ8tmlw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6608.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(39860400002)(396003)(366004)(376002)(136003)(346002)(66476007)(86362001)(26005)(6512007)(16526019)(186003)(66556008)(66946007)(1076003)(110136005)(8936002)(316002)(8676002)(478600001)(2906002)(6506007)(4326008)(44832011)(2616005)(956004)(83380400001)(6486002)(6666004)(52116002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 1H+n//K6n5Nx+I/122KVhPeLFUEtjoAjmhw75i9CpIxFXOZeFCDGEZU3qdbj31tNhUXTwi7WVlpLBHplHm75hDa3pr1PZmMHQpBBnA1mM0i7rVD1H9zoJ15zDM0V3cjW2dfUjAdHygc2DIU6gTGBVyG1bRgaVz4uLGQhnc7pWnoqvNxHTjUfYjee2lXUkxmIXJP8ltZzX6aDTimqMiXzgjXRi1tnPbeCP5NfFE0RRs7Bg5g3cRsLRdSN6sJens90UFBIAqd7d8ccsakAEQB1VlYlz+leso9J1iNcinqzTbf9Zq0pXC3E9akcFD9Ir1/6uUVU40VZr+GfrsL4Bc/6dzAMO2Ru8b8ZjCcmEpfMaRf2gusEXqv24jGdnzfwQeoSCfWgVlII14PxO42y+mFrSOfRJcioR8yH0Lst4BLqFnoM8IyR1X72yr2bmMyjdoV/nyN2Rhhjzns/mD9dfMIZKNBJN+RZZsfYwwid/y9A67YmEHQaFEyeUhdzNeTnKmzCJDPKk4am90JmOmVbbk9j8KxubbR9lMhF31AsU9vnWOCfEjewSFaQQzDVrAMfxlPLz7QqToufb6Z9DFiMnOrxry/MRFa6z6atXB1F/inDHE0WedAarQ1EoSIMdF6MnjqbV4RVGxtJrMsQu/Ypp/iHAg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 300b8447-c9c1-40d6-5f36-08d83a26d822 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6608.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2020 16:36:18.3553 (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: 7bMCyWRHXQcJKXBtmcVqQlnm0wMupvrhbIRumQmwhoYkHgngb03Z+G2ZC2nCcYq93W9Pk3jIqyTTHVJ7LkQL9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4992 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Andrei Botila CAAM accelerator only supports XTS-AES-128 and XTS-AES-256 since it adheres strictly to the standard. All the other key lengths are accepted and processed through a fallback as long as they pass the xts_verify_key() checks. Fixes: b189817cf789 ("crypto: caam/qi - add ablkcipher and authenc algorithms") Cc: # v4.12+ Signed-off-by: Andrei Botila --- drivers/crypto/caam/caamalg_qi.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/caam/caamalg_qi.c b/drivers/crypto/caam/caamalg_qi.c index 05cb50561381..1d775a55fcf5 100644 --- a/drivers/crypto/caam/caamalg_qi.c +++ b/drivers/crypto/caam/caamalg_qi.c @@ -18,6 +18,7 @@ #include "qi.h" #include "jr.h" #include "caamalg_desc.h" +#include #include /* @@ -734,9 +735,10 @@ static int xts_skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key, int ret = 0; int err; - if (keylen != 2 * AES_MIN_KEY_SIZE && keylen != 2 * AES_MAX_KEY_SIZE) { + err = xts_verify_key(skcipher, key, keylen); + if (err) { dev_dbg(jrdev, "key size mismatch\n"); - return -EINVAL; + return err; } err = crypto_skcipher_setkey(ctx->fallback, key, keylen); @@ -1408,7 +1410,9 @@ static inline int skcipher_crypt(struct skcipher_request *req, bool encrypt) if (!req->cryptlen) return 0; - if (ctx->fallback && xts_skcipher_ivsize(req)) { + if (ctx->fallback && (xts_skcipher_ivsize(req) || + (ctx->cdata.keylen != 2 * AES_KEYSIZE_128 && + ctx->cdata.keylen != 2 * AES_KEYSIZE_256))) { struct caam_skcipher_req_ctx *rctx = skcipher_request_ctx(req); skcipher_request_set_tfm(&rctx->fallback_req, ctx->fallback); -- 2.17.1