From patchwork Thu Feb 11 20:01:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 381037 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2374967jah; Thu, 11 Feb 2021 12:06:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJyA2bB+azydhBwVRGOiuhhWPIPBipBaSYkmU09ywo6hVfDO+xCCQPBTGOV+PDkHerKoKNs5 X-Received: by 2002:aa7:d2c7:: with SMTP id k7mr9947476edr.374.1613073962812; Thu, 11 Feb 2021 12:06:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613073962; cv=none; d=google.com; s=arc-20160816; b=VYC6kUBv2Nh/hfhlRlB8xq1sjckrgm09UQuF7F2g4LbGrnkR/1UnIEkS3qu6+lxqBA mVDQutsR7LX3wh7FRLMYkNjw/ufjpGCmukg5Ovl+Ha+vm0whWLdUA/jy316pW0QgbH0v UXQB50uLlLWH0f93evo5/nmCoSOMLPXwvkNFNjJ5zKi6F9THbpKBdnNiECkVQk9BHYmc WBBWAz9AP9wcqkD6W/HxY2Wvq+iAguCvqtnCMJ0KaYm7LHtrJna0rXe/97Q7guis4xdk GPPp1imDiYfJA1jsOwTOzeFp0+upwrfJXKAZ32zLjQ2J8vbWvp7Evh5Ib2HbfG7XEv2B Juhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bL5tBDOEKgNdAp1Fa/CljitFahbwVqV1YSG/EkXQA0c=; b=V7S4eHfg/IfmowL4fzm2yfoIZuBaArLfceRBO2osmdZv+sKs2x1vdLFDHsXRv+iSD2 5VGGZ5XnjTzM7N4Dc7QtzmBjbdXTB7mmOsJCLSAtPlGxGW74c3KgypWWhgjQiAulVY8m ivs6W4EU5GFWOhgh9oUqhXJUsXdVY1ZXAEHfpml4XRGYWyX0ldod/RZcRotkvUi5jOVP EcY4MwcX68ZJI2lXt0uErCTCKbBngopJJ7k4t1V2sMU/5dbDLohnYWfzHhKFiL6RIge7 ydbQcQcndjsWwCXBXdMVS5KGxdzYrWv2F/Q3VByKoGsiyi/9XmAUvq+dYM7wxj9wD/FB odjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=koec8wpR; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hy24si4520322ejc.149.2021.02.11.12.06.02; Thu, 11 Feb 2021 12:06:02 -0800 (PST) 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=@linaro.org header.s=google header.b=koec8wpR; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229997AbhBKUFe (ORCPT + 2 others); Thu, 11 Feb 2021 15:05:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231322AbhBKUDW (ORCPT ); Thu, 11 Feb 2021 15:03:22 -0500 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C1F0C06121D for ; Thu, 11 Feb 2021 12:01:38 -0800 (PST) Received: by mail-qv1-xf32.google.com with SMTP id a1so3148176qvd.13 for ; Thu, 11 Feb 2021 12:01:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bL5tBDOEKgNdAp1Fa/CljitFahbwVqV1YSG/EkXQA0c=; b=koec8wpRvuhR5tv/Ao6J+GJABNrBwHe5+cC8LGvp6bbyx7drnjjNsbwMfn44UgLQt5 x2FjR1ObKQbGaZz+ctKNvqNm2oL5ip9RGq1vlY2u4szlJsliW/IDaMZjeNVWDwu4ywrQ dxUYNRXR1KmZ2T4kLq/MDVvdzq3Pu/NG4q8XNIMYzFyVrqSGi6GMFx7iz094u0Wzv29n iXwsso+pdJyH5uxg2l3T/HD2YRpRkpbZv8AMaw7wCg9r4TYxfqRAmMg3hVNJloBhgy02 W6Hi6WN+UHsGXE9OUQGvKLyTrT5LnQIXPh7qY1hCqHeYXe9o8yfaykUYyeeaj/c4D5xe vw4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bL5tBDOEKgNdAp1Fa/CljitFahbwVqV1YSG/EkXQA0c=; b=FkHEkrYGoeFmc4OQq/bfjr9z6Z5s94zCLnmXIy4IY8AUl1k9a0YyR1EUzzve+/eB9C ViHPqqqWfPkhu1VusPTYlIxfn7IInA7ZkizJYOTdfQP4HTxQuvFNql3PVr39AlzKSilZ EDqY54t9/jTvIYMadfhXriW5BiJIIORJPS5AUEu11ZShm8u9EB8FQ0Zo/87CUJqN42aN PBMoXmGrjZxGH1KtuREkhAPZPz4l+6AegmKyKdQyBzQ0OFLPwib4CaEoGD5Dq5l63/m1 sGHTGI2zZEqcpZodfUHZqqUEUcF0FZ6blO6CuLCEoxCcJ/6CEDPLVSiRlr+MZT4iQ9qk bxLw== X-Gm-Message-State: AOAM532rGAUXO0GSFAy5ClFHQIwV8TDw9mVnmtv3u+YzSR00LxZ+FbWM xvXL1ECP/it1k4LcUR4euODhbg== X-Received: by 2002:a05:6214:11ab:: with SMTP id u11mr9210776qvv.17.1613073697388; Thu, 11 Feb 2021 12:01:37 -0800 (PST) Received: from pop-os.fios-router.home (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.googlemail.com with ESMTPSA id 17sm4496243qtu.23.2021.02.11.12.01.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 12:01:36 -0800 (PST) From: Thara Gopinath To: herbert@gondor.apana.org.au, davem@davemloft.net, bjorn.andersson@linaro.org Cc: ebiggers@google.com, ardb@kernel.org, sivaprak@codeaurora.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 08/11] crypto: qce: skcipher: Improve the conditions for requesting AES fallback cipher Date: Thu, 11 Feb 2021 15:01:25 -0500 Message-Id: <20210211200128.2886388-9-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211200128.2886388-1-thara.gopinath@linaro.org> References: <20210211200128.2886388-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The following are the conditions for requesting AES fallback cipher. - AES-192 - AES-XTS request with len <= 512 byte (Allow messages of length less than 512 bytes for all other AES encryption algorithms other than AES XTS) - AES-XTS request with len > QCE_SECTOR_SIZE and is not a multiple of it Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) -- 2.25.1 diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index 11a2a30631af..2e6ab1d33a31 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -274,14 +274,19 @@ static int qce_skcipher_crypt(struct skcipher_request *req, int encrypt) if (!IS_ALIGNED(req->cryptlen, blocksize)) return -EINVAL; - /* qce is hanging when AES-XTS request len > QCE_SECTOR_SIZE and - * is not a multiple of it; pass such requests to the fallback + /* + * Conditions for requesting a fallback cipher + * AES-192 (not supported by crypto engine (CE)) + * AES-XTS request with len <= 512 byte (not recommended to use CE) + * AES-XTS request with len > QCE_SECTOR_SIZE and + * is not a multiple of it.(Revisit this condition to check if it is + * needed in all versions of CE) */ if (IS_AES(rctx->flags) && - (((keylen != AES_KEYSIZE_128 && keylen != AES_KEYSIZE_256) || - req->cryptlen <= aes_sw_max_len) || - (IS_XTS(rctx->flags) && req->cryptlen > QCE_SECTOR_SIZE && - req->cryptlen % QCE_SECTOR_SIZE))) { + ((keylen != AES_KEYSIZE_128 && keylen != AES_KEYSIZE_256) || + (IS_XTS(rctx->flags) && ((req->cryptlen <= aes_sw_max_len) || + (req->cryptlen > QCE_SECTOR_SIZE && + req->cryptlen % QCE_SECTOR_SIZE))))) { skcipher_request_set_tfm(&rctx->fallback_req, ctx->fallback); skcipher_request_set_callback(&rctx->fallback_req, req->base.flags,