From patchwork Wed Jan 20 18:48:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 367075 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp745659jam; Wed, 20 Jan 2021 11:19:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJxz1C9jSCr5wEck/lnIK1yEV3AYeKMQ0N/0OJaOoK70Hu2WQ7El5PTOI1bj8b7G0bImeoJi X-Received: by 2002:a50:9f4d:: with SMTP id b71mr8500022edf.310.1611170371499; Wed, 20 Jan 2021 11:19:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611170371; cv=none; d=google.com; s=arc-20160816; b=Ho3ewTe3qd4YXL1DSFb5A7iLNE8tz9Nuaz36tmvosblyJs0W7KTg7wBtqbEVIEFPxU 3Owivwhk0Pjb9JEWyR8Po0u6SxJo4EbXFDiHE6gWW7TmI6g3ORKmFJ4ytzf/nm8WZNgb Tu//bPSj6YPjPKv5vtO5FeDMzJEM8E8QCq0TbYlm7peRmIMm5ZpqGvQrQ0t7RqJ+9Yq7 Q/tlVXhfpx0qFqnucGZhibbqVPSx5BE+2Z9gmS6LCoBDePMzpuJDdQrTJP7USlp3T762 HisKqRyAZsiNbYaFaRC6dp+ykCKzBtytnbNOSver4XXrRjxSfz/oQ0zcFjoNenP+JtwS tqkA== 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=4ckoNO1YJt5QKI0zTcMaiAvFZHq1fWNUxmCXeDkmSik=; b=zBxdbybIaKE7DXc9K8kjLJ2qDa1cJSkcBeYHrCv/EAqasz4/4YdJCMjnCplBS/HGQf cZzCDYjXoxlmjXWhKj+rj6Kbf0mRqYEFOuB7TpbVnrDrcm+D17+NtvE6VGOMZwc9MUIm 2U4KyJAkNheKvUrcHNYcYKjdJU4vCSKh7zF5LUK8NNLM8Xc3Or7HRPptYpRqVwXKx8CX MyKGnBLvyucrF3y7yYGBDtlnPa2Z+utj6F+9wnk6oVT08sbclkBY7o/0HxqWr2nPveLN GNt8wqJBox/WMU033UX+3gP9CbpCAjHlJOdDTA3K2QlIfxkuOn/QaV0uTzp8F7Mb5ffZ si3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sPpCMyU5; 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 dr2si934728ejc.663.2021.01.20.11.19.31; Wed, 20 Jan 2021 11:19:31 -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=sPpCMyU5; 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 S2391917AbhATTSV (ORCPT + 2 others); Wed, 20 Jan 2021 14:18:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392096AbhATSuu (ORCPT ); Wed, 20 Jan 2021 13:50:50 -0500 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FA7BC061795 for ; Wed, 20 Jan 2021 10:48:50 -0800 (PST) Received: by mail-qt1-x82d.google.com with SMTP id d15so11590267qtw.12 for ; Wed, 20 Jan 2021 10:48:50 -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=4ckoNO1YJt5QKI0zTcMaiAvFZHq1fWNUxmCXeDkmSik=; b=sPpCMyU5a/KbiaJEZnuL75dHd3hNUe5y2Qm6K2Tygsn0dLPHKWCEcibvsA75MTKTpP s8hUQV1RREpcP+iJBh4k2an/TDE6qPYsHXDCH0Lqh74plPbvzyS30bHiIc2iOmTjdySx ZWS4BaBYfaUd3X6oN/ljIJSCwsQ0LaG+JpQdn72u3RspT1sdON+Nw8Ooq/bu9Hx7ucZ5 skjek77aXLjVyShV0pGYb+8CAf50A/aBn+my1BD0OqjNZM1/STccUR6yQTzfHfp+kSjd smA5Z/s1tvK8hafVPNppx08HXa4YUz1SoBnm/5gAF6nNEL0ORirFKAc4F7CAjPH/k1xo e20A== 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=4ckoNO1YJt5QKI0zTcMaiAvFZHq1fWNUxmCXeDkmSik=; b=CpZh1eNPpwIdzBKdoasyJceFNWUeObCDDAaoG3eYyxval5p/yDhF5Ym4HU52OrheWG z5cDwGrLvkq+59FUQtinbAs/PzqXn3d9YRhtyIQMEfsT82xfpklPkQxkDD0nGlwX//+A gZy246A/dKFsb9byLI3eMN7JUuJaG/stSZFLpEJOwFwZbk9OsQChN1+QcFJAi3VIk8A7 cMHC3H59PjbmM/piP7oLZorxG9esQP3VdmpmLv3Fpa6/LhxWYWQImgYzIH5b1R/BPzaK wKtWy6nizZTPL2VExWbhrNFxdcS1D66i9PbXeG7eo+p9me6K56nI7kSbvvCIFvMpDBjT jo+A== X-Gm-Message-State: AOAM530RsRXeSUcR+SRQx6iDzPZdJR8eD1DGeA0hqOgWUO2mHsS/+f50 8dWXplL5jg0G6tvLvmv2t9RdUA== X-Received: by 2002:ac8:5852:: with SMTP id h18mr10039542qth.357.1611168529688; Wed, 20 Jan 2021 10:48:49 -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 w8sm1769903qts.50.2021.01.20.10.48.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 10:48:48 -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 v3 4/6] drivers: crypto: qce: common: Set data unit size to message length for AES XTS transformation Date: Wed, 20 Jan 2021 13:48:41 -0500 Message-Id: <20210120184843.3217775-5-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210120184843.3217775-1-thara.gopinath@linaro.org> References: <20210120184843.3217775-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Set the register REG_ENCR_XTS_DU_SIZE to cryptlen for AES XTS transformation. Anything else causes the engine to return back wrong results. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.25.1 Acked-by: Bjorn Andersson diff --git a/drivers/crypto/qce/common.c b/drivers/crypto/qce/common.c index a73db2a5637f..f7bc701a4aa2 100644 --- a/drivers/crypto/qce/common.c +++ b/drivers/crypto/qce/common.c @@ -295,15 +295,15 @@ static void qce_xtskey(struct qce_device *qce, const u8 *enckey, { u32 xtskey[QCE_MAX_CIPHER_KEY_SIZE / sizeof(u32)] = {0}; unsigned int xtsklen = enckeylen / (2 * sizeof(u32)); - unsigned int xtsdusize; qce_cpu_to_be32p_array((__be32 *)xtskey, enckey + enckeylen / 2, enckeylen / 2); qce_write_array(qce, REG_ENCR_XTS_KEY0, xtskey, xtsklen); - /* xts du size 512B */ - xtsdusize = min_t(u32, QCE_SECTOR_SIZE, cryptlen); - qce_write(qce, REG_ENCR_XTS_DU_SIZE, xtsdusize); + /* Set data unit size to cryptlen. Anything else causes + * crypto engine to return back incorrect results. + */ + qce_write(qce, REG_ENCR_XTS_DU_SIZE, cryptlen); } static int qce_setup_regs_skcipher(struct crypto_async_request *async_req,