From patchwork Thu Feb 4 21:43:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 376335 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1654929jah; Thu, 4 Feb 2021 13:45:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwmzwaDtg6RQBHPWPis7dEIcqIPBD6cz1/lBkmPtViSGWBOvlpgtZYjWKad7c3r1WpigSa4 X-Received: by 2002:a17:906:259a:: with SMTP id m26mr1055648ejb.399.1612475109930; Thu, 04 Feb 2021 13:45:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612475109; cv=none; d=google.com; s=arc-20160816; b=v7KrjQHnYfjdHoeDqQKLbU2332fI+rhgSZDTgEw89QggqCVT75ZqChhilpbAYWklf+ GrCxdoj7y11Arbu03n3ojddDYogjseyri7HyPm6WsC2PcTlur8qfsknMQ24bcFUhd7AJ ju+wQdwyZU5muja6ORrx00ruz8eWyQhNXhYHGaNwNQB0CpRYKwXk5uZbwJ5q5r5B8WJE eYLBJBCcJEFszO1f+7bPK+uvWru0ZJDNhM98DnFPlbUD5fWW9NpCfnYaET5CMKd5mpaw UGcqeVAFHsy2ogIr2PPAbKD0bNljHFaY4RX2Ybm4NKCyClD/Ej44FqM2rNkgCyid5+mU 2seg== 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=aN4Ar0ko3Rto1g1pRIsQic5bApXWaoyHtlgB9BLpWjA=; b=b7I17w9uVwSy06timDUE5tLmMvc50m5gJMxTxEx61TxpW11InM080LmBTgVaAI3wx5 tnSn4Wav2UGj8NPC8AZ+B8wXlexpkpEHMm5tTe4ou1bD6Z4WEBoWvCXFqfYCKBsSIFEk Vmjlv4VQKSWbmG55ecWBUxHA3q6YQtqFEqQ0Rp1PSfYNfe+gTOlAgqVlNseZ14XjLt0T okSbsNHvYQsWrXZ5rzlt/UetKE0g99BlW42tvdaDYI6137XvMsUxmkDOJdJmXZhOd/GG fHzEFCUhMnmanc+VjIzMTF9BLcxgKDNaFvu+dN30/sdXRYT+/hcjJIpzbRo6kJNcP8pb s/Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yUMuvKiB; 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 i15si1501760edx.596.2021.02.04.13.45.09; Thu, 04 Feb 2021 13:45:09 -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=yUMuvKiB; 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 S229970AbhBDVo7 (ORCPT + 2 others); Thu, 4 Feb 2021 16:44:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbhBDVon (ORCPT ); Thu, 4 Feb 2021 16:44:43 -0500 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82EF2C06178A for ; Thu, 4 Feb 2021 13:44:02 -0800 (PST) Received: by mail-qk1-x72e.google.com with SMTP id a12so4901292qkh.10 for ; Thu, 04 Feb 2021 13:44:02 -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=aN4Ar0ko3Rto1g1pRIsQic5bApXWaoyHtlgB9BLpWjA=; b=yUMuvKiBaGvWTtXR69jwfs1lH+chT2TiyqXcS9n/roPUX8Qq4e6SzDSN/klWgUgB4t gmrySONcyLl7VpLN3BRQBAh0w66aPu//TWU5yl2BorlRPIYUicZbze8+rv/1CvGbyO8o 4MHJK4QYDnStgmNPo3YPfTlSwogAnWO/ENtPvsix/JNvegprLPF8/nK6ccm1O885I0DD h07aHyRQBnAsUXT+CvQq74oQnFbJld5mOfNlJbPooBBppy3mzgKkhRGC3L8q2GO6FUgU Gwjk5nDy72mCE1OQDIYK1RGT5ha5UlACUhJvh4nEaa0hKj3Kk5xX17aKLq9yPcm++zVW zCiw== 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=aN4Ar0ko3Rto1g1pRIsQic5bApXWaoyHtlgB9BLpWjA=; b=R26ZNa9gQXdocr/aNZZtBVeH/MbcawP2jxjqUimLTp5H20FS+RJdjGqVsbV8vLN5MB g/Il20tj4bxJgF0InTPKTg6hir58s/NVGq1XRKV/rtINEHL4iZX7drFV9jIjGfv1MYAU 8Q4Rx+P2b1ixqpTm9p6ldqE1T01rsGGoy1B8ZAFacDBNrrYRG8zIY2/gBpgd2enmZ3Wv LVUV3Pc73RsYvsF5BS0qoW/7Brlt0AgODQ/bahvC8aq8Om9qKZv98PpabU/jUfUTgvPV kc4wFliU1bWK0DLJuS9FBO0Xv/ThkAUx2HIPdXPpTYKSRjHypCU5TgpzezOvcm1UK2M7 fCmw== X-Gm-Message-State: AOAM532sYBWS065p5U82/sfLC0HhBIi27OuIlAdrjH0zzEsmfoazJ9ao PFIbeASLoU7elaRfISmH+a7kag== X-Received: by 2002:a37:345:: with SMTP id 66mr1245842qkd.358.1612475041699; Thu, 04 Feb 2021 13:44:01 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 13:44:01 -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 01/11] crypto: qce: sha: Restore/save ahash state with custom struct in export/import Date: Thu, 4 Feb 2021 16:43:49 -0500 Message-Id: <20210204214359.1993065-2-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 Export and import interfaces save and restore partial transformation states. The partial states were being stored and restored in struct sha1_state for sha1/hmac(sha1) transformations and sha256_state for sha256/hmac(sha256) transformations.This led to a bunch of corner cases where improper state was being stored and restored. A few of the corner cases that turned up during testing are: - wrong byte_count restored if export/import is called twice without h/w transaction in between - wrong buflen restored back if the pending buffer length is exactly the block size. - wrong state restored if buffer length is 0. To fix these issues, save and restore the partial transformation state using the newly introduced qce_sha_saved_state struct. This ensures that all the pieces required to properly restart the transformation is captured and restored back Signed-off-by: Thara Gopinath --- v4->v5: - Fixed build warning/error in patch for wrong assignment of const pointer as reported by kernel test robot . v1->v2: - Introduced custom struct qce_sha_saved_state to store and restore partial sha transformation. v1 was re-using qce_sha_reqctx to save and restore partial states and this could lead to potential memcpy issues around pointer copying. drivers/crypto/qce/sha.c | 122 +++++++++++---------------------------- 1 file changed, 34 insertions(+), 88 deletions(-) -- 2.25.1 diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index 61c418c12345..7da562dca740 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -12,9 +12,15 @@ #include "core.h" #include "sha.h" -/* crypto hw padding constant for first operation */ -#define SHA_PADDING 64 -#define SHA_PADDING_MASK (SHA_PADDING - 1) +struct qce_sha_saved_state { + u8 pending_buf[QCE_SHA_MAX_BLOCKSIZE]; + u8 partial_digest[QCE_SHA_MAX_DIGESTSIZE]; + __be32 byte_count[2]; + unsigned int pending_buflen; + unsigned int flags; + u64 count; + bool first_blk; +}; static LIST_HEAD(ahash_algs); @@ -139,97 +145,37 @@ static int qce_ahash_init(struct ahash_request *req) static int qce_ahash_export(struct ahash_request *req, void *out) { - struct crypto_ahash *ahash = crypto_ahash_reqtfm(req); struct qce_sha_reqctx *rctx = ahash_request_ctx(req); - unsigned long flags = rctx->flags; - unsigned int digestsize = crypto_ahash_digestsize(ahash); - unsigned int blocksize = - crypto_tfm_alg_blocksize(crypto_ahash_tfm(ahash)); - - if (IS_SHA1(flags) || IS_SHA1_HMAC(flags)) { - struct sha1_state *out_state = out; - - out_state->count = rctx->count; - qce_cpu_to_be32p_array((__be32 *)out_state->state, - rctx->digest, digestsize); - memcpy(out_state->buffer, rctx->buf, blocksize); - } else if (IS_SHA256(flags) || IS_SHA256_HMAC(flags)) { - struct sha256_state *out_state = out; - - out_state->count = rctx->count; - qce_cpu_to_be32p_array((__be32 *)out_state->state, - rctx->digest, digestsize); - memcpy(out_state->buf, rctx->buf, blocksize); - } else { - return -EINVAL; - } - - return 0; -} - -static int qce_import_common(struct ahash_request *req, u64 in_count, - const u32 *state, const u8 *buffer, bool hmac) -{ - struct crypto_ahash *ahash = crypto_ahash_reqtfm(req); - struct qce_sha_reqctx *rctx = ahash_request_ctx(req); - unsigned int digestsize = crypto_ahash_digestsize(ahash); - unsigned int blocksize; - u64 count = in_count; - - blocksize = crypto_tfm_alg_blocksize(crypto_ahash_tfm(ahash)); - rctx->count = in_count; - memcpy(rctx->buf, buffer, blocksize); - - if (in_count <= blocksize) { - rctx->first_blk = 1; - } else { - rctx->first_blk = 0; - /* - * For HMAC, there is a hardware padding done when first block - * is set. Therefore the byte_count must be incremened by 64 - * after the first block operation. - */ - if (hmac) - count += SHA_PADDING; - } + struct qce_sha_saved_state *export_state = out; - rctx->byte_count[0] = (__force __be32)(count & ~SHA_PADDING_MASK); - rctx->byte_count[1] = (__force __be32)(count >> 32); - qce_cpu_to_be32p_array((__be32 *)rctx->digest, (const u8 *)state, - digestsize); - rctx->buflen = (unsigned int)(in_count & (blocksize - 1)); + memcpy(export_state->pending_buf, rctx->buf, rctx->buflen); + memcpy(export_state->partial_digest, rctx->digest, sizeof(rctx->digest)); + export_state->byte_count[0] = rctx->byte_count[0]; + export_state->byte_count[1] = rctx->byte_count[1]; + export_state->pending_buflen = rctx->buflen; + export_state->count = rctx->count; + export_state->first_blk = rctx->first_blk; + export_state->flags = rctx->flags; return 0; } static int qce_ahash_import(struct ahash_request *req, const void *in) { - struct qce_sha_reqctx *rctx; - unsigned long flags; - bool hmac; - int ret; - - ret = qce_ahash_init(req); - if (ret) - return ret; - - rctx = ahash_request_ctx(req); - flags = rctx->flags; - hmac = IS_SHA_HMAC(flags); - - if (IS_SHA1(flags) || IS_SHA1_HMAC(flags)) { - const struct sha1_state *state = in; - - ret = qce_import_common(req, state->count, state->state, - state->buffer, hmac); - } else if (IS_SHA256(flags) || IS_SHA256_HMAC(flags)) { - const struct sha256_state *state = in; + struct qce_sha_reqctx *rctx = ahash_request_ctx(req); + const struct qce_sha_saved_state *import_state = in; - ret = qce_import_common(req, state->count, state->state, - state->buf, hmac); - } + memset(rctx, 0, sizeof(*rctx)); + rctx->count = import_state->count; + rctx->buflen = import_state->pending_buflen; + rctx->first_blk = import_state->first_blk; + rctx->flags = import_state->flags; + rctx->byte_count[0] = import_state->byte_count[0]; + rctx->byte_count[1] = import_state->byte_count[1]; + memcpy(rctx->buf, import_state->pending_buf, rctx->buflen); + memcpy(rctx->digest, import_state->partial_digest, sizeof(rctx->digest)); - return ret; + return 0; } static int qce_ahash_update(struct ahash_request *req) @@ -450,7 +396,7 @@ static const struct qce_ahash_def ahash_def[] = { .drv_name = "sha1-qce", .digestsize = SHA1_DIGEST_SIZE, .blocksize = SHA1_BLOCK_SIZE, - .statesize = sizeof(struct sha1_state), + .statesize = sizeof(struct qce_sha_saved_state), .std_iv = std_iv_sha1, }, { @@ -459,7 +405,7 @@ static const struct qce_ahash_def ahash_def[] = { .drv_name = "sha256-qce", .digestsize = SHA256_DIGEST_SIZE, .blocksize = SHA256_BLOCK_SIZE, - .statesize = sizeof(struct sha256_state), + .statesize = sizeof(struct qce_sha_saved_state), .std_iv = std_iv_sha256, }, { @@ -468,7 +414,7 @@ static const struct qce_ahash_def ahash_def[] = { .drv_name = "hmac-sha1-qce", .digestsize = SHA1_DIGEST_SIZE, .blocksize = SHA1_BLOCK_SIZE, - .statesize = sizeof(struct sha1_state), + .statesize = sizeof(struct qce_sha_saved_state), .std_iv = std_iv_sha1, }, { @@ -477,7 +423,7 @@ static const struct qce_ahash_def ahash_def[] = { .drv_name = "hmac-sha256-qce", .digestsize = SHA256_DIGEST_SIZE, .blocksize = SHA256_BLOCK_SIZE, - .statesize = sizeof(struct sha256_state), + .statesize = sizeof(struct qce_sha_saved_state), .std_iv = std_iv_sha256, }, }; From patchwork Thu Feb 4 21:43:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 376336 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1655710jah; Thu, 4 Feb 2021 13:46:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPRKp923bjZlnKCblu+M3zNDMVp5oF+oqmbsyFmCovfqnj0EToekf06rNiYUTcbuvrdF5r X-Received: by 2002:a17:906:a14e:: with SMTP id bu14mr1051316ejb.303.1612475199972; Thu, 04 Feb 2021 13:46:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612475199; cv=none; d=google.com; s=arc-20160816; b=IIqrRkV8FyzDyoMv3lM1kKa5I/NnRvxuUrxrA6eFQKpbI2agjojjZ+cbU2nRRHLJBS YSJcyb7eeEKuPQEd1Tp6jeVc81hyjQkAHK/2+1YZiPbNfOARKA7wkxWKt9YA2ZuGJx4C S3TxUEEsCNTPTx4+wcFP2zpYHrQtBNJ3fQUlQbu5t36gR2Es0v3tcLwOZok/mLiNeXqX 1e0hErdULNMm7g9nBzM0qtiWoKpUOXPuXPalz9vZ0lsMf9ioFDNHttXPEJrC2kWVGCRO Ei8UBDBvWPeZML3wbydIsRUcZ78nzFY3XlgaPDfrngpFQPlASKyfQ45Usc34yaRemcDp q5Dg== 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=QL7UCH32HRfcwYFo/OihKYejmQ9XVroK1tPKK/3bNQ0=; b=Evj5yuxVaoeQYuBE6FLxZ8C0BG0xz0NHoB4DyWxz5roqyPwHLi7Yt0xGFlKsI8UBnM 6o9Wgh3TPcqdL3GdVJAp2b6odXc7aw5qVBJhSO7YVx3LZQ4MgHC5+vp/Z53XxIe8p4cu PljixKtt1zH2uQFU7nFlctoUx1SxnfcKKzChdDzVD7sQZ9YTgXxMY+0zLv8hLmZDRo44 1sb4Jh2fU7mB/9H4tMF9Fbt+gLVVduqJHTTRDLNNvVyLOnGXP7ZCBO2Z0rPyTOrUK6WZ ILSgSslIGE2v8XS19VPm5HnvGeD8zPwNCVAG0nBk14yo9lCo3FqufAK/A5yrKviwvaBz medA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LnP8z+oM; 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.39; Thu, 04 Feb 2021 13:46:39 -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=LnP8z+oM; 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 S229500AbhBDVpa (ORCPT + 2 others); Thu, 4 Feb 2021 16:45:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229823AbhBDVpX (ORCPT ); Thu, 4 Feb 2021 16:45:23 -0500 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64F0EC06178C for ; Thu, 4 Feb 2021 13:44:03 -0800 (PST) Received: by mail-qk1-x733.google.com with SMTP id n15so4918416qkh.8 for ; Thu, 04 Feb 2021 13:44:03 -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=QL7UCH32HRfcwYFo/OihKYejmQ9XVroK1tPKK/3bNQ0=; b=LnP8z+oMAn848LJIEfdOqDBRJds5HSWKBf6vcIKvI4CiADXTlE+/N/zNNkHCrIhLAY VTnY0I4xXiXCCK5k2VfTkPZn2rie5BlnPXqovi1k1P1LnF23GdUuBQfgx8oYknHJSjYQ wGR3Bt/8er4TGA3nLtM0hHK3K4Z3Pl95Nlhwz6yzWtVgoVIkzAA+lx44rV/cZkM6PWG5 aSGnvDIUsEt16bCvEo6zj/EdwYg+QNp2B7C1vnR5BgxazIQzWS9pp5oTRDdKGpGuxTmj NDdBY0bPPi3X/3nVVvjSzb86atdmKAsX7D+MQIEYE+FPn5rhSny22sSuEeL+KfMo7YMh 499Q== 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=QL7UCH32HRfcwYFo/OihKYejmQ9XVroK1tPKK/3bNQ0=; b=fC8kHmiMvVv9AOHS22tkodMFu7dGjhD+ZddJwaJYK7GPM7JFVfwe4OQw5eXooHDmgb 3bBFVNywbz59n0GLO3uM1xmRqzKEdEBcXSTNUlmxjIlg8XPMFHW8RKpAVyshz8enebMD ycYH4RBaJOaQj+oeavsx4fm2uq2qdLTvFYrBKj3L1kn5wKlwcj5wKkxXz7R1PPFMDhvR ljAiKd+lY07hqEfqtqGAP80CE9ytcXfR2kGqDJGmN/XTMyfHvUa3Q7EoPELD5a70pkRV q4dX7q/bHWUCvh8XsD1q9MmNn26I/TlRrS7S/lDV4ywrR6bdFo6+XuGPi+n8UDabT7Up FlDQ== X-Gm-Message-State: AOAM530lrgdRpTwZh8myASMUPDDd7oPHL9cMqFW2ceoptrLz4/u6Ds/O lORGxDyI057qL1vBuDNyyeuiCw== X-Received: by 2002:a37:a753:: with SMTP id q80mr1285453qke.29.1612475042611; Thu, 04 Feb 2021 13:44:02 -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.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 13:44:02 -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 02/11] crypto: qce: sha: Hold back a block of data to be transferred as part of final Date: Thu, 4 Feb 2021 16:43:50 -0500 Message-Id: <20210204214359.1993065-3-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 If the available data to transfer is exactly a multiple of block size, save the last block to be transferred in qce_ahash_final (with the last block bit set) if this is indeed the end of data stream. If not this saved block will be transferred as part of next update. If this block is not held back and if this is indeed the end of data stream, the digest obtained will be wrong since qce_ahash_final will see that rctx->buflen is 0 and return doing nothing which in turn means that a digest will not be copied to the destination result buffer. qce_ahash_final cannot be made to alter this behavior and allowed to proceed if rctx->buflen is 0 because the crypto engine BAM does not allow for zero length transfers. Reviewed-by: Bjorn Andersson Signed-off-by: Thara Gopinath --- drivers/crypto/qce/sha.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) -- 2.25.1 diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index 7da562dca740..2813c9a27a6e 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -216,6 +216,25 @@ static int qce_ahash_update(struct ahash_request *req) /* calculate how many bytes will be hashed later */ hash_later = total % blocksize; + + /* + * At this point, there is more than one block size of data. If + * the available data to transfer is exactly a multiple of block + * size, save the last block to be transferred in qce_ahash_final + * (with the last block bit set) if this is indeed the end of data + * stream. If not this saved block will be transferred as part of + * next update. If this block is not held back and if this is + * indeed the end of data stream, the digest obtained will be wrong + * since qce_ahash_final will see that rctx->buflen is 0 and return + * doing nothing which in turn means that a digest will not be + * copied to the destination result buffer. qce_ahash_final cannot + * be made to alter this behavior and allowed to proceed if + * rctx->buflen is 0 because the crypto engine BAM does not allow + * for zero length transfers. + */ + if (!hash_later) + hash_later = blocksize; + if (hash_later) { unsigned int src_offset = req->nbytes - hash_later; scatterwalk_map_and_copy(rctx->buf, req->src, src_offset, From patchwork Thu Feb 4 21:43:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 376338 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1655722jah; Thu, 4 Feb 2021 13:46:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJzzKuEgbd+1SF+YwewjsWzStvnLqj8PjamH7PL8Sajv03VI3zZ0JmtqE13L12T0HG/heKKo X-Received: by 2002:a17:907:3da0:: with SMTP id he32mr1047967ejc.265.1612475201452; Thu, 04 Feb 2021 13:46:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612475201; cv=none; d=google.com; s=arc-20160816; b=xYJcDE8jXuuofV8EplJX76/cNnzaUKQLtxV85KEalE575XWuzbtlcf2kj+hH7bClE6 zRv0jM6qg/jgrJ7TvKLLPP6B18s8Q5H9JqXbAwOs2a3wfDGPp+fB0fNwew0vDCKgOfLM 8ShTKwrPG5s8REaOHkgBgTYjdM052UxVEyXwEqo7RjWFD6mPuf8drKEjsvUKoADYYz0t EKjhyV3/m0zin7lSjZeIUCtR9ba8SxqiTu8pEqf2FyqcJk3MQZv4I0jPEm6kCmxQu+XY Ohuj89w7shu8hGNGi6l+4XuUpA65ZA8ZE7W4BmBaclG10EtpMt6bzvDPK/4XcmryNwTR TpyQ== 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=qH6pF/G1SFg+K0bTJv0NKKhaRdQW632kFeXNuGpnkfE=; b=XlL9XGh5xtrQO1n3nZnM52PDB254pVS7N7AWW2wPfyTYMIKkm7LsmOAot9K8/ReKtV jjghABdAIxAO9mW7f0fHlOiiV/eQOWiRkreC1xTKsZ8zT2hqjF2CewZyQsac2/yq5Eik kXdJRN60585rdCKM2FlgKL1K3Ou9lEzR/RGJu21tWqVhqePlVOjzvHuAGngI/ZSjeYpe bQQKpQDjW7pzlT7LOAUOcsBpJH+k3xWHWkXldcY1l5uoAwX0G/9C8DhRf/iz23cbhjuz Ze5Lkjbchk964bsI+waa0dvWk8oADI+xImfSwKUz8Jk4ZAitt9RSsgJfPmmq4B2bHkJk gpsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gbKxS5e8; 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.40; Thu, 04 Feb 2021 13:46:41 -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=gbKxS5e8; 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 S229823AbhBDVpf (ORCPT + 2 others); Thu, 4 Feb 2021 16:45:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230058AbhBDVpX (ORCPT ); Thu, 4 Feb 2021 16:45:23 -0500 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DE82C061794 for ; Thu, 4 Feb 2021 13:44:04 -0800 (PST) Received: by mail-qk1-x72a.google.com with SMTP id t63so4974614qkc.1 for ; Thu, 04 Feb 2021 13:44:04 -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=qH6pF/G1SFg+K0bTJv0NKKhaRdQW632kFeXNuGpnkfE=; b=gbKxS5e8CTLLKMrWTEmfPwRWGpzyjMOngziTQj1g2+TvAFgL9trZ4VXVFANBUJfga5 3oDbRCy5R3qU1bE78K222fxBzdeVY/4cOtLBN/vJLGYpUlJy5hmNZ9dv03gItaiJAbWQ GncNJH3B6AYgpytL3qa98eL+QQaV7blX85Wau42c/ZSCf0lB4LWY66S+VtVjudz4i4Ec XNwDg8jTwxP6CjHfwLDvadYj4h0z7SBgCrTe6otn6oar4OWsg6nMFjSuMG0PyHRwXmTH JDqUmP6q0a4N6WQAmu8jXZXuTOxJpcSb3GEmPrZlVvoJz1o+oViZh0XgYbAJMa+TnGd7 doNw== 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=qH6pF/G1SFg+K0bTJv0NKKhaRdQW632kFeXNuGpnkfE=; b=cPtb8hJSdkxE3nOGALnvmtv6ZgxiJaMCvJC8SmYSFmbixOMkt37Vwcq+IqV1NsDzG2 W0shiPpFMnwuldBXI6jtc2/BFwmVk9WYYE1qouzonMpDurZkkLSX5NHhu0YWwxyJNw77 wM07vmqj15SF06E0cd2HSbm/fHSUmdDF8/gpvilnXl8FgOGEndllpXpRpOxsu7j1A9Ao dmMiJwT6Kt3kKoqRhvjF9z1kWuAw++QOnMkKqUwitlfr2LYyrXNq90iGvA7N+uZZgWJf HaezELSIgcZ+HtDY5cQUojk76gOain7eZZFQCBEjFkDKseA3sBLDh294j54NWyptWB7Q UNSw== X-Gm-Message-State: AOAM531aDdwfzQpVgblef16HVC3iu4vQdwLYicEks2Wccs/PlDO4MI9t PP8gi4m1Orps89VdWV5nFuyQgg== X-Received: by 2002:a05:620a:544:: with SMTP id o4mr1314845qko.285.1612475043441; Thu, 04 Feb 2021 13:44:03 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 13:44:02 -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 03/11] crypto: qce: skcipher: Return unsupported if key1 and key 2 are same for AES XTS algorithm Date: Thu, 4 Feb 2021 16:43:51 -0500 Message-Id: <20210204214359.1993065-4-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 Crypto engine does not support key1 = key2 for AES XTS algorithm; the operation hangs the engines. Return -EINVAL in case key1 and key2 are the same. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index a2d3da0ad95f..12955dcd53dd 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -167,16 +167,33 @@ static int qce_skcipher_setkey(struct crypto_skcipher *ablk, const u8 *key, struct crypto_tfm *tfm = crypto_skcipher_tfm(ablk); struct qce_cipher_ctx *ctx = crypto_tfm_ctx(tfm); unsigned long flags = to_cipher_tmpl(ablk)->alg_flags; + unsigned int __keylen; int ret; if (!key || !keylen) return -EINVAL; - switch (IS_XTS(flags) ? keylen >> 1 : keylen) { + /* + * AES XTS key1 = key2 not supported by crypto engine. + * Revisit to request a fallback cipher in this case. + */ + if (IS_XTS(flags)) { + __keylen = keylen >> 1; + if (!memcmp(key, key + __keylen, __keylen)) + return -ENOKEY; + } else { + __keylen = keylen; + } + + switch (__keylen) { case AES_KEYSIZE_128: case AES_KEYSIZE_256: memcpy(ctx->enc_key, key, keylen); break; + case AES_KEYSIZE_192: + break; + default: + return -EINVAL; } ret = crypto_skcipher_setkey(ctx->fallback, key, keylen); From patchwork Thu Feb 4 21:43:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 376345 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1657652jah; Thu, 4 Feb 2021 13:50:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXtq2oZ2I7XhPflNzgYETElaRN5ntoF5EwmH7BeqencZGsRuzI3wmghgjq23QngPD0xPry X-Received: by 2002:a17:906:9bcd:: with SMTP id de13mr1042113ejc.245.1612475448043; Thu, 04 Feb 2021 13:50:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612475448; cv=none; d=google.com; s=arc-20160816; b=qFSiZONAa89B+m5lnD39t7hZn2yjh/UL6PFK7GoTQaZU93mQRNwl0WHklcwbopHzzh prpQiZK+z6/KHBj7XyApz3cIC58W0/Ne5npEgqNZzJb7j2rO6jkwwa26PcUJeUP+UrSk wC09UZX33GnIJCAqqtHw+Cw5TvBRFkTGR+rBLMzQswh8YrSQ4fWyQYUStxQ9KzDOcVAF sv1RNy3i+wEhwFYm+3OQxm2NKI+MG7d9Q6+sTrlRUreZDEU+Zu/ik8fbcTx8ohm0ptCE rBFVRr5N2x2RXq9g2xsgPjcHsebv4ScnwPqss8weZ0EkKhy7uwqpx7ebLdMGc3peQw08 Rrgg== 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=JO1AHf4uhYw2ez6Ve3o7chTARaAb1KHfpJckn1suQ+U=; b=Cy89DbJm8R2x8sBTSAqc2dFaMzrEjEb89P0uH9NNT4BuzVgvh+yvEtzy1q2aGRvNsE AM6VILGx+r1hwVbqO8GqRzBVSU32KmJMWee2Jek4yFsWdlEyVxsbpO+rOWg7N2sR+BjU bYVLfm/YzZ4JZ7FDGRd45w4s1s+Qzjfr96co1+cZi4TplEqdv6TVG09IZ9leHQxKm68K 2h3yjCohydlPHNE7yBPZ8Qo44sPg6hmEZnakBfQVklX0EStF5/pVmGIc/70WEkGLnp4g c7XQaVdR7y+0yexImttcnfmSt8GBKB8bcT61fzfS1sicv+OsHCOyvvPYv6bx+y3lfy16 Bjbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L5atl3u2; 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 he39si3830778ejc.512.2021.02.04.13.50.47; Thu, 04 Feb 2021 13:50:48 -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=L5atl3u2; 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 S229866AbhBDVuW (ORCPT + 2 others); Thu, 4 Feb 2021 16:50:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230064AbhBDVpY (ORCPT ); Thu, 4 Feb 2021 16:45:24 -0500 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E6C2C0617A7 for ; Thu, 4 Feb 2021 13:44:05 -0800 (PST) Received: by mail-qk1-x735.google.com with SMTP id d85so4929002qkg.5 for ; Thu, 04 Feb 2021 13:44:05 -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=JO1AHf4uhYw2ez6Ve3o7chTARaAb1KHfpJckn1suQ+U=; b=L5atl3u2FShWrNk0KPUgQBmlVFI8trZLK+DuEcZWP0P1LwPq9Kl5pxeU3pyfzKh6kN oD4oYBetvwTOIHy2Tnt+aBmJvlseHBkH6HctukpVUSZoH/MgiQ2PyT0r8aTx7/5FZrs/ 6LQUB2yFXjZ8IAIZGw2cScLTy1OwvS+k2kf0/zlttN00+XG22VEZJimpa4hbif8BFfzJ FDt2mY3WTUsmO7HeJ15MKySQOlocbwcsNxJDYoLbn7fnH9FdeNoFMoK1Pgt0KpU0OXGK ZJeVHEgjmCr5XIiJDlLQJ5i8V0AKbu98wSIUXpCOR6QvsdSTxY90F5JtaO9CjwQUGuzL ZCmA== 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=JO1AHf4uhYw2ez6Ve3o7chTARaAb1KHfpJckn1suQ+U=; b=YfttwysJS0QJR2nBgvh/Es5SfMl7LpS0IWfrhIK0V5xGTeER1BHDIQm7bzLqkrAzcU kMKsgmdJhdGxYO9jlxNTGir/raQKq57SwvZ3cSMJGXiuMkEuptYLaXpCLrwbuo/3Ba9Z vrVajrKZ/r0+hfWODK/MO7iSSgj7xFZRs+DtVnk2TeS6AavfM+1pCOH6m5JPid0Orj06 VFQHcmPQHt7qUnEQktiyUlxe4iVNT7ympAwI4FauxDwTv53L3FYaT+R3rZoaPQQ09cv3 FoFZLYCQUkfLdXaqq00F16I3dHhknWxUSloztH10mMBrDwKLpVzEaZMzO91UYzG5prYy I04w== X-Gm-Message-State: AOAM533Y1KdtSg9avDYvZxwH2Abma1yT0AAF2cacOTKhrQhhGf4alwVE Dn0bEn8d4lPVWUs5jNWffZLoUg== X-Received: by 2002:a37:8dc7:: with SMTP id p190mr1247597qkd.308.1612475044406; Thu, 04 Feb 2021 13:44:04 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 13:44:03 -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 04/11] crypto: qce: skcipher: Return unsupported if any three keys are same for DES3 algorithms Date: Thu, 4 Feb 2021 16:43:52 -0500 Message-Id: <20210204214359.1993065-5-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 Return unsupported if any three keys are same for DES3 algorithms since CE does not support this and the operation causes the engine to hang. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) -- 2.25.1 diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index 12955dcd53dd..de1f37ed4ee6 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -221,12 +221,27 @@ static int qce_des3_setkey(struct crypto_skcipher *ablk, const u8 *key, unsigned int keylen) { struct qce_cipher_ctx *ctx = crypto_skcipher_ctx(ablk); + u32 _key[6]; int err; err = verify_skcipher_des3_key(ablk, key); if (err) return err; + /* + * The crypto engine does not support any two keys + * being the same for triple des algorithms. The + * verify_skcipher_des3_key does not check for all the + * below conditions. Return -ENOKEY in case any two keys + * are the same. Revisit to see if a fallback cipher + * is needed to handle this condition. + */ + memcpy(_key, key, DES3_EDE_KEY_SIZE); + if (!((_key[0] ^ _key[2]) | (_key[1] ^ _key[3])) | + !((_key[2] ^ _key[4]) | (_key[3] ^ _key[5])) | + !((_key[0] ^ _key[4]) | (_key[1] ^ _key[5]))) + return -ENOKEY; + ctx->enc_keylen = keylen; memcpy(ctx->enc_key, key, keylen); return 0; From patchwork Thu Feb 4 21:43:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 376337 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1655718jah; Thu, 4 Feb 2021 13:46:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0Q9ldcwcYnji6eZKtUfYITPs+J2u0jz9XOHGCR4pSREwlkLYFs06KczCUR6NGqf5TcYgD X-Received: by 2002:a50:998f:: with SMTP id m15mr608593edb.342.1612475200641; Thu, 04 Feb 2021 13:46:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612475200; cv=none; d=google.com; s=arc-20160816; b=s08GlwHH9RS6VzTWlmJhSjTQsdKS5DH5zqYwOuWccZtRMkFM1v6pcspFTKSfCpdX+l T+uwpb0Jo6By0Zd+0PeLOuv7Yi3AF1do6OsKrbRoICpR4tjkxTfo3Lysyb2ZusDCkCcx 4znH6dADO9VvyDvJxkMgI60cDs9j2yW0YKYoo6bqJMen9DZ+GrnudkEcIOYkFxBOE67a 6T/OnXYTb/b+f4kyUhnNYJaxfgUzqEGZh7dF4zWlebkl8L8t94TiayV8pnri6qonexxh uL9u6l1wplpDFCIrr4zMQGdtGr/TfwO/YzLPXvv/RkuCkws45zOlURKEO3HexN5ByvSL 5nIA== 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=fbaPzVOJqVBKum7B5yoNy4q+qHm6B45n0RkRe3mNDrc=; b=H3KRwXIXr/OYLu9zWwhOyNMz9b6U0hv0l03eUE9YKeisMOq9HvtVQgxeMQ1OT7SEOE NM+2TmCUqi5xxTaE7iqPto9wuJo2qzqLHQWbfBmfz+/dFNsvxH6fpNT8L83+Wy2/ceGP 0EqRSlLd6MWmwLMyJ9c6h9CRNnC5U3tWWOKG40wOW3QB+tGNd5sTTE6LsQVVW0Slt2SN bOEbMNXQmAEdY3UMxGWlDGlTARjxjOhxcfKVjoqiMSs5dj8EqPk8qq9COJu1Lr4YJe+y dDBytTdJY0Pt0LSh/rPmXaIMWyr5cTjpha5OyVw6on21zY4zp2MZ58oeogYYidH75fzr +HEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kGJX8eyN; 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.40; Thu, 04 Feb 2021 13:46:40 -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=kGJX8eyN; 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 S229513AbhBDVpe (ORCPT + 2 others); Thu, 4 Feb 2021 16:45:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230077AbhBDVpY (ORCPT ); Thu, 4 Feb 2021 16:45:24 -0500 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A7DEC0617A9 for ; Thu, 4 Feb 2021 13:44:06 -0800 (PST) Received: by mail-qk1-x72f.google.com with SMTP id k193so4919307qke.6 for ; Thu, 04 Feb 2021 13:44:06 -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=fbaPzVOJqVBKum7B5yoNy4q+qHm6B45n0RkRe3mNDrc=; b=kGJX8eyN3yi8UlOcJJ6kU9ufahtm5U/YGN/KL9tEJ+qlTwFMpipOSJDa7XCZx8Q2dR Owa3CpMKTbBsV9fBpN5nB+yTvgiICdGsxMVhRPYcVhKf0SQCF1jB4v2iqrHp+348HZNc UcUOxHimAxMBmosQCRTnC73Gj9PrO7ztPQkDr42+QZ1hCQm8VMNNr0GaayO3VW8yS7f3 wWzuMU51Ywf0X+pvisB+l8GMqaH12XN1JuFHoon+U0zNpSLDum6H/Q5V9ph0BJunJrYS GDKt17AvSLpx3BtXwS3OxxFHRTfsNBcEObpX0pDxSv31B1mJVr1vvuNPtZOfadrEGbEC KfPQ== 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=fbaPzVOJqVBKum7B5yoNy4q+qHm6B45n0RkRe3mNDrc=; b=LZ5Wj4f9QBqTbPVbZMRBuWkUYz0XsyFVsFp7+i8RIZ43v64cZiw3ZswTxIEA8XsgE1 BuIX7u+eeMG9+8YcZlsf7ByJeAj+1nigFoxpwu2nMyZp4pn6lhPmotuGjn5TlI+1rTQK y33in7JK8pPHkJG5vPAE+AAOZkf0kk82RT2ebu58dWUWgNebTlKw1pVVsIwZOhoPnHD3 YBXC6SVk11Jg+RZYWjo7r7l8yQH4TTOGQuCCjwO3Nqe4vu0XiHwQ65DILgP6UeiU8pjV JQT5DSX5s5EaQZJ4USDLMAllacXVRd++0m2+/2XsoY4rpxcWWamat1xcDGfJn2hUzdU6 drPQ== X-Gm-Message-State: AOAM531ouyM9Kc/CuSk0JgYZ4F2JKiuh6iCsz1mzUzziI0hBx8/+ncGv YD7UStq0EjHLB9Bc39fcsVdCMw== X-Received: by 2002:a05:620a:158e:: with SMTP id d14mr1263186qkk.111.1612475045331; Thu, 04 Feb 2021 13:44:05 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 13:44:04 -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 05/11] crypto: qce: skcipher: Return error for zero length messages Date: Thu, 4 Feb 2021 16:43:53 -0500 Message-Id: <20210204214359.1993065-6-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 Crypto engine BAM dma does not support 0 length data. Return unsupported if zero length messages are passed for transformation. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.25.1 diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index de1f37ed4ee6..331b3c3a5b59 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -260,6 +261,10 @@ static int qce_skcipher_crypt(struct skcipher_request *req, int encrypt) rctx->flags |= encrypt ? QCE_ENCRYPT : QCE_DECRYPT; keylen = IS_XTS(rctx->flags) ? ctx->enc_keylen >> 1 : ctx->enc_keylen; + /* CE does not handle 0 length messages */ + if (!req->cryptlen) + return -EOPNOTSUPP; + /* qce is hanging when AES-XTS request len > QCE_SECTOR_SIZE and * is not a multiple of it; pass such requests to the fallback */ From patchwork Thu Feb 4 21:43:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 376341 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1655772jah; Thu, 4 Feb 2021 13:46:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrNQw3hFeonroE5W+IJTZtrS+LjKRr9pR0KgHSbBazOv3LykzO7rTpKQ1oNNpFr4Dc7G74 X-Received: by 2002:a17:906:414e:: with SMTP id l14mr1114581ejk.476.1612475207321; Thu, 04 Feb 2021 13:46:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612475207; cv=none; d=google.com; s=arc-20160816; b=sztCzzoLpzRvy4rTibei0l3mo/iCDMk7cw82AaQG2otTmri/CQGwXP4dR4fBXcgqXe VOIQkaEhb1iL04I93JQXngHkk290g9Hv33fH8KSnk2HEuhpWhxQtOZrVELNPlm7Cx9Rv NrTwvdxkdqcP/W9Y8sqlBQQyC/456OFQHAxdL72JVFut8G0cfXegjPP4pEVvq8PlDHzy oLzanDskPwa74dmJ3EEc6E1g/7J3sPSl4Nmt9ihuJNoFWp6EcRGov0jetZKfrqDytsEk mYQe8t1a78NJfIC5LAjncVGI8tG2VF94TWEnMn2wh3JkzYc55Ve0vuJUpTseB4t/eIxg wFcQ== 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=+Uh3JollLTG+dAe2nrFPwv+L2m02OQeUEuYSFXryNKA=; b=pks7OKjxqvPoMCEc9juDx1bZVTBYHo4zIXpi0S8KSxLQtBcMsNlAEgcHK60PV7ZWMq PMj+8lAb3eBOIW0fncrvvKLED27XDfR7M+YKW3txOlyV5xoxitvkEq7owkfyjHHoevWS dNlcp+VbFurhfBvGcBFK+S0QPRXxeZnee5PE0Sq6aLoj3fJ/GzxYZaXExrEGG064jkWX R8CBUmhxH/vHBeXSY9zIvh9XvI9fWPVpTd1DxUYOu87/Yup9OAGbDUsUNPnY5/9REv7B d5WKW/NsI47uY1JVKXJIgvM9tQWLeTJqXy8mRDRyrOiuaubthBA4bFpgh3OXgpscqzL1 RB1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jWvRhrxq; 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.47; Thu, 04 Feb 2021 13:46:47 -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=jWvRhrxq; 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 S230208AbhBDVqM (ORCPT + 2 others); Thu, 4 Feb 2021 16:46:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230098AbhBDVp1 (ORCPT ); Thu, 4 Feb 2021 16:45:27 -0500 Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6BC4C061356 for ; Thu, 4 Feb 2021 13:44:06 -0800 (PST) Received: by mail-qv1-xf35.google.com with SMTP id es14so2507326qvb.3 for ; Thu, 04 Feb 2021 13:44:06 -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=+Uh3JollLTG+dAe2nrFPwv+L2m02OQeUEuYSFXryNKA=; b=jWvRhrxq+HtoVbJ25dNRu4xY6VYR7oLRLfdcUcDb3o6gS7Y9vSJzF128Jsn+iZp069 q2JeXO3v22fmSx2/3k3hUmSS9uqWtZwLlWmQVmLfe6JdRSmRjy3h38i9Zk6q+kO0nRS5 Hx/cTtDxXQBa/I3Okgtk/xYpbKWtUwL5jMSnwp3SQUrCsMWo4e783xGbbaQiPZ9Z58VR AcCu0GNvHBOqpFb4xc4hHfccp2cedZY7CUcQFEv71eyKmRZE6TxfsRWRNkW2CPX+JZAm L7SyL/xhd8rnw8vZtBFhFObWhJ7+vFBI3lkgzBez1/X2pb0EpzKYr89Yoks7r5bB0xFK 0sZA== 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=+Uh3JollLTG+dAe2nrFPwv+L2m02OQeUEuYSFXryNKA=; b=N3qfD//D9QUkNzLIhhqGlX1KLyNluNteBqVGj9ZtnENQzYgkQppScsOUXTF3re3AyZ b/O/QR2ML+mNPQzlScoZDC9WvPy6SnlkEBDmnrvGj9b4G0qaiiqRw/ILE8WgUEvGfaq7 4cjhryDMh+H7BdkbKx3cs6aT+D6vw/iViQrtrbQRm6aMqb4O9Uv4vco5fQOYN0G/N1vf /jBewBt7B7CTF6pI/dUyfTYceIxyyX3J6H89tWC08tCH6j3iTH/RKHa9+5NNp/is7Wzs feh0don9Ze16sH+5FFjOl5Z7qqs+I3ko/V0e/v31T0CIgo/6tgg7euUfnPrHSlr7YRT7 ljlw== X-Gm-Message-State: AOAM5315DkWBFKtJOq49mC25DMD0d5iXA3NnyPzknja1iKnO3Q9qj3KI OYG9LGcQrx76l2HXifHwWOGg3A== X-Received: by 2002:a05:6214:324:: with SMTP id j4mr1547471qvu.53.1612475046183; Thu, 04 Feb 2021 13:44:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 13:44:05 -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 06/11] crypto: qce: skcipher: Return error for non-blocksize data(ECB/CBC algorithms) Date: Thu, 4 Feb 2021 16:43:54 -0500 Message-Id: <20210204214359.1993065-7-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 ECB/CBC encryption/decryption requires the data to be blocksize aligned. Crypto engine hangs on non-block sized operations for these algorithms. Return invalid data if data size is not blocksize aligned for these algorithms. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.25.1 diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index 331b3c3a5b59..28bea9584c33 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -254,6 +254,7 @@ static int qce_skcipher_crypt(struct skcipher_request *req, int encrypt) struct qce_cipher_ctx *ctx = crypto_skcipher_ctx(tfm); struct qce_cipher_reqctx *rctx = skcipher_request_ctx(req); struct qce_alg_template *tmpl = to_cipher_tmpl(tfm); + unsigned int blocksize = crypto_skcipher_blocksize(tfm); int keylen; int ret; @@ -265,6 +266,17 @@ static int qce_skcipher_crypt(struct skcipher_request *req, int encrypt) if (!req->cryptlen) return -EOPNOTSUPP; + /* + * ECB and CBC algorithms require message lengths to be + * multiples of block size. + * TODO: The spec says AES CBC mode for certain versions + * of crypto engine can handle partial blocks as well. + * Test and enable such messages. + */ + if (IS_ECB(rctx->flags) || IS_CBC(rctx->flags)) + 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 */ From patchwork Thu Feb 4 21:43:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 376342 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1655776jah; Thu, 4 Feb 2021 13:46:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJywzjQcJh7oK8M0S/3TTBJNX70mihY9TvkVCO190c4tkka6fe4/rzrGyMMiHmJ+udV2lXXJ X-Received: by 2002:a50:d58c:: with SMTP id v12mr583658edi.71.1612475207662; Thu, 04 Feb 2021 13:46:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612475207; cv=none; d=google.com; s=arc-20160816; b=C3XtyXb6zlXtvRtMdi17g+C3EniYt+0jj7vT+bKU6vabVYKJBZStXt518Ir33Fschi OZduhKLZj4P6qws2vZIP4Kb7R5C1zlhvc6XnwwT6q2OXeS64aob0f6Ae4GQ756liGn6h vstgHIoiqOz2J6VH/fLSXLbU+fOFthTtr5UMethpjHF5/ll32fiiZYztbfInGd8ItBB0 zMt6X/bCYdaC0G9gyXgUunMZUK84yNZYfeU7lHjYU3g5votsdJfaNdphy9AZd4Cq140x FslujVEoxmH5vcscmm9VI0I2gNi340AMXpHF1lUo6kIs+RSsQxAya1ZxRn6B4UuvBaxT o3Gg== 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=KjZ2FfLW1/QZmo1tCtVZh16jkU5d2sBI2rN7J1hvIYw=; b=sQSE3bAeKjlOTGq1oGit7axnUHnSOgk06YLMYTqXhxwI1XeSdZDciU0W7Hx+v+eTtA 1Y6AcbBUzYqTQOX10AQPTKzXK/foAOTGzR+++iNzgXUACwabVqpSslkp8I2IQKUPA8IE SRdt2ySHkmGqpylBVeCVy1b1IdMOxSIxNjRlW7zJB6ebnD4dqEnPqM7se6JVNfUHT9HU Dzl2jC+mHeQc0Ykg2HKPlsFa+RY5e+wpE/SLsXsrhj7o8h6HCQvqCLccQIK8STBMhr9+ yO/7yJ8DRq55iXBsQ5E1/Ov5bhCOwBWlQFWMy93ZBisNEhlZfU08sAAN1eK8OKWJWEAL zN2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g5EgL9oK; 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.47; Thu, 04 Feb 2021 13:46:47 -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=g5EgL9oK; 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 S230098AbhBDVqO (ORCPT + 2 others); Thu, 4 Feb 2021 16:46:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230114AbhBDVp1 (ORCPT ); Thu, 4 Feb 2021 16:45:27 -0500 Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA970C06121C for ; Thu, 4 Feb 2021 13:44:07 -0800 (PST) Received: by mail-qv1-xf2a.google.com with SMTP id l11so2523440qvt.1 for ; Thu, 04 Feb 2021 13:44:07 -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=KjZ2FfLW1/QZmo1tCtVZh16jkU5d2sBI2rN7J1hvIYw=; b=g5EgL9oKkFrP4qrDMqJXWuVtfqL+27lOlV4TwftWzdFlWpIMb6cY1CPR2U7M/CM8r7 EoCtl2w4xW5UovRh4KwzaRDDjowaeSougjpE0WSpQB1/7EVGEd4X0CI577NJkKIqbOdl i5/VH5hfpVECB5EUfIhpUtFXAqaUkR8VOTD3F+mtD2SyuMdVrNmvkGN+fs32lbJVtC/S FX3fC9rRsZ/C/7IcF+R9fxfCliW7b8InuPEypVnzhHv/n8UliqJgCPc3aqTmpNsSyvJd nO812hYm+e5ghRyx+XQtUBgc24kq63WR3lT6jMjS9vPR1ZpO7u9LD+4EGLA6dPo9KxLR VVpQ== 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=KjZ2FfLW1/QZmo1tCtVZh16jkU5d2sBI2rN7J1hvIYw=; b=G4FNa8zM+ltIUome/jTaRw22G3iEMTHYMTo2XfZiLxfvUtP24wXLQwUdJpCI7bGq4t gsBuJjbfsnajDUhqbXCuZvHOaqacsN3S4NZG0IXitrTekpKmtVFS0yOydHSji6QMTKN9 x2A397V+gZeFE4+OGmxGrtJ8/uAXbAeWr3fInZwHNdy5Zj2lyn1z9ZQxnSCxboXw5TiV XClzwwmr7+Dit+opWtbWJGymj6VMHF8sRFFrJ+plbkaigjWCaq+QT8yAv6JIu3Kdn/G3 /o9hCfY5WKTWCMyEjGUixwNKyiqcR7LNaIKM/rJRD4ppGgzZEXVpmYkBu2yXufeMeThY +Ezw== X-Gm-Message-State: AOAM532LOXhIwSeGzQ4syOj0biCKWUAVq3aPLr3U+U8URHdaSDW8cawR e5atEyeUpTmAuD0rQ77j4vwNPQ== X-Received: by 2002:a0c:ffc5:: with SMTP id h5mr1622019qvv.48.1612475047129; Thu, 04 Feb 2021 13:44:07 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 13:44:06 -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 07/11] crypto: qce: skcipher: Set ivsize to 0 for ecb(aes) Date: Thu, 4 Feb 2021 16:43:55 -0500 Message-Id: <20210204214359.1993065-8-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 ECB transformations do not have an IV and hence set the ivsize to 0 for ecb(aes). Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.25.1 diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index 28bea9584c33..10e85b1fc0fd 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -356,7 +356,7 @@ static const struct qce_skcipher_def skcipher_def[] = { .name = "ecb(aes)", .drv_name = "ecb-aes-qce", .blocksize = AES_BLOCK_SIZE, - .ivsize = AES_BLOCK_SIZE, + .ivsize = 0, .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, }, 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, From patchwork Thu Feb 4 21:43:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 376344 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1657641jah; Thu, 4 Feb 2021 13:50:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJx7MTzFQumhp7F075oSfJkIs9Q4SpD0wuquPuf5KFd5ACxajdi2pkX6iUzaXMqWxj9AQbck X-Received: by 2002:a17:906:a0c:: with SMTP id w12mr1049829ejf.211.1612475447356; Thu, 04 Feb 2021 13:50:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612475447; cv=none; d=google.com; s=arc-20160816; b=ii4K9tVV4wuLA63nxYnMhFgy2IgLTJCwQPUhTFs0wfENiq9PmTGD3mI2aPplk5+h7S H1O+Qqn31iophdTVQhYWGGada6y9LOU6f9iECJ2NLPzIRHTNJ1sZ+sR5DGU4XuxqgMkr WPgHoZ+JQkakM2Zw51JSwx4v6WDpFYHQd2y1MxAoyycO/9PHuiRZ1/40at6yxuc4Abcd 9l/b+L4bTQmumcPN4Rr+z2hecAXJOtlbs/aus72gbT8HFTotAv3yJqOKjd2GIdZATUid b7uCLNACLiAHEjBPicwGOYt8e6oIB9OWsPX6MmyleZU8DoUoRW0JYTmO1m7F1XPI7Yil nVxw== 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=H4BViZmMHUNQYYu9VpJJKST4ly897JCfdbGhTeJJKpE=; b=x3JYgKl5fIob1RHChZ5lp6h4yWq5yyB03Q37M8bxdDA7izGcZo0e7R/aS3ohYlYgv7 f57jhX75gSx/BS82jW6XtfyFMVD8G1IJ3NUwIbAfUPZbN9E3MYp9/7OPGmOWlIEfXe9G e+8PgdfCHTu+WtelUSY1/NZrZedl152gfTSLyGilFGkUIxnI6lp+0PTeEAWXIIRIuZ0Q /ovZ84lGzqWTr0qIhWxJeCEstQsYAVktfRtwDinwk4cLH83MfAB558UrkL9j63qZ9PYA nkR7mTs2vCCiJUiq5o7rlDaVvIJTruC7vamkUq2jQRMXSJVtO6/q73KzPeXoNuAjCci4 ExNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qSmPUBrY; 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 he39si3830778ejc.512.2021.02.04.13.50.46; Thu, 04 Feb 2021 13:50:47 -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=qSmPUBrY; 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 S229537AbhBDVuV (ORCPT + 2 others); Thu, 4 Feb 2021 16:50:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230198AbhBDVqJ (ORCPT ); Thu, 4 Feb 2021 16:46:09 -0500 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F044C061221 for ; Thu, 4 Feb 2021 13:44:09 -0800 (PST) Received: by mail-qv1-xf33.google.com with SMTP id r13so2478573qvm.11 for ; Thu, 04 Feb 2021 13:44:09 -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=H4BViZmMHUNQYYu9VpJJKST4ly897JCfdbGhTeJJKpE=; b=qSmPUBrYZyY3E7e0B+TomSazy4rmNtQf+cbA4jP7UBTtDjl9PiOpNAr3+Bqq7oNlt1 VJVc2nQb82J0ITH+RisAG1+YoQiQxXURBSGzutmFYFfXV+ALtlvZD6sh7SsZ2kGu/P4V QbfbZWGT9myU5nsQNwQSONpdrm2lqM/SgULmU/XMJ6UiPsowWnwa7WgZ3B1KnJr2AM8j ddoBalsHmb1Cuxn3qx3JQ+wwscXVwBfWAIkDoYD1EtYFtMUSgNOTzYKnlSwCjE5f+ODz 2PeT5v0smAxAd73MhD8xWAhgHsROXc5Bn6PUNpphasf8wy1VmIRkpjOotBEP8HkcyheM D7uQ== 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=H4BViZmMHUNQYYu9VpJJKST4ly897JCfdbGhTeJJKpE=; b=Kd0gUq77bTIGiqaS97dlLBh87/KufZOdm8c+zOYOhK1CuJhLzleKRxNMUXu8QXNDKZ kbXAd94wlOLXmRADgyXmPoB907Fv8BSOE+yW3PmvWfzB9kXdMSROwud/sTiy/lGD1t69 ifFgGBWElloHluy8HXf1qzzhHvw9fhJyEnEEE+gF9McomloreF8EXsYYHWw/imohXdbC 0QWTu5a/UjHlzXHFYDp9OVx0lpPDqquews6ZNvMj/rziq7lt2q8Q/XphQtx9lCggMltM OGqvQIsO6ZJl2rMWp821jWTUcgtLYSILlf1gOQjTh2ubnij5zvoa4fpVSzeDgVhWX7wn qR9w== X-Gm-Message-State: AOAM531avhY39N9hmRUXBqe4oT5uggB5afgKAVWfjA8k7+/ZqOulpQGN zfyjeW1id85DDOK6NJatLOwNXw== X-Received: by 2002:a05:6214:522:: with SMTP id x2mr1604236qvw.13.1612475048876; 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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 13:44:08 -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 09/11] crypto: qce: common: Set data unit size to message length for AES XTS transformation Date: Thu, 4 Feb 2021 16:43:57 -0500 Message-Id: <20210204214359.1993065-10-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 Set the register REG_ENCR_XTS_DU_SIZE to cryptlen for AES XTS transformation. Anything else causes the engine to return back wrong results. Acked-by: Bjorn Andersson 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 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, From patchwork Thu Feb 4 21:43:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 376343 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1657638jah; Thu, 4 Feb 2021 13:50:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwacMyIBKKq1wmd54IQ/oCxwffIHAT+lnJbTwXcf8vTo/Xg/tMKn44pyL+Fbe29s5unhLHK X-Received: by 2002:a17:906:39c6:: with SMTP id i6mr1082979eje.433.1612475446340; Thu, 04 Feb 2021 13:50:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612475446; cv=none; d=google.com; s=arc-20160816; b=AQTnwsVwj5zEPBXbTSHRb6+iIxjx4wsu9nUEBEkYHu0eY5y0eQg5puk3Xu+7PqXBSN GCqqB0kN7Thb5wUdUL+J3pt+QjQzdkIXq4+CSltgX8MjMkKXmqQ4zkED1mXiECGtbbcm MfRVQWltCqJBX5ROAv+Iuv8WbAZYqJCmfQxMeO/DS8hZvOqqfJI/OliIlUfhFmntsTT+ Wz0fcyn3KfYdoqq680R/ORQAzYpytFgNSPnbEuVWSZLJxd3eDHEgjXP4gok3MefrIXt5 bKWexI0H1h0ggxThhXl14vEmaAJDSSxGd5pJ8z7lUZlo9D2JOwrvKa3uy06sN7vFOYpl dnTQ== 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=YJE2aPOEkLIKEj61l27Ctrd7+4+SFwAw4jzWQDD0G1c=; b=f5vTwPLdlJZiNdSZCYjMkq+L/NpbJM7l7YKLm0H+XUhGh7NLev3MDxJy4Ujg9tejZb FEGC5nsgDWpHak6V2JM2Q6DjTYeB8hxJ6hjOjdc1lw/LzZ7vLyss0ZK35Im4fUM99Eax BLgssJlA4uvK8JK9xPT4GSzia08N+P23at3PBx/bIwvY7fBIfLVJzuAQoU8mI43qYDLB gNFCQy9hIZa+YF9LiXlsZH4ubTo0zFeXgkpNsadAQS8CcmKMtUPVQqCwIXwCz8A8m9Oa tASIOMmNofWCcAp0+dkrEZ0Fa9mYa0xxfpzqByxSKow1BUcf8pDIvKUtH8eYmkQBCdCg h0Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oeTV7brA; 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 he39si3830778ejc.512.2021.02.04.13.50.46; Thu, 04 Feb 2021 13:50:46 -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=oeTV7brA; 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 S229554AbhBDVuU (ORCPT + 2 others); Thu, 4 Feb 2021 16:50:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbhBDVqN (ORCPT ); Thu, 4 Feb 2021 16:46:13 -0500 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AB0AC061223 for ; Thu, 4 Feb 2021 13:44:10 -0800 (PST) Received: by mail-qv1-xf2d.google.com with SMTP id l11so2523491qvt.1 for ; Thu, 04 Feb 2021 13:44:10 -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=YJE2aPOEkLIKEj61l27Ctrd7+4+SFwAw4jzWQDD0G1c=; b=oeTV7brAnPNqzQlfpvHWPIN/2EByLwjB4ekTbsIoy2RKjdwjBERjCGhL/IfkW4K/ZU JcGD9gHoN67JvxbkFoswbR8lV9qF/FWuqxk6onmTMvPmDQBKd3o10vLUq3sQ2g0QnxjQ xSSZwGzTqRhYqZYsHjL9DOUT83eCqiu+FM3BMHtjoKSUZS8d2dTe8A+P/s26IIBSsHGq GmFLeVKUBPIG4s8I07Mdhu9oZKuddSgmwi8lKqODK8lOULkSTMP7MmgQw0w1rNz/IPcO i6orK5sgO0PdUyxhPdHY8KeiREjWthc9ZRiR/RqjN2iR0Yrdh44y8s21iSHxBzCXDn6S YVXQ== 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=YJE2aPOEkLIKEj61l27Ctrd7+4+SFwAw4jzWQDD0G1c=; b=CKiOhNYt782Y+PWf0j9E/Z1IsuwrTyE9tY1BfjgorxDgsw9r4qptCSGMBLxdKAGfva iX1aabi3abVJEQyNmucVjUkoneqZrh/5cY0hlwmFA2TK++QAJmOiFaKqPsEe+F5ewgnn MHXErqU7mmdjuF+wMZgyN+wbd7Uh+pDGyVcEskALM1slc+yn+PJ7v+5iXRKwObJa47Na S92V6MFGBy4lsKBb79YubHgYqwUD962PhbQgILx6Wujvc4uco61Axh+XKjOw9Zfgug8J t/dga9YH9IHv6YmjjinIhot9YryRJcGjdm68SG7pyT3+JHjFYb0UgVjWu8MNxSEYRE5D 0AJQ== X-Gm-Message-State: AOAM531iBaKC8L5mnv8njVaSDDNjbIeO7FfRCkjpkKJb73CH008w7bu9 RshKv2c2pPBfqib8OCccPOH6CA== X-Received: by 2002:a05:6214:613:: with SMTP id z19mr1419357qvw.2.1612475049721; Thu, 04 Feb 2021 13:44:09 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 13:44:09 -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 10/11] crypto: qce: Remover src_tbl from qce_cipher_reqctx Date: Thu, 4 Feb 2021 16:43:58 -0500 Message-Id: <20210204214359.1993065-11-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 src_table is unused and hence remove it from struct qce_cipher_reqctx Signed-off-by: Thara Gopinath --- drivers/crypto/qce/cipher.h | 1 - 1 file changed, 1 deletion(-) -- 2.25.1 diff --git a/drivers/crypto/qce/cipher.h b/drivers/crypto/qce/cipher.h index cffa9fc628ff..850f257d00f3 100644 --- a/drivers/crypto/qce/cipher.h +++ b/drivers/crypto/qce/cipher.h @@ -40,7 +40,6 @@ struct qce_cipher_reqctx { struct scatterlist result_sg; struct sg_table dst_tbl; struct scatterlist *dst_sg; - struct sg_table src_tbl; struct scatterlist *src_sg; unsigned int cryptlen; struct skcipher_request fallback_req; // keep at the end From patchwork Thu Feb 4 21:43:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 376340 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1655759jah; Thu, 4 Feb 2021 13:46:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGEXtiHSfQQRBjJdWIeERmIwHfcnsQbnZ3GA0UEJX8G+2AkIvtIhQ9cfn1VnmrofU7J7wX X-Received: by 2002:a50:9310:: with SMTP id m16mr628228eda.94.1612475205405; Thu, 04 Feb 2021 13:46:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612475205; cv=none; d=google.com; s=arc-20160816; b=LYQ3l6rugZUiMZqD6oyaeXS2HUP28WhcY0EMtPK9jGFOoVTsp+kpVVtEOOEsAkkqZE BZUIsFwUMgaU81vWpY+umQWTa7H9SVAMCo1dYd6HkGe5EA9cUSbRD/OVunYO5b/LIhvC +0WkJ7+62w+P1gkxYJ72of+017ywtUwH5bQrHeySl4IbTYWhCw5gvsIKjMgA3eERzsEY qka2xY9HEd3R/yYoOFkr6CDBbtyS1kVYBHHXwWTZQIKxR1PcixeQL9scN0tvHWJuRPLF hIygRpUQ1cYa3K2j5zuaqtc/5tQWpcsf72UZRa3UX6sd88GQrbg0/5TkGrt4r6WQw/6V MJpA== 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=g2H2M2trN7O+hF5UdQLkbd5BwU/Kqg0aOCrMAr9yvMA=; b=U0K09AQiC+CQ4dVbfRthotXiw6yKLt5C0WKxxG7scnXFUOe+uqJgHC7GJnkpxFRVFC am7YmZ1HtZResgXPyCdcFMC7m8tO8jb+1Kthcub+c8GcasCunEa41PttVShufv3vKZbD BDg38Z1lIHrJLaeSjWY4Ni6eKGZkMROyF9HfpAPbsMs8aoBXgaZZa61LQBzGOsuHeV5u RGcZBh6qVQKKIlhdf7JdKJ5HaFOCMMTy+NFQZiUoRWH6YVfHj83hJ3/MyQT3dBxq1sQv mz9qUXWpylnVuKsK7P0pABYY2L7OcZRLELhjzQiLJLbiemvuxfew6yG/Z7St2X4qNMCS tzMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DN1fAENQ; 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.44; Thu, 04 Feb 2021 13:46:45 -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=DN1fAENQ; 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 S230185AbhBDVp7 (ORCPT + 2 others); Thu, 4 Feb 2021 16:45:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230138AbhBDVps (ORCPT ); Thu, 4 Feb 2021 16:45:48 -0500 Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9D18C061225 for ; Thu, 4 Feb 2021 13:44:11 -0800 (PST) Received: by mail-qv1-xf2f.google.com with SMTP id u16so2492787qvo.9 for ; Thu, 04 Feb 2021 13:44:11 -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=g2H2M2trN7O+hF5UdQLkbd5BwU/Kqg0aOCrMAr9yvMA=; b=DN1fAENQ8vD0G2gYQS+QnNBHTavkKklxLYVg8KfChPMydJuoC/EU+7T+uzg0AzhAm2 ESwVP9BcORzDD35xWtHGz7RlnRi7Ti3XWwNJb2wwt2doLQSfGxSS/DYFHmPyif0kYBtb jQcQlXXRfgMPl26LS2sMhZP/bKdHbutn8vFa5nzb4JM7XG4NUt9KCNiv0qfGMhSeVR3/ C7jmxrZg8i3gfV0mtuHAYvnSVLOq1OJxwUWJ8Jr3hxDDXC19Ni9RI9igQcuzlPk3NvCJ atcfoD+0+30M71J6FdUiVe6VF+a8Ye5JBya/o2j7oAzxCDswl2hhz/e122geO78QoXXK Y4jA== 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=g2H2M2trN7O+hF5UdQLkbd5BwU/Kqg0aOCrMAr9yvMA=; b=SM6OzGvjdfxeTLTmZhNBdBUJ0G6WgWtiGsWi5twaN81fR9zLTnKKvdSJzkFRYqoDFV VhGjXlQrEiDgoCEYab55QEmNSXMXbFzqX6BgydB/mTXuGZ/9G7aPuxUne21VYbpmN4ya XR5Pe12cLwGyxlJU0UV6bF4YicihdrDZb7yErXv4BRx1Lb8zJwu1U729MIWs4ymflEtM gbf3gnJfjp+Gu4BhkUOkLyLorcT3cjeg8Zq3+R++eCsTTWA8QY71HRh8y3/A0ZMHuxTs W78hRFXErmOAw7HHppo3KKGaCP6uvb9/Ga2zI8TUUnKBDb1GQ54VzkGVUQv4t8ijvlF4 JLHQ== X-Gm-Message-State: AOAM533TbYkoHGAd6YyuHjgVJYCVKlYi5vg5h42U4T2l9RGcd66yOpyu +1ZeI9oPNGRWoXXc+IO8QzzdxQ== X-Received: by 2002:ad4:58f1:: with SMTP id di17mr1336680qvb.57.1612475051044; Thu, 04 Feb 2021 13:44:11 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 13:44:10 -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 11/11] crypto: qce: Remove totallen and offset in qce_start Date: Thu, 4 Feb 2021 16:43:59 -0500 Message-Id: <20210204214359.1993065-12-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 totallen is used to get the size of the data to be transformed. This is also available via nbytes or cryptlen in the qce_sha_reqctx and qce_cipher_ctx. Similarly offset convey nothing for the supported encryption and authentication transformations and is always 0. Remove these two redundant parameters in qce_start. Reviewed-by: Bjorn Andersson Signed-off-by: Thara Gopinath --- drivers/crypto/qce/common.c | 17 +++++++---------- drivers/crypto/qce/common.h | 3 +-- drivers/crypto/qce/sha.c | 2 +- drivers/crypto/qce/skcipher.c | 2 +- 4 files changed, 10 insertions(+), 14 deletions(-) -- 2.25.1 diff --git a/drivers/crypto/qce/common.c b/drivers/crypto/qce/common.c index f7bc701a4aa2..dceb9579d87a 100644 --- a/drivers/crypto/qce/common.c +++ b/drivers/crypto/qce/common.c @@ -140,8 +140,7 @@ static u32 qce_auth_cfg(unsigned long flags, u32 key_size) return cfg; } -static int qce_setup_regs_ahash(struct crypto_async_request *async_req, - u32 totallen, u32 offset) +static int qce_setup_regs_ahash(struct crypto_async_request *async_req) { struct ahash_request *req = ahash_request_cast(async_req); struct crypto_ahash *ahash = __crypto_ahash_cast(async_req->tfm); @@ -306,8 +305,7 @@ static void qce_xtskey(struct qce_device *qce, const u8 *enckey, qce_write(qce, REG_ENCR_XTS_DU_SIZE, cryptlen); } -static int qce_setup_regs_skcipher(struct crypto_async_request *async_req, - u32 totallen, u32 offset) +static int qce_setup_regs_skcipher(struct crypto_async_request *async_req) { struct skcipher_request *req = skcipher_request_cast(async_req); struct qce_cipher_reqctx *rctx = skcipher_request_ctx(req); @@ -367,7 +365,7 @@ static int qce_setup_regs_skcipher(struct crypto_async_request *async_req, qce_write(qce, REG_ENCR_SEG_CFG, encr_cfg); qce_write(qce, REG_ENCR_SEG_SIZE, rctx->cryptlen); - qce_write(qce, REG_ENCR_SEG_START, offset & 0xffff); + qce_write(qce, REG_ENCR_SEG_START, 0); if (IS_CTR(flags)) { qce_write(qce, REG_CNTR_MASK, ~0); @@ -376,7 +374,7 @@ static int qce_setup_regs_skcipher(struct crypto_async_request *async_req, qce_write(qce, REG_CNTR_MASK2, ~0); } - qce_write(qce, REG_SEG_SIZE, totallen); + qce_write(qce, REG_SEG_SIZE, rctx->cryptlen); /* get little endianness */ config = qce_config_reg(qce, 1); @@ -388,17 +386,16 @@ static int qce_setup_regs_skcipher(struct crypto_async_request *async_req, } #endif -int qce_start(struct crypto_async_request *async_req, u32 type, u32 totallen, - u32 offset) +int qce_start(struct crypto_async_request *async_req, u32 type) { switch (type) { #ifdef CONFIG_CRYPTO_DEV_QCE_SKCIPHER case CRYPTO_ALG_TYPE_SKCIPHER: - return qce_setup_regs_skcipher(async_req, totallen, offset); + return qce_setup_regs_skcipher(async_req); #endif #ifdef CONFIG_CRYPTO_DEV_QCE_SHA case CRYPTO_ALG_TYPE_AHASH: - return qce_setup_regs_ahash(async_req, totallen, offset); + return qce_setup_regs_ahash(async_req); #endif default: return -EINVAL; diff --git a/drivers/crypto/qce/common.h b/drivers/crypto/qce/common.h index 85ba16418a04..3bc244bcca2d 100644 --- a/drivers/crypto/qce/common.h +++ b/drivers/crypto/qce/common.h @@ -94,7 +94,6 @@ struct qce_alg_template { void qce_cpu_to_be32p_array(__be32 *dst, const u8 *src, unsigned int len); int qce_check_status(struct qce_device *qce, u32 *status); void qce_get_version(struct qce_device *qce, u32 *major, u32 *minor, u32 *step); -int qce_start(struct crypto_async_request *async_req, u32 type, u32 totallen, - u32 offset); +int qce_start(struct crypto_async_request *async_req, u32 type); #endif /* _COMMON_H_ */ diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index 2813c9a27a6e..8e6fcf2c21cc 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -113,7 +113,7 @@ static int qce_ahash_async_req_handle(struct crypto_async_request *async_req) qce_dma_issue_pending(&qce->dma); - ret = qce_start(async_req, tmpl->crypto_alg_type, 0, 0); + ret = qce_start(async_req, tmpl->crypto_alg_type); if (ret) goto error_terminate; diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index 8599250946b7..3fc0b263d498 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -144,7 +144,7 @@ qce_skcipher_async_req_handle(struct crypto_async_request *async_req) qce_dma_issue_pending(&qce->dma); - ret = qce_start(async_req, tmpl->crypto_alg_type, req->cryptlen, 0); + ret = qce_start(async_req, tmpl->crypto_alg_type); if (ret) goto error_terminate;