From patchwork Thu Feb 4 21:43:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 376339 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1655738jah; Thu, 4 Feb 2021 13:46:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGG2D8yV4ylwQACQ65lTZpufuiO7YOQSzDFPKBSTqD1CHCs+QBugOHJU4PWr9XGyjdRo/I X-Received: by 2002:a17:906:17d5:: with SMTP id u21mr1060283eje.109.1612475203032; Thu, 04 Feb 2021 13:46:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612475203; cv=none; d=google.com; s=arc-20160816; b=ONXVUyGEHkGiGZSBs+WfWcD3p8QjuYG/vlCoPPyTFFnNpiVOflR4h2aLwmptEHBQP0 lKmk3QxCSzyvZy9Tr7Zy35blkAaSmkbt21k1Vhx947aDW8AB25NLhk43Ss85hD0LwAqh FUDTLTZQZuckv/W4aC5vtSDDswpOMtZ5WpDDh1PYKFNdSadGhAzdatkJEBNoEjRq5+Gl zp1CPKv1hZstcSrDIWLA8hpcDXiacXC9lFBHj8ZtjsWt9ovKOOy1+nj51EN2EBcg3ePx tXPDZ6whAv6ekv0Wdo9qii19b8MmziDJO/0VOCgPRPwXV8fAqdF2mD5oMkuBmfuH6sIH Yurw== 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=KOavuKeXCTpivEkIf3Cid67Tg4gQisaxPtYIjIwqF5A=; b=rgS02/F2zo1vrF+bQaOpb8ABWo54Vg09KPDRWfgq2NWn7YPl2P6I2YJnN/Zyf++JoW d48/QKpW8zsAI8Rzf47SGyt36CWKycN9EIn5ovlRrNhjLWI63U0i3+8P16DzStBDf3yM F7sbTZ1m6kVqFCEVA+NWdfT7N/RCqx1Y9ffSISua4tjfqJta/XBnSt0PwuzzS7+TgTMg V2ssHuUXPsorqRW/H3UvBY9VvZlnryggLcsafmk1SvUR9B/y2/ae4eKsoj2j93ldmpfR t3CNar2x+/usn8Mg+xeFPQhX8hIH/33l+frN6OaYEnJYCBuEuhMxu94IOyZoWb4Rphk2 vPsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NPi6B5Ge; 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 j4si3983455ejv.17.2021.02.04.13.46.42; Thu, 04 Feb 2021 13:46:43 -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=NPi6B5Ge; 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 S230153AbhBDVpu (ORCPT + 2 others); Thu, 4 Feb 2021 16:45:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230127AbhBDVpo (ORCPT ); Thu, 4 Feb 2021 16:45:44 -0500 Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8E20C06121F for ; Thu, 4 Feb 2021 13:44:08 -0800 (PST) Received: by mail-qv1-xf34.google.com with SMTP id j13so2487382qvu.10 for ; Thu, 04 Feb 2021 13:44:08 -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=KOavuKeXCTpivEkIf3Cid67Tg4gQisaxPtYIjIwqF5A=; b=NPi6B5Gezo05TbeR+EcOfPoFg/pw7If1e3RInE7Jmrx4CxNsD8bfMF70v2XvWJTMWF JMv+lw8DZ6u6tPwSEdPRh+mgTva4Tz7vB49GetLQghyY6LUZoV7oeT9XsO2GVVf0g6Ig re1ksST7JCk0boamf4+FYG/3s/prT/QPwcYqNtk6XZNdVW374eID8nDWrVsEGYBBGZEC lBftR+NzInUVKNBtsjRzSjIRPdQyA9mSX0XnjISpYzkQm4iWdFR/XWYCSYjWjE1TnJWf fWfL+fGS2wVcPuMNYbZdBIJfnqYclnHEf/ieLqfiqTyZIBiMYKMfnj4JvZdicJERanT/ 4irA== 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=KOavuKeXCTpivEkIf3Cid67Tg4gQisaxPtYIjIwqF5A=; b=YNqQ5Wq/2ThMWaY6UxFP5Pzm2tUYpylDfZjxEePGlkrPTraLewX8ttnn5KmQdMTWmL gTG2szS23Bz4NIm7edBeXc5cpm0bb3BBNHZVg+bjC1Kthwvpaln50Bso0qnzoU13qGEb 2iUBYMy1PjfQGQXU7WVjMGDzFbUWacDVuaY2mMhTAjczdsr3ZJSU3Sj0RfXwl7y2RhgC PyP/Y6Fv0roAlvXwsznaqD3A2KAzSedlkyB1ZgJzrGtjBoFHtdEPRS88HoBG4Ym5ko/t skVXQrJx9GTPUoG1RnMzqka9mmsNXQE5nKaQ9OzDBRpiWYBrrOy/GVoFgvGmHsFcjGkq +6nA== X-Gm-Message-State: AOAM532Mcp0M4ModOE+Dr5fcJdRNVt5PwZxkbS5TBPJ2OppaFUg2SIvT DSN2rTahvFGK99HZZNMKHHYndA== X-Received: by 2002:a05:6214:949:: with SMTP id dn9mr1319029qvb.35.1612475048140; Thu, 04 Feb 2021 13:44:08 -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 h185sm6353858qkd.122.2021.02.04.13.44.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 13:44:07 -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 v5 08/11] crypto: qce: skcipher: Improve the conditions for requesting AES fallback cipher Date: Thu, 4 Feb 2021 16:43:56 -0500 Message-Id: <20210204214359.1993065-9-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210204214359.1993065-1-thara.gopinath@linaro.org> References: <20210204214359.1993065-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 10e85b1fc0fd..8599250946b7 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -277,14 +277,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,