Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2940844pxk; Mon, 21 Sep 2020 00:35:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxYSgtQUUf3My97uSX9p1pzhkAhi7wgVZQsciEYMur/Kpn907fOTkWuCUo/Gib448MjIjc X-Received: by 2002:a05:6402:22fc:: with SMTP id dn28mr49275877edb.365.1600673722890; Mon, 21 Sep 2020 00:35:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600673722; cv=pass; d=google.com; s=arc-20160816; b=OHrPZUuRjGwYxjGiO2tTEjjIrPBuX1vD5GzPR/31fb0wFdFs6fgT6/0RNKgpIad98i CyaHBQ2SIRDiZ12qXHhNIRZ64csRuHT3otZf1Z3x2SgOHyPbtY7RYPBpXEmmDGNITJPN 1wal09R/t85IXeXoo1MvSrE3kzXjuEdp0b3UTGPJ9ggjw0ZolECeE8ZjeEWckmboPPeb WmRKBKuAN9nNS/CJq+SnITm/Ac3B5SD7K31ef7JQGahfG5Ba2kaxwfoa+Qs/ZzrosHH0 T4hl+LcA8dwbFFiUwJaf/hb4mhWlUMxOm+iPsuOGeQtPH32zf/YyJe6uZta6biXjk13y AoTw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=t48bUselI1r0GF/+r5CwLTQuYChjGC2OLYgTa/EBvW4=; b=ptxAr615Y+NpxZV1ZLQeAqZJ/nUK/sA3/sJhFeaJk7zr1DaZDYzWKGb1HKcgx9l4/f hRBA1UZAeDE5VONs/lM0gZgczf50OU0L2I157CdFOxiY8jWvxJ3uhU3q1lnQhg8KDxlz l+pexPKzmLfJdxqgAL/e4g8IfI5Ioe6S/J3UFYwp7RqwHT8CsdEOHpoSlxWE7J5W8Ho0 GuYE1fbyt86M2ldM5duBzEY3gT5+S/SsCVETDQHMcBfam72rAj2LcDLXmxHbDgYFvnIb 4n8aYeureEqOpwhrpzZb0q5Sut/Mkc7AFx0nqTWf0TZY+zN/UFJj0575VSx2J7Ydv7pS zQvg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=RyXudyZJ; 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 a8si7583748ejv.661.2020.09.21.00.34.58; Mon, 21 Sep 2020 00:35:22 -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=RyXudyZJ; 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 S1726510AbgIUHdP (ORCPT + 99 others); Mon, 21 Sep 2020 03:33:15 -0400 Received: from mail-eopbgr60075.outbound.protection.outlook.com ([40.107.6.75]:47332 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726489AbgIUHdJ (ORCPT ); Mon, 21 Sep 2020 03:33:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kHQ3V9DOQNFZ4eTkXVb1K79LzbcVog84ucFXihq4VTS1lbncIg5q/2dwqVe26c2e+o559ZJauJ3C+8LkxfGLfioGUrnnKZzu2p9typtL86xGOfxJFgg2sI631j3/Xafct0TFUdxvcVMgGmWn2PHGbX1Wz/fdeVTytIipDxqJ0hoeyxR4omXIFI+c2zjbsSX7tOfIC7ido53yVSoAnE1/EP3Ik5CsXwEVo2hJ/36X78ij21903nSEGguQJyFGTa4w8zAIf1Gq5OHRa2okV/wuguXXMhUerWlUQ36KwO1ugbZGYtZPMSI44PkwVXU9REC7VXRBsUDj2Qv1ItH8n7LF5w== 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=t48bUselI1r0GF/+r5CwLTQuYChjGC2OLYgTa/EBvW4=; b=JmU5ls8RsAoteAWa958uYFdOYpi0hCEzigO00/yFn+Mo23kKZ4leE4nsbPB6P6Mn1puS3zSTGv7v5x2CjSCfCEgTIBXB75VB2V4uyiuWFwhncZKWWEsvfJkjcPr9yzOtItlX6tWtct6fRi2KjnIiFtBNbf3XsmrPT//YCP2hj/aOHcmzY/fP2lzQgeA+cowe83v5moaN15rZ5QEsM3XBeHm8HBDHLM+SO4xQtwzZtv/mmCKCwPzRm7YreUBqYKoax6tj3gU7kuWzWvIR3ymo5lUbfporreg37sGcUnw4pe7Ders4oTTtD32FgCZo6ZDpdZPsTalcVtRq8zLv1PIWaQ== 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=t48bUselI1r0GF/+r5CwLTQuYChjGC2OLYgTa/EBvW4=; b=RyXudyZJez3JUXhK5wJPIlINfkHpICsS4G/uPcr4eeZy0A1T8XLgzSz3dOUobctPyU57gNE/3cp7M1HkG9cdHpDsJmeX04kjX0uNIvY3A8NvvGc+T5HlFtI49AuXTIEk1Ixby2IAG5z/xnBjo1/OgjAAWelzrTwPGXAc/7A2A6w= 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 VI1PR0402MB3903.eurprd04.prod.outlook.com (2603:10a6:803:21::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.15; Mon, 21 Sep 2020 07:32:33 +0000 Received: from VE1PR04MB6608.eurprd04.prod.outlook.com ([fe80::34b6:beed:6762:a67c]) by VE1PR04MB6608.eurprd04.prod.outlook.com ([fe80::34b6:beed:6762:a67c%7]) with mapi id 15.20.3391.011; Mon, 21 Sep 2020 07:32:33 +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 v2 11/12] crypto: caam/qi - add support for XTS with 16B IV Date: Mon, 21 Sep 2020 10:32:04 +0300 Message-Id: <20200921073205.24742-12-andrei.botila@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921073205.24742-1-andrei.botila@oss.nxp.com> References: <20200921073205.24742-1-andrei.botila@oss.nxp.com> Content-Type: text/plain X-ClientProxiedBy: AM0PR02CA0016.eurprd02.prod.outlook.com (2603:10a6:208:3e::29) 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 AM0PR02CA0016.eurprd02.prod.outlook.com (2603:10a6:208:3e::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Mon, 21 Sep 2020 07:32:32 +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: fe7b40af-5233-4e82-67b2-08d85e0080e8 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3903: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ed28INyL7vdwNK1sCUWL/bxjgp1CPMIZNX7l/gkgzB/CwuN4e9KeHYwkFeWd/uqIOV1vtKwUjMxyEkcREY/01rSJu8jqsDQOlzvkuwbNvSETEpHtAvlrCpfKYw0279DEEjgZwRfdnQabxt/B2dzFj0jq53YweH0cFJz/cRW9KiYrpMsV7FJYAdBqjfpVLF+N1YoUwwIUCcg87/rCaov/7Yqn3QM3OJNyUATSFihTCxcOKE0MXY+CDP3dTp0P1Ggd2ptPbMiAW/eDLjV12wg0wwU44cov5QW8i1ysYN9rJrRthkfOYXqy36zPM+GW+55RUucncyYmFxGMQcg1GKtyIqT5gnvZ+P8RPsSfLzd5GWx1N7Sb+dsjGba/p01kE1J+ 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;SFS:(4636009)(366004)(376002)(39860400002)(136003)(346002)(396003)(66476007)(66556008)(2906002)(4326008)(44832011)(956004)(2616005)(6512007)(1076003)(8936002)(8676002)(6666004)(52116002)(66946007)(478600001)(316002)(5660300002)(6506007)(6486002)(83380400001)(186003)(16526019)(26005)(86362001)(110136005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: mAe7EpM+xYlCPdUsHl4b9LaOr7z+efApntnkzg279c4fMd0FrWTWI5efZQw9uD/fswlUt4W9LFOs7C5deRBTExcui8OMzHsXHNx06yQwyw/uK+DcjvHBC5ASWSKAPaQ1kF7Z65LJ3Vc9i1gzYgxJliJnUkBJ+vLuayR7flDIHmNWM5naIzHxnAkqNcUPiFdyWUcRvSWy3nXD7PmSIs66tPVtLSBlbBHFdpSOrnztOv8M8eafLQDKatp6AbU3U6ByFvezEdCiiLhk+1GrCDRA/ObSDLCRmU/GqhDki5d7t/4kwamVDh079fsPUeeu81Uybq8EWef5JUJlY5cy3SuBKKie+qTgNVQKZEQf08bWF2iJ8FM8/tVj8IxftUfr5t1XCbyUKKVlz06YrcCWmZ8yuUn/zyxWFLljKaPrMWbAMxSHYpn4VgAH8s0PEyfFlrGOeXAc9cGnRvMtvAFsf8s7lvgBvwPkGX3QAXxCJ5OHMmcQU779LgMBpjNFWS4CbXO1WHkBQYjJmY7JboL4MTV0bWWKyYfxHOn2eMH76CKsqrekDteRXyBbLQsBLYf5IsiVexaxi1dHKU63yOeMeeuqzULnNPHdKGOLeypowacSP3HyRH74iMHrYqwQM2DUE01UnPlN5vAIipLoOvjpwLv7BA== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe7b40af-5233-4e82-67b2-08d85e0080e8 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6608.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2020 07:32:33.0579 (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: s48oNrT/8UMMVSJjhTXt3A59yFdZi68ZkHdowsdYLUCLfvNboI7It6jW4IVQomw3sqPyP9fkFVUdLhJXxV3wjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3903 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Andrei Botila Newer CAAM versions (Era 9+) support 16B IVs. Since for these devices the HW limitation is no longer present newer version should process the requests containing 16B IVs directly in hardware without using a fallback. Signed-off-by: Andrei Botila --- drivers/crypto/caam/caamalg_qi.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/caam/caamalg_qi.c b/drivers/crypto/caam/caamalg_qi.c index a897eea59790..88d767910874 100644 --- a/drivers/crypto/caam/caamalg_qi.c +++ b/drivers/crypto/caam/caamalg_qi.c @@ -733,6 +733,7 @@ static int xts_skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key, { struct caam_ctx *ctx = crypto_skcipher_ctx(skcipher); struct device *jrdev = ctx->jrdev; + struct caam_drv_private *ctrlpriv = dev_get_drvdata(jrdev->parent); int ret = 0; int err; @@ -745,9 +746,11 @@ static int xts_skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key, if (keylen != 2 * AES_KEYSIZE_128 && keylen != 2 * AES_KEYSIZE_256) ctx->xts_key_fallback = true; - err = crypto_skcipher_setkey(ctx->fallback, key, keylen); - if (err) - return err; + if (ctrlpriv->era <= 8 || ctx->xts_key_fallback) { + err = crypto_skcipher_setkey(ctx->fallback, key, keylen); + if (err) + return err; + } ctx->cdata.keylen = keylen; ctx->cdata.key_virt = key; @@ -1406,6 +1409,7 @@ static inline int skcipher_crypt(struct skcipher_request *req, bool encrypt) struct skcipher_edesc *edesc; struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req); struct caam_ctx *ctx = crypto_skcipher_ctx(skcipher); + struct caam_drv_private *ctrlpriv = dev_get_drvdata(ctx->jrdev->parent); int ret; /* @@ -1416,7 +1420,7 @@ static inline int skcipher_crypt(struct skcipher_request *req, bool encrypt) if (!req->cryptlen && !ctx->fallback) return 0; - if (ctx->fallback && (xts_skcipher_ivsize(req) || + if (ctx->fallback && ((ctrlpriv->era <= 8 && xts_skcipher_ivsize(req)) || ctx->xts_key_fallback)) { struct caam_skcipher_req_ctx *rctx = skcipher_request_ctx(req); -- 2.17.1