From patchwork Sat Dec 19 03:30:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 345969 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2710291jai; Fri, 18 Dec 2020 19:32:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+sXibPWOhBVt4zPnH6lk0sIvDUDGtAp3GnTyFpdcHq4N4CZijQehusGJW18RiC4TuOeEU X-Received: by 2002:aa7:db14:: with SMTP id t20mr7325815eds.158.1608348738332; Fri, 18 Dec 2020 19:32:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608348738; cv=none; d=google.com; s=arc-20160816; b=NC0aKgTjNaPGnTYQhs36x2qbTREONvj18B0+avfvD2YrHGfr4hPdHu4xa2utbdU5r2 0Ss8W6dv3dOUvsZlAhbzPdVso+YY1c+A9bZvfgbDnkyT9iZOmPRciMLJoQ5WHDUMSkfh gKKhhfNgIi2VzqAuqJOsCehJxyMWbJDhR0PX/LqLQEo3Ez+jsboiSn3rHTdnUOQc4HnR osntNfOvP/Clc8aoz9CvY4mB0btGCUvVs4bKq5z/tqBypaMjiSNZgJHcRc21AJKZraye pXOytpmh28L6FEP+o8orKx/O00WR1vl5O5s+UN4rtwWcPmdQHV/Vs3WA6D2fFYiedQqT 1iRA== 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=LrTDV1JC3FHqRkPuc+wq4o33QEiL82RGRHhUmIGgN6s=; b=H/pvfJTuP3nToSF0FbaEFqzh254YfGaWgrGppVD7xqk5D7bh0aMm+b82v1lchSWGIs 6fRPyX/sj/3fg1zOS+EBMkdrF1gq4wvPl+7zTuebVaS/IttPpFFditq3V7/yLMPvT4Bg Gc51dKkq/Jp0J3Nsc3p1E7nSSmb0eWWyTsr3J+loU+/Z1Q4Klz2+omhMI5nlPk4cwfnF qGy3mEhOV9QwxJJN4zsuTJxNQXQO2f01XXcVRFq/BoDQNRXw1t+aY8B56VoCpQGRhcjY 4ht8BaqV+Wkj+9QPYVWQ0KbIH7v4prdM+0NbDEi/CDVFHzyjnhJwLmkiIQrrG6zW/Epz r7rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="FV0bA/gl"; 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 s2si7383558eds.424.2020.12.18.19.32.18; Fri, 18 Dec 2020 19:32:18 -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="FV0bA/gl"; 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 S1726221AbgLSDcM (ORCPT + 2 others); Fri, 18 Dec 2020 22:32:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725966AbgLSDbv (ORCPT ); Fri, 18 Dec 2020 22:31:51 -0500 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16771C0611CC for ; Fri, 18 Dec 2020 19:30:34 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id 7so2926112qtp.1 for ; Fri, 18 Dec 2020 19:30:34 -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=LrTDV1JC3FHqRkPuc+wq4o33QEiL82RGRHhUmIGgN6s=; b=FV0bA/glG6mM2oq/0OIUCIVCj6ovoytZ5Qj/7e+wkIWZ2ELS8XCIiKnF6W4r6i7jRT CFWxHpAaKVstazgf50GOecmqvoxJ2c/3Af0zFXqfBCUnWWXQ3csgizyva8ZTedaBRUyp SlbsXze46vnkooO1wMFJVXrx/DLreGecZ7HHnYRpDtxesRsJPbyQiaUGm95dmA1Sa3dj UwcPkuerUDLJjuvenqZZs+gD6LhbxVI9wf19i/Lu9hfL5LGveHHuUCxxb05T7GkrQavn jjMUfR3lwsQfMjOjnOV+SrD3sgnnXrTlpuBtEZawPuKmA0uTzkWQNSg7GdlQ1D/LA+6q iT4A== 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=LrTDV1JC3FHqRkPuc+wq4o33QEiL82RGRHhUmIGgN6s=; b=IyjVbPp9hEYwz3wrrlz8penJ5eHzpyfr8QaTbpVwIVo0nbaObOeWNAmVkXnu7Gv3TP NVeXBn9wBWMl1bIGW4LJzJIQMyyO7dpaZ+zb71uL+giXBw9bz+VTDvQ+7XbZQsEDYl8c +bavyGfPvee1NSIOBBHFrE+dj/3lDVfd5e6S6CsqV3cfYkZeEFM9h7zcW9rbuRLv4TDF BXYUs+ITR6MO8/KEAzJpiL7ZcSu908PVASCH2Eis4fc5Uhevrfl/X5DMENFjGs9IlxFX EE+F8mg5jWOcjAP+Zldb8Um3muA1rbkfrN66W9e7uSW4w5tk6ZZoX0LkzWmuXsbAl5jj p+6w== X-Gm-Message-State: AOAM5318a1TsIRlvQak2mIc+NPTR6QsQCmWzpFiOB/cpzs6frIFdd2tV Q+ho5NRPH8Opvcb/NZF/PSObhg== X-Received: by 2002:ac8:5b82:: with SMTP id a2mr7248502qta.215.1608348633318; Fri, 18 Dec 2020 19:30:33 -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 y16sm4376045qki.132.2020.12.18.19.30.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 19:30:32 -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 4/6] drivers: crypto: qce: common: Set data unit size to message length for AES XTS transformation Date: Fri, 18 Dec 2020 22:30:25 -0500 Message-Id: <20201219033027.3066042-5-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201219033027.3066042-1-thara.gopinath@linaro.org> References: <20201219033027.3066042-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 diff --git a/drivers/crypto/qce/common.c b/drivers/crypto/qce/common.c index 5006e74c40cd..7ae0b779563f 100644 --- a/drivers/crypto/qce/common.c +++ b/drivers/crypto/qce/common.c @@ -294,15 +294,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,