From patchwork Wed Feb 3 14:32: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: 375413 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp388856jah; Wed, 3 Feb 2021 06:35:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJywEccgbjYIuU6IjVR/WU/FDV9nKlD5b1SuTHffaArDEEiCBh3Js6wp59L3K1OKPudA8cjN X-Received: by 2002:a50:fd84:: with SMTP id o4mr3224368edt.340.1612362911716; Wed, 03 Feb 2021 06:35:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612362911; cv=none; d=google.com; s=arc-20160816; b=C0bY/VlJEquGSsAcN8QxmwsGhPZFwmArT6eeUMXNpqgSjN7A7VrTzDmA5DGeJ401S6 UVpha3uGMt3nz7XUxPijUc4Vs4LlBBIn54v5wBKBUMCQw7HkoYwqArwcXF7nEhZshEOY yTPFTbQe1cYp5Sz+GrnheD/gzBNs1M/itPibqjfSg5mQvPvlcTwgZAgYBEEDAcvvB9j9 YGnXvPi7n7JCmhpo06ZBBQWZn7tQiqcI0P7xo4h4emZGZwZPzfFokRM8gQwbTR0/0YBg MG0+DZErQ3VZXCKQODv7JRIl6YH1KvGTtli2p8ztCWWCW20YYFl5cgstgyT3SAP5mgOe ZzlQ== 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=ud736rWi4YDStkQGLZirsnezpcvto+zhQzFWozsJkhA=; b=deINRWzpU6yF2OQz4sMXNTGmbZb6SM1Lx0rn1RD9S1NH48BmbOanNFJfFPsV2yFk83 bScTrYWhOD9YE/1aSmCBapv6iZnsUYCH7NIJhg6KvA8T9KgdrBGfgTBeFLsYypwkKik8 YSQzhGRyJYRcKYwyvLHf2c98GZm5ZkmK6gxbl0x+7+qm1/ruLLrVNoi8gHqiT6/KnWR+ 3o+zNlauXhHqOQgZRwT78axzOxqcozJE27XLocECmw1wAByWt0lvK+hLONQ8WLnD0/hq TRMS0qJ0HaMMFIoYsnrXxeirY+jSgU9f7T3rgOWFxL8wu3/aRGlavY/hAhFSxSg+UQuV 9FLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o0CcDUWn; 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 s18si1533688ejd.741.2021.02.03.06.35.11; Wed, 03 Feb 2021 06:35:11 -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=o0CcDUWn; 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 S232773AbhBCOd5 (ORCPT + 2 others); Wed, 3 Feb 2021 09:33:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232317AbhBCOdv (ORCPT ); Wed, 3 Feb 2021 09:33:51 -0500 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F29DC061786 for ; Wed, 3 Feb 2021 06:33:11 -0800 (PST) Received: by mail-qt1-x82b.google.com with SMTP id v3so17669980qtw.4 for ; Wed, 03 Feb 2021 06:33: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=ud736rWi4YDStkQGLZirsnezpcvto+zhQzFWozsJkhA=; b=o0CcDUWn+FgqLVl+GqBu8O5LFJYo0piLJdLfdXdq9PZsNB8/HtSiWrelFpUnVb0Nmc hfTUxezk16C7Hf9A0k7pz1SYyk4+0Xc3K5yt/MzBe7k5EJGxcyw24XJ257uicfuRjSiZ UTJ2OtkobIrWd6ikqqyWvyAobIoLmauHR25VmnIZtcXzWXwXCT0VMo0ALpM+7UtKE1jD ivxHAOfOm6JhTgAs3YMxmUiIE/DSb2Uh4rxduatMMgqP8Z5BP7X2UKVveR+444VB+ctG NmcQjDJEoejF0rxWf73EBQRjAW1wCcQSj5D6ZcH1VoaKIxCW51ECsEjhPbP/fp47DMcr l+UQ== 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=ud736rWi4YDStkQGLZirsnezpcvto+zhQzFWozsJkhA=; b=bsWdkggHmH/au/gPXNmyGi3vdFkm5Tx1q57erTF6tvJStmcPgQOu23Y30uhV5SPY3g jZOinQIgJde58Jl8Lp6dfj0vy1q9+7O//12TxUJbuALjauPg7NL+F2tQyQIi44KXl3kC rHGK3vivDaicr2KJvt2TijBpoaE56yFlJEuNbZic9MkInW1xZcvJyGvFYO8OWHA4UQQs atHXXJJUECehk9EUY26xD9AO8ve2xw1DYMJe2WkSqnqve/Dx5LhyXHQatvZ6Whv3lz7+ GfkWdlF2+Dyd9qkXYxMvW6B1WAidJyFKyDljplVJAZLPeBTC+v+a97KHJ7MG0sFxzzZd 9V5A== X-Gm-Message-State: AOAM530xzd3Wor2O8bppMByYWfJJ836UBzCxcrxqqZMkwRvFCC2ypQMn Xvh0kUMKBLAWbOV//vr2yPchhw== X-Received: by 2002:ac8:508:: with SMTP id u8mr2834615qtg.138.1612362790489; Wed, 03 Feb 2021 06:33:10 -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 v15sm1775433qkv.36.2021.02.03.06.33.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 06:33: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 v4 01/11] crypto: qce: sha: Restore/save ahash state with custom struct in export/import Date: Wed, 3 Feb 2021 09:32:57 -0500 Message-Id: <20210203143307.1351563-2-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203143307.1351563-1-thara.gopinath@linaro.org> References: <20210203143307.1351563-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 --- v3->v4: - Fixed the bug where only two bytes of byte_count were getting saved and restored instead of all eight bytes. Thanks Bjorn for catching this. 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 Reported-by: kernel test robot diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index 61c418c12345..500290b40916 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); + 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 Wed Feb 3 14:32: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: 375415 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp388958jah; Wed, 3 Feb 2021 06:35:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzp++GBSNONuFEGvQGrLUZAR7VTmJmb63+iYG2ho3zciaRamDQitRI1tN61PRY6eWH1uio4 X-Received: by 2002:a17:906:b752:: with SMTP id fx18mr3223746ejb.17.1612362919712; Wed, 03 Feb 2021 06:35:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612362919; cv=none; d=google.com; s=arc-20160816; b=Niom1UtoPUgbHYLPyTQDcZmsZb7FEvueED7ge7BXbI2gJuso2T7Q/pnbhlooGbhHc/ yaVmWX3DPq5Vtm8StO1exLE6vK/Xol4XYLoFmdy1lNa3pDGxSZTJMlYpO8JFV6tXtrc4 1kvJ6Ili1nBMQPc/OhIHVe4IHJUftxIkRpuAqmWSDwQdlABdiKFW665nMkpPX5LBN0th RiuWxXosqs/zVFXXhmiaG4gnn66VJ/vnmN9fC+K6agWVZV3qZ6jxQf+IjLF9K/7Ych57 uxIHH37fHK4sv05CjodRlFoPENUKxLjjFfSZ8L6gr305GFgiJ67t9Zf82FGBFLe0XIaX j4iw== 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=uksNnzHRuWvpXMI4aSId1xngqmQe06fCD5OoPJgAWng=; b=fhk8DAx4hFhyHHIhsKm1lmwTXdjqrxQOrpS1Z3s3+lEYko+46gu4hR6P/IckVcAp4z MQGQBSiUZE5BSgvGwjsu8h6hmFvq+pa4d030IdiBVRmH3FQdfkfnAosxgXonV/N/f9wX rtKgxevIoNKhd6J2+Kn14SkGTvHGQgI11uPUNcHWGsvJrZRiSphLKhC6tVmDiJAKz7FY mYvlCwa6OZxr9IzrA3Xj/k90rUDIsCQTotaIoAk+vtBWmVm2QfF7xjv0iJj7pkDgzRuu N70cfN1zV7bTs4klh7hPGIn8mjJnVoP5VjhXPY1EpOPLh8O5T3YWIGbxqx3pKavwc+hT Yk+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G3cYYZHA; 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 s18si1533688ejd.741.2021.02.03.06.35.19; Wed, 03 Feb 2021 06:35:19 -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=G3cYYZHA; 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 S232848AbhBCOef (ORCPT + 2 others); Wed, 3 Feb 2021 09:34:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232847AbhBCOeb (ORCPT ); Wed, 3 Feb 2021 09:34:31 -0500 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4615EC06178A for ; Wed, 3 Feb 2021 06:33:12 -0800 (PST) Received: by mail-qt1-x835.google.com with SMTP id r20so14075691qtm.3 for ; Wed, 03 Feb 2021 06:33:12 -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=uksNnzHRuWvpXMI4aSId1xngqmQe06fCD5OoPJgAWng=; b=G3cYYZHApyAjGvQh6/bf039aehtbg3lTurFDKjeWPGZHGI9NzSnQI1iVe4t+2grxWo mRU7l01aWIdhQS3gANSX8rvbA8aXnZihjklSln+08vFmdpxYriUdjglEDevluwZBpq6p ul8AB+EA0vUa2f5zIvaGGlPwtTO7sgBxv8iK7lnRJRzLE4nWTp5yAew7QT72DE2j66WN XRyvBu6ivXgM7Ij50VhEzPpQwXRiWQXGjjzS2VsM+j1TmC8+p1oK+Y9R6kMURoayNpZa Ppm/B4yEiYqVb0PJ6tmdR7p8YbcqHQqMjDuJs6F+EkXbjOMZN2HJdS5B4ktrIOQF2ksn aioQ== 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=uksNnzHRuWvpXMI4aSId1xngqmQe06fCD5OoPJgAWng=; b=T7LTwSo2akW1yGZIAln9sQUmEg1Y9oBhcotZZUJAx/Q/onLtAe0t30zA0MmlG/dpRd qwadztg9QBe8Eqcvh7uKWudRQ/xLeN7Vnlo21NLQ+dWfvKbdYOGJnR2zqnbLFgow2JJr 6kLDcghmk2TArbG3cNDkiaSQcwFWS7/6gT+Jkjx304d6b/UG+9IKhqk7MCVH99B0vaJz 6+00wBzNhbihOpb0zndCCoTFG/ain1Wl3SIivBEWaTSIGE124I7LllKQpn/frVhA99Mv Nzi9LeCA/KDZOdfW3sZLy/xW+5FJHT1PPbvo37dBiy5grFbA6ObkNoWU7MeQYSlQZ3yU UcoQ== X-Gm-Message-State: AOAM532nUPqqS8K94N/YokuNsWT3p5yUKhmvhFqogcLhGl/nnZeMFCMB rRyfJnngszNLm09g6lqh5cOtbQ== X-Received: by 2002:ac8:59cd:: with SMTP id f13mr2754307qtf.258.1612362791507; Wed, 03 Feb 2021 06:33: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 v15sm1775433qkv.36.2021.02.03.06.33.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 06:33: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 v4 02/11] crypto: qce: sha: Hold back a block of data to be transferred as part of final Date: Wed, 3 Feb 2021 09:32:58 -0500 Message-Id: <20210203143307.1351563-3-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203143307.1351563-1-thara.gopinath@linaro.org> References: <20210203143307.1351563-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 500290b40916..c8bfa9db07b8 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 Wed Feb 3 14:32: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: 375416 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp388964jah; Wed, 3 Feb 2021 06:35:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxRlw8EeC7+4aZ9Snu0nmbzuRfbqfHNwAMsTvkZHvN9SGYLXpbQzagm7ZFlwvWB7OAQvZg X-Received: by 2002:a17:907:7785:: with SMTP id ky5mr3568738ejc.176.1612362920106; Wed, 03 Feb 2021 06:35:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612362920; cv=none; d=google.com; s=arc-20160816; b=DCBvHweEbZsdS6jid8tSXyCw6zgep+TvZiYgSAS79+cfY/kN1EyL+YFszZGYRwd5Sx +UmIuJDTaxQrDYA1ISawzp6/CoOC+2ieORHsP9EOg+QnoYufB5zBYW7GzFnCeboBl+h2 SaDrIwR+pBIFsybvMaGB3+O+HYAidBYLq7XykT9Bvjdo3FwvFTa5m/MG/j+It3hJoR9K LNuzW3lVy9uKUaQgMUx+KpONIs6Q8r7QyT9c1BsED4Zd6+Dq5LnUuC9NuCI9MlCge5iC XCaLKg5uYYnmaiYsXax1SksgC5FIdF4ifFpBqJRlU28MLxVonaE3lX1R21RpN0oH5IV2 ZWhw== 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=iT1RH/DMaFNlCaUat/QGQx2Cj9iSd7GRWeSBqB4Ro69HeHHAiMAeSXySleIgOWYHQW I3k3ApxbWk016lyoagZ8Yfwx2FORYUQZ8sX2XtVOI8ths5oWEl5JoRgX6tHOxjhRlny2 t04sbBav2F2eHJxYO5h0PUlrt1FZvXhm8DWVWcW9psF01XtXKxi3g/6s9emx++7XrSyT zk1wBmR3OHRKySRTVP0UiwZxVzLXlPz4stmhN+Jlc+vNy6VCzoXjHNrfvzINMi995daP mbrodinf8nMwSMkgLJijla3FCG7lQHpgOcJAdJ2CZ7yxod15g4/LUS3T41wS3oUtTVDS AupA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aFhCdAPN; 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 s18si1533688ejd.741.2021.02.03.06.35.19; Wed, 03 Feb 2021 06:35:20 -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=aFhCdAPN; 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 S232934AbhBCOee (ORCPT + 2 others); Wed, 3 Feb 2021 09:34:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232848AbhBCOeb (ORCPT ); Wed, 3 Feb 2021 09:34:31 -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 2275CC06178B for ; Wed, 3 Feb 2021 06:33:13 -0800 (PST) Received: by mail-qk1-x735.google.com with SMTP id a19so23535452qka.2 for ; Wed, 03 Feb 2021 06:33:13 -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=aFhCdAPN/YL22McZM81VXUVWm6cZq+icW7D7mDIbkcCakVss0d3fBGjUiPMOZP5b/G 1Ikg4/W7bCqt57vQncxOSgchloc7P/uIr+KMadW4jPQaylWz80EyIAgysn4KTB6wfqfJ X5HRK1chHI20yvfOlBqmlz05ztOV+9zVoBaRLu7KMGCP+gwk+nF4FFCne+4wBQh0omJn /dWnDpZABhLyo8WafKD9Egv7Fr44A0QR0nKT9rebhqogKSL9kNhs7HBBKRXZs0SIE7kt 2GIwTHrcTpkeB6kiIJtO2tbLVWtBkrzpExUItfHG9i1RGmZ4R8zGJqYYZCXoO4HG1AoM IqHg== 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=epbMXBai0pZYHEGMEIG223d2uK2pjMvVaRqIGAeg0ZS3/wsRo2q/qAPUd2yT1DpHZh xCJ4sYHtILYmmdbX2XZ+Rwrl3jvtkdyg5sJ7smO+Bs3+0GBWnZ7YA1l7hqSlzqYbBC18 7oa41RZoP5le+Tk3KgQ5zP1mCGD7RNwsOd9VBmqUHTuKHeuLeYVjEmJC1L2B6B8pGQCS 33/19bDHK5BrcejLU1Zhp/tE6nLpncdMToP/YCYtgxOp0S4HkedNM4WCHd0n44JrstVy Fte6qukFPni1LUCBouaEnt8PEU66ZWwYLyFjLICeY6PVO248WcrtHKwAweHllzvsLk8W d++g== X-Gm-Message-State: AOAM533AtI87chiQLJ1FKGBr4gckMpuakpPgjfC7u0HQW3D+afapndSL nI2wTMYZA2KEQiQPgt730wCZMw== X-Received: by 2002:a37:2e87:: with SMTP id u129mr2754756qkh.344.1612362792387; Wed, 03 Feb 2021 06:33:12 -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 v15sm1775433qkv.36.2021.02.03.06.33.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 06:33:11 -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 v4 03/11] crypto: qce: skcipher: Return unsupported if key1 and key 2 are same for AES XTS algorithm Date: Wed, 3 Feb 2021 09:32:59 -0500 Message-Id: <20210203143307.1351563-4-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203143307.1351563-1-thara.gopinath@linaro.org> References: <20210203143307.1351563-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 Wed Feb 3 14:33:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 375418 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp388988jah; Wed, 3 Feb 2021 06:35:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwixXUtNxXVC3sEYsRyS8Oyc/EjCVcOiqRihPswDwtTEVhFpm8KiglSSZEVjCpvkP7z6wfb X-Received: by 2002:a17:906:854f:: with SMTP id h15mr3402600ejy.2.1612362921656; Wed, 03 Feb 2021 06:35:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612362921; cv=none; d=google.com; s=arc-20160816; b=L8Xlasc1NTXaEBoq4aYRmDaMoHpElq4wm0FvqgoIeS3g7oRd1MSUzSupMykFj9u5NX p8TnAgVclpicuns9rD33qOA44fpxORXRwoZFkFJov1Lj+53cTQREo4itIDg+8YD7frst X0ijE/LfnYQOIr4SBfEdRX0I90wa4g5N8lRAKYgpsmm3xwnDTkm0cF9kIn3l/TfzGs6r Ly8kuDRLG0PZRN/mYMpRHTFDC/hmcxUZE/gOyWo5heXdYMXOuP/Rjf249XyfXp1WeUOJ SfDUKYxsNaGJOMlKHdr3c2M1jPjobxHdV7ceRZ9gzv2eNrY88qIFJ5z0PHRGx/dtxTCV ExpQ== 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=oCP8Ao4Cl02o2t3IrCglTqQeJMmXZKZ48KKWdaRXvgpeHNlsYeF4fbTiZbq3hiiNq5 NGOoJQIGz0OwQckCmh1El+fIBkUUJTEgRPItSmcTL8Kc+OGt6rDmyK19+wVI5CpI3nBw HtTHR4ezUuI+BQhPBwiy+4thxta9MJSlaRdYYpI3EixFX30buuf918g3nMsMxX6s3pmX fGp3QfgMM/fFc/Gnx6l4Oxs3Nmy7fEt6MjZlU7Jv4q6vBAwKK+14Ogpp2w1SPK3UITSg bM+8f3xoOku3jEobEUA0p3PtFdyJ1Ozah7HkHf2TqJvOW2jXAev6XYnpSKo7fXNwxdCz 3MuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kPOqAcmA; 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 s18si1533688ejd.741.2021.02.03.06.35.21; Wed, 03 Feb 2021 06:35:21 -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=kPOqAcmA; 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 S233017AbhBCOfO (ORCPT + 2 others); Wed, 3 Feb 2021 09:35:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232876AbhBCOec (ORCPT ); Wed, 3 Feb 2021 09:34:32 -0500 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 494A1C061794 for ; Wed, 3 Feb 2021 06:33:14 -0800 (PST) Received: by mail-qt1-x82f.google.com with SMTP id l23so17612508qtq.13 for ; Wed, 03 Feb 2021 06:33:14 -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=kPOqAcmA58UbfVRbvNMjoHECsWtumzrZSpGgU3OVn6nAv7G3Mcwpo0l+v0TDHgHAWq h/3BO0P+bxsfqZkNmnHmGmweFpyD4vjIrWXBtUm7k7AZWH3gqle4hZH7MoFG5pTyunyd al4uvKnxvyQXsFTivJR+zaQLomfR3lHculQ3m+SZ82wQ+/3ByuMFJPmZyteIH8SA7AHy FHd7dsnE3YZt0ujmgRYVqUWrb5wxGhhzhK/QMteP1fmmAXyzpj3HOS4t9SnecMr2eClR u5zFvvjB2wpsidS+sXwejCau6hQUlEB7wv476PurAmJeBu9dFpwkd+6NOElZMQINjU3Y gQ5Q== 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=LRDbUigYUb57bjvRvOBcVMeDp+kgoC8tvjaE3mC695vdPWH8Zcdmra0BE3jQQGo9w5 e6Gtp5DL0s7APkgI1KSFH1HH+YZr7cqWN8bxwddEEPX5kOFnhm0BFHEXUCmWhFt8EXWQ whr7r3NHfyX4AZeh6eOzFRVKbziLUV+IBiz4o2sOTBtLTnzdFQyJYfhuKk0G+tD9CW/h 76+9Vy93kofelGdo1/U+UFAAAwRMYaEnO7Hf2xmpvvTG4rhteASiWDzW6r9nomFTJMES c/Wemx6PJvBmtaUura5zB56GB+fOFAOMPEfkGnvJACKC8tEISl/6A9Wh3Zz+z+ovNxfE Uv3w== X-Gm-Message-State: AOAM532US95fXIoSnpWWdvj6Fbx1pbWXUhxaSIoA5B7hIiPJpUP3TR8A 0vG+2Bzu3+B403PmTyk0UthlrA== X-Received: by 2002:a05:622a:1d4:: with SMTP id t20mr2577064qtw.281.1612362793478; Wed, 03 Feb 2021 06:33:13 -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 v15sm1775433qkv.36.2021.02.03.06.33.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 06:33:12 -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 v4 04/11] crypto: qce: skcipher: Return unsupported if any three keys are same for DES3 algorithms Date: Wed, 3 Feb 2021 09:33:00 -0500 Message-Id: <20210203143307.1351563-5-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203143307.1351563-1-thara.gopinath@linaro.org> References: <20210203143307.1351563-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 Wed Feb 3 14:33:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 375424 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp391262jah; Wed, 3 Feb 2021 06:38:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8evsGYnRj7h8ioIByVfjuz44dttZKmCSy6b+tHYNm+061S9inD4i+MdaXGasqRuQk88Me X-Received: by 2002:a05:6402:5206:: with SMTP id s6mr3197412edd.92.1612363119533; Wed, 03 Feb 2021 06:38:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612363119; cv=none; d=google.com; s=arc-20160816; b=Tuz0ZXki1eaxph2frA0z3+AXQnxRIsITcXP6HnmPvVEMd5h2AH6kXBtnV1P4C4UY87 uhaZDtJBG5pXEU1ZJCjpx7A5lyRfkexzcj5xymjBcpM3eMW9cqNsLQIAIHLo4zFoQlpT 54EvPALsOgVghLB0A5o4mWPCSGi/2YBzkLNyD72ZX7aoVTRZf5neQgG0fN1f9G6NhE5Y uBjDKeiLO5S9XIycpzLezbqTDdP+K2+2tlDREx9h8vMaumKTPEAYwKenwGyebljeioEK NwG8RIMK74gWbbijvQsKUIvxyEvspagcKgUp/2+Ztj0An5UWUWUmmD04ssIMhvJZO4QG BYrQ== 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=YFWM2zrywwE+It6ftOWliiBTZ+3RjB0Yjvmov2OELtg3gkGu7z/zAftRUckJDeXmRM ujX3uHvWtpXM2lvAemNH5fwa2qYiZeixPk3UuPpMprZTVB77tcL7ggkMu6Mt1pl7SyUe /QEbZ4IrZdO7ZZjqaa3X1tojvC/VNR1RF2X4AsSIHkoAE/jhWHl1YYz8mO0T18+2YNFr NgslxePrV3cQH8aFc7dc6Fr36gqKAphar1pD2vsXV6QgzZ2hFjYguECEfIS5GvRyInGV EWNYt79AUhvLCA/y8Q0IFfkSxLpN16SUwHlra1d+0OgDYeliIy+MQVZ9snLqFszlMdtE tetg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QyusuCpE; 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 f12si1438560ejx.333.2021.02.03.06.38.39; Wed, 03 Feb 2021 06:38: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=QyusuCpE; 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 S233026AbhBCOiP (ORCPT + 2 others); Wed, 3 Feb 2021 09:38:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232888AbhBCOec (ORCPT ); Wed, 3 Feb 2021 09:34:32 -0500 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 135CBC0617A7 for ; Wed, 3 Feb 2021 06:33:15 -0800 (PST) Received: by mail-qt1-x82c.google.com with SMTP id r20so14075819qtm.3 for ; Wed, 03 Feb 2021 06:33:15 -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=QyusuCpErLb3kiwVr9cb7mMeO3uuL0Db7UqGjOizoeNDgOIiJ/M0RgYT9/2QInQ5sk mZz0zX/IAcLhwG1US9lLL6FTf4lcACEfU3cfMOTm6JGXT4yZhb+PGp0P4sq27nDVbXyF cUH2bcqdUbycPUSlX5ulcTlp3nHffPGdMMGiwqh+xPy8nObkayALUlIf74etHGX9oXsC eMzBlzkE8NPJeJ3dFNDZzridD/+2DB11X0HMuUlhsY8fFMH+mfJI5XDbBirpoOmmn7XF UF6sSQZJV60jlFHdYilEq9e94moDgIl2nebwBGdOjiG985jACp8OJt/+66cSwB8lrA80 BV1A== 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=djRpl0l28wL97u6MmOjUey+o5Y4ZY0hClNhWVHISE365dtvo5hPAq1lQ0X/9I/VJW/ J8Tb7f65GxQSWRh0PF0Nu+bQBvojO5uemsfe/xrJ8fdsPZnkRqfg2z7S8zAaBauFpZpV SfqPR0yniFV9F06HwBh/PA5uJfTVel7npvSjAHuhh05mQxVWkqpYbHs1H7FrqOZXdzbP WDr+Jaozj4yr6W17+4lMKByzJjMYdKcrosP/Ecd125GDbz4ZAWBDqBHMQUNclBzhWygy PrqJxfzwEj3wjm6Hh1xNfTGdV6qOQ0qHqntZkXvga8ADEHVhaQqXi3nvIXU5vSGV3Yrk RsOw== X-Gm-Message-State: AOAM531qz+d8i/ABjTHdfnHicCRutfp7kdiAnGV0rP7DwttuN0vJneJj zI6WX+WcVZ3ZTTqXyQpIf3BMAQ== X-Received: by 2002:ac8:71d0:: with SMTP id i16mr2581739qtp.349.1612362794339; Wed, 03 Feb 2021 06:33:14 -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 v15sm1775433qkv.36.2021.02.03.06.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 06:33:13 -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 v4 05/11] crypto: qce: skcipher: Return error for zero length messages Date: Wed, 3 Feb 2021 09:33:01 -0500 Message-Id: <20210203143307.1351563-6-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203143307.1351563-1-thara.gopinath@linaro.org> References: <20210203143307.1351563-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 Wed Feb 3 14:33:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 375417 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp388982jah; Wed, 3 Feb 2021 06:35:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5BlcxORVlya/V/Pm9gzKKVQzWm8vmwDyBeR3UlvaofvBU9m1JIr5LqGxl2+cZfnRoGxus X-Received: by 2002:a17:906:854f:: with SMTP id h15mr3402545ejy.2.1612362920960; Wed, 03 Feb 2021 06:35:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612362920; cv=none; d=google.com; s=arc-20160816; b=koPL7Pv/jy5lh6vrkBNYw11rmBNMEiEmpr23cGkt63RvWNGSsYkVsCarM8BnNfFZQz yhOI6A0SUoe3uH9zgeTusPGAaXG5Ty8fE0Nkd6rVxNlICjSnZTeXxUVKNxWRKlim+ira fC/dKprSkUOZOjtDpgTlwUC5Zxce/VLt/NKTbjlM852dbB6d7Y4gX0JU8MgJsyZdWHMS TOTV3SXB4e3xA09N7xhqXirpV1aXvaZpjncywUMc5u68HWeAhNaEq57vw6ewuBkzCBsQ oDg4bp9lAgk/dCGTeDNujvtMhLhP3agfSXBAZefMw9Gokj/ofQoy4eommJpVQPeuISXg hn7g== 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=oAbGBtfCwWWEF4E4+/bXTqZpI5BhpmXZC7MxBaz8FikgO9mYms/e/u6Xd55thHXaiq Fb+xCajMcUR2b+a1CimIxbpsIln39yBnq2zK/FMNBl+LH9UTUYKzk68IBw2Q1KWAc/lR 7gZ6bewKalZnLa/SDCIdt4Df7B3gGIEoMqrL3ACY6QeRu/t1egpR43IUEqOEo90wRs3R rugxRuTEZmhU6egf7FkVbN78hrHW77tKdPLECs+RAsjjXtZhY4lS4PJ0MBZLH09OZ4Ms vVALWh2SekDzENuVgfltGVvlTPyU5Kgr1N9PIBZ/f6+P6KbD15eOGnT0aUxRKeAk+rSB RdCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="NfK/+uIg"; 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 s18si1533688ejd.741.2021.02.03.06.35.20; Wed, 03 Feb 2021 06:35:20 -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="NfK/+uIg"; 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 S233011AbhBCOfM (ORCPT + 2 others); Wed, 3 Feb 2021 09:35:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232903AbhBCOec (ORCPT ); Wed, 3 Feb 2021 09:34:32 -0500 Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46F0CC0617AA for ; Wed, 3 Feb 2021 06:33:16 -0800 (PST) Received: by mail-qt1-x829.google.com with SMTP id e11so30592qtg.6 for ; Wed, 03 Feb 2021 06:33:16 -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=NfK/+uIgybzpmnDkFqO6IuK2o3JDCVPeFz4z0KcAKVxGfIjpB61ZVAIVCWTuHZMRDr YCCQQ6DGFGEC9iGjmUkhfUmgTDKwHPmyuduKipooERCIAhXU6xPPhe+T/Hme3wsVarLn NEkCy1LdJhl8/ZAyHMLbyTBxirDM2GM5y9PLMWJs7J3IrgPzXHbrO2vkJVLmb68KRS7N VThzzQTfRRfP4qyypdVCXGn/P10EzEvdLOUZkF+07StqP5DCdLZ+Xds243DskFNSg1iy cMBn415hgvVfhDai+fL5+R2dX7/zjFTNiXzGsveo70ZeKldXyp6KxwedmIDFSM0NOh6i WZWw== 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=I80rVXG4dZBjRRmd+Pk95d12KgHrdx/3Obhj6ETUinLLnrOY+KyItsDkKaTBc74VZG Go5vev2rYvMspd6pjF/U6K+E5CHV/l/+njQcuoaB4dhRyCtvxCgZNSwGqS7yuh7RcjHE yePUpqnaXVwsYkOhwwiC5Zt3RnUfWv7zqrGa7W1gPgmcGzX8sXVQ7HtKFRETjLEB/k9b QV7W9nTnihLboLsT7xac8bhGHomQzR1sJEMGVTDDjjouvyTv1xn08+iG+oV2CnLqsE9y Sg818eSmumKrhTEN1g6NSxJzbhqL7gguvMnHS+zfUczartQwoxwlee5fTz/h5QJvQxTl EI4g== X-Gm-Message-State: AOAM530VJW3p+Xvjy3csHOyTZw62iSAJwaYn5nKS/cxE2KgSEOqSQsqc WUc/yoN8D0z+sUVHdaCfWxmHIQ== X-Received: by 2002:aed:204d:: with SMTP id 71mr2683694qta.318.1612362795500; Wed, 03 Feb 2021 06:33:15 -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 v15sm1775433qkv.36.2021.02.03.06.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 06:33:14 -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 v4 06/11] crypto: qce: skcipher: Return error for non-blocksize data(ECB/CBC algorithms) Date: Wed, 3 Feb 2021 09:33:02 -0500 Message-Id: <20210203143307.1351563-7-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203143307.1351563-1-thara.gopinath@linaro.org> References: <20210203143307.1351563-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 Wed Feb 3 14:33:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 375421 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp390036jah; Wed, 3 Feb 2021 06:36:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJyH0H1TVYJtzcCDBI43BVRUX/Dr22DKOcWU9Bejx4a7GrF44k3Z2DM6aJSYUBk7TkRGkuvf X-Received: by 2002:aa7:c2c7:: with SMTP id m7mr3250602edp.134.1612363011507; Wed, 03 Feb 2021 06:36:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612363011; cv=none; d=google.com; s=arc-20160816; b=t8miYVpmt3V49h3OmkQcX6+T5Y2QDxSqQGsjzoxpUFGHljsPP5uhyATJ3UB02jwe+j wMJjh3MmcRV9hE7RUlXn0/LKITvgoHlPPK3wjFcIM8+Tif/1cT0Jl1K+WPa3jyJaG3O+ aM+4PXQAqTyecWNG91q0s90t3Cpe1ZHKjMEZyVmDN2EUhAwD23WDZIGxdl8Yg31p1+v3 1AtgwDmFlpXm1Y/VWTYayIknK5b3mN5qZzBoPVg5xZHXtqwgGNESe4AGfWXbeZBBk0oN WHly7FQBnPB65zgFGe8pbi1nE68bpi25aU8t78M2UhkscmAHMwezDpweJ2darfk6VySU Ox8w== 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=Bw29hENcBJAbjBPGbcdTCQNRcfY+6ogVr2iP9iau0gmK7Emv8FoSH6ZhdyAjBuv6sM QmUiSrrP6oqHJZ2Gt5suilx+6mlocgWS4lrx7gnLVEc3QnEvEPwhzAYTAol4831QdiB7 XYPAmicCSoI50hvorAnOtkHvY/3HYTIFmTdzwcIMaFW/WZHYrPJxnRSC4EsIp6ZAVTKK hoLLEhnUs1fNxg/70Pm5/D26UmZ0a2l5+Os3qadJEZVsnc6fFZbIfkxaCQpq8xnTwl4C mXG5UBYpMBL4dNOsOJKsSXzA/oxtwpwz7QvtLGq4rDrnkv3+c+TG5gz7zP81NxF3v14l V2iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="qAx/D5Bi"; 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 y16si647906edq.174.2021.02.03.06.36.51; Wed, 03 Feb 2021 06:36:51 -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="qAx/D5Bi"; 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 S233041AbhBCOfh (ORCPT + 2 others); Wed, 3 Feb 2021 09:35:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232725AbhBCOes (ORCPT ); Wed, 3 Feb 2021 09:34:48 -0500 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36B96C061351 for ; Wed, 3 Feb 2021 06:33:17 -0800 (PST) Received: by mail-qt1-x82c.google.com with SMTP id e11so30628qtg.6 for ; Wed, 03 Feb 2021 06:33:17 -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=qAx/D5BiFOnHn97BwkyayC1pEdlp7lg77Shm0+zyftyMKEovfrABt1m7MxpP79jjje KPXkPgBjt/8U0iwg8lE/T2xE+Dg8QuAhVg/y4pkK0tCUVLamzZLRd578KdhzBlr2Pr4C puSlgFZfFMwbRyCF1ztVHI3blsfqH458We9sol4zp2Pca+ijbrZnCwHk8+aFJU/F5P2p TnJ2MDQ46kEpZdpwD/w+1a1uQ5gvXNE8GYISkqXswP7YbMJ2PW4jfj8dvV1mU4UyjyDb GlqLh0AK8LZpLGV+at6AesnQWxLCw1ZQRZRlpkRdZ3w7JigOo01gOLhl8IXEgyPm6uTC 1cWA== 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=l8tsmZLBYjUQSr8XkLkY9BYtz7uYs7bySlKA9gLncfgaydWmBn5XV424I9tNlfqlEE tKjYTClZV0UC7rlkpqJ5DGfchBlRPAqNQxQ0lYIpoRcdkHTUV1h05RBZNlCVHvBq8hdk qjUKmwxcF/t5hrWPbWofHt2TesVMr2xRKcsV6XS3xIM2wu1lp0ABz+l+iCoI7k4B1Rsk SzIOGP1gnLMp8RQkitBfQGjuAq6ysfV9P9Sm37z6yR9m9aJPnqV40QxK585/RqRkwALb yXEAQ15I6YC/hlqaA+ZYeX1+kRsEhozvZXK/3GeXDRSxRj2xUqIVjt+NFxyLJcuUEzT3 CtGg== X-Gm-Message-State: AOAM531tGku2ebpKXk/5NjXCvC6DBsvU/YBWaWdMEfAnbmpoBVKUZ7cK VgJvOqR+VPzhMUbRw3/ea0KG4Q== X-Received: by 2002:ac8:5ac9:: with SMTP id d9mr2534250qtd.123.1612362796444; Wed, 03 Feb 2021 06:33:16 -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 v15sm1775433qkv.36.2021.02.03.06.33.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 06:33:15 -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 v4 07/11] crypto: qce: skcipher: Set ivsize to 0 for ecb(aes) Date: Wed, 3 Feb 2021 09:33:03 -0500 Message-Id: <20210203143307.1351563-8-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203143307.1351563-1-thara.gopinath@linaro.org> References: <20210203143307.1351563-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 Wed Feb 3 14:33:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 375422 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp390074jah; Wed, 3 Feb 2021 06:36:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNBqvXmTm3HdDQMByGspKJirbMkc1BRaZwG/gMJvbe2r9xzoUVguIn8VYwweerJSJOM6eK X-Received: by 2002:a17:907:961b:: with SMTP id gb27mr3647972ejc.413.1612363014281; Wed, 03 Feb 2021 06:36:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612363014; cv=none; d=google.com; s=arc-20160816; b=y8b4wDUTnjiXUel7sxo27chkpzNggitHBKdetRZfKZJPMcp34YaVmoedP1CRE4DOd/ QRxlnZAeKgjzVTtAf1yUH/g8wr5AbVmIbQUTkz0sAB+QOLHg7Y6bEl9xbJdl1gyzRBpD Y4Dvh3f0MBqgMA7UUxTLfR21XhTdGBC/RkX6UNl/IfBRwyv4BKX9CcdRi44YQArR+m23 p7ZqhlXqbuRH4pjQGWFuz3f2y1QOs0cIcV8wicMZapJ83SldLVyPZoUxsxmESgYF5hQq uMDgsiVJ8LlTOlSe9x6FwOVjSG9hRpzc6IoKQLVd0WRm5+k8KP/Cpt45cv8n3z+9Zsmp l//w== 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=o3SKphSyifY9XIoCwYwvCOIEvMfgvDvQC65+S/SIC+kcig3RQyW6f5zP4RdVO1RtYp jmSKF07ljPA3ZfZnDYx86NQTCZbt+MFd7oTxILgfxI0mvSRy6z9hVOJiD+cekNPo7Mey A4cJp1VnJ+717+c+nagMeRvtnKupdn1UZ3F2bw7iyRbzxriH1nqzNUTNUZHI4FU8aW/u SqPiJIAUPJ1k/KRHsfeea9ZIEgXU1/QCLayF1Nuczd/BeizgWPoAixM+Adewc1RVFsow 6a+vQx8tM37tL19d9/ebaoUn5SQA9RFE3aLPRxJ2IItKM5Yzz19KqBoBjoSpsEvBvtNA OMNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tjXUrpvU; 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 y16si647906edq.174.2021.02.03.06.36.54; Wed, 03 Feb 2021 06:36:54 -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=tjXUrpvU; 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 S232901AbhBCOfm (ORCPT + 2 others); Wed, 3 Feb 2021 09:35:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233014AbhBCOfN (ORCPT ); Wed, 3 Feb 2021 09:35:13 -0500 Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94DDBC061352 for ; Wed, 3 Feb 2021 06:33:18 -0800 (PST) Received: by mail-qt1-x832.google.com with SMTP id n8so9286707qtp.5 for ; Wed, 03 Feb 2021 06:33:18 -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=tjXUrpvU7pHWfvrvXYj/S15x4BbX3W+mjPb6BS8ryOz/85daM47ObxCtHodeYCxQrs 5H2IowtHfDUNpKVD9BWvigJOS4NTjFhJ3PnNxCZhvwcWHbRkVGHHI/DRpNZD2yKnHZjP 5E3hngtmLEV8rcf4BdcUFJUUAGzj3yrCo5aBDdkj9BRSVHsZdZzABtBeidTjwio/YfeI jcdBUdhQNK0gv+EIiSCAHEblbtKVrIjPmeiX5FVLCAflU/5FQKb/4hSuCa/XIpEi7gWP VfGo8MOKtpiWBoKL0NOG8tV4nXEP0IO/HM+ODDmAgp7JZgvKrIVhyROilTzfwTulVxgo +2Sg== 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=ebLB6RF4Fg8uk8wynZDvS/b9CrTVEd2puT/MTEsEY6pyhDOK6Za9WZZpD4i/zyVcTr wMLWEh0Ny6JN/3gRwT4HH2HP+XeoREKWxtW5YJQpuwZ3WlqW39YLq0XhAec2zA9S32E6 53jGCt+g3pkANOJS0/fJNot4C74Y40KzNJvVlG5Zz5ckWoWpbLriL1nJudnZ7AXj96o1 6df+DV1lzmTNSkTJwAeKgThDcFO9isgpJqkZYYAIAMWxsFvOURpdHkCCj/7izLsQ+MSk rwM2X/SCarHeQb8G4cKnWnSJmD/+hsnWsgN9WB672LBUACD3xK9WcwbaTo9JNGvXOqZl k/kA== X-Gm-Message-State: AOAM533PXLog0jGJ7i2esfcNlajql0LORiQKNrjPOZKMkXQPJO1/h/iZ kzhyrgo2N2AW/V/X9Cru0i18KdWgZbTxUw== X-Received: by 2002:ac8:5a0e:: with SMTP id n14mr2670962qta.370.1612362797856; Wed, 03 Feb 2021 06:33:17 -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 v15sm1775433qkv.36.2021.02.03.06.33.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 06:33:17 -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 v4 08/11] crypto: qce: skcipher: Improve the conditions for requesting AES fallback cipher Date: Wed, 3 Feb 2021 09:33:04 -0500 Message-Id: <20210203143307.1351563-9-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203143307.1351563-1-thara.gopinath@linaro.org> References: <20210203143307.1351563-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 Wed Feb 3 14:33:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 375423 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp390087jah; Wed, 3 Feb 2021 06:36:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJx5GSrimWPEJtcMA+ajuc0d/T9XMKZDb+9TMXMPGBryHKsJeQ/jtA+xWu7rIowcN37yIeCP X-Received: by 2002:a17:906:7006:: with SMTP id n6mr3421087ejj.35.1612363014864; Wed, 03 Feb 2021 06:36:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612363014; cv=none; d=google.com; s=arc-20160816; b=gahzV3R8yjHFSH+dOYegzcZHmejH8/Jwkd4NDln/55mTePcsI5S3lbDmzm5ATIl64L EM3c499QHG89jnn5tFWdUdR07x+nE4CBoGT+dqlX5wey19EWPHMo/k1sagm6QEZvmCgo oqLnBEjfpmRaJ3s43NDDUbfoE+QEwzwp/r8Wn24dzZSgeudYw/LP4EE83HOa5HZrvlaL VMOdLhxep5gD0QXnnLtJLKcage+PkcIArW3uCQMI05O1g+B9nusWWm30wZ08c/lSDJwc LPGzTQ09RQlRpm8+iXRRpO6D4zjiJxx5Uwi4ddQ0FCheS1JLDPzHJd0g0VQ7v1OTdhk2 2LbQ== 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=gGrRIr9P/3n/xw6UJ8qlezUH2SiK6rkxEEz+lJJhDWqLzfjNiIJV1UEYBz+sutG019 hq+NsbaHogDh8/3LUGq3hzVjh5ul+qcDhXQglcKvZhGUJOUcv4+SezmkQlVCZRKmo4XR VLvXpfOrwWsASQvEND6k3FmyujBP4n0tWKZ7pzGKQ9leW1eAr6LTitdycdluDxLirOl7 91JI6fMiblOqcjvYWOulvxcoUCPHAGa4iXt9RAigunjME/TQhZ6kF+5jcGdSzKHELBzy 5K392P3I0sC25sC/5gj9zES4akpNE6LPUDCkcdaK7Ig4gSQCXI6X4JF8leOgJWXqSdV9 hUFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fn9CA4Yw; 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 y16si647906edq.174.2021.02.03.06.36.54; Wed, 03 Feb 2021 06:36:54 -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=Fn9CA4Yw; 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 S233014AbhBCOfn (ORCPT + 2 others); Wed, 3 Feb 2021 09:35:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232903AbhBCOfO (ORCPT ); Wed, 3 Feb 2021 09:35:14 -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 A0F6AC061355 for ; Wed, 3 Feb 2021 06:33:19 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id d15so17609650qtw.12 for ; Wed, 03 Feb 2021 06:33:19 -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=Fn9CA4YwyxlXYNEjYdibrpe1DxpcKeD8/v0w0LcbTQArYbUr1mqMEehOF8wsJYUpv6 FBMdrK0DQQVx8JrH+CY1ihpqsT+/ma+PyoAw+0CYQLXmYM6LvFDUZph1/wYQF/7rIF4t 7HcEwqOEQW4AK4YiGOY1bNGUp41ctQael1o+fRjNzz2bQZLh3LoKstrw7TXBVBCjB3v9 ls3zCZM/mMcb2ZKtVXW0GDHzAgSgStI1WO6IIVsBAkTy15kfge32Qm8E9iTu4UdMzxyv 8OXAYTjeRdSKw4tUV0PsGlWcRFz+aBXnJq3WwMul7NyeJKyKgHBruIpa2SEzl7+7QZZl xETA== 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=eSgvSdt3ncVUEJsrim4oIu4RTAchvDt4WUMQseO0H77t+HKkQOqyqwVSFxYFogPkam qu7cM9kZFJWbJcnkZ75ndmdD+lwOD9ijzHykxItdGme7pxo+Gv2Av6zaaQ73+2EXoWO4 rAyl1obQOvFB0eZb0+EeFwg1Ewwg0snDQhmiARH4KrmeBHACxm27ltf4HdM/SQaqCPQH Z4+qUJtxUgruxEc0/thRVxf6a5G2zRGOmTe0jFxMT1NFDCjcJhVAeNePyVAfJT4irvw2 34HsEt5nyvW/N2Qdwon8XSEPeS7lu9XZ4ZnIYsBICTJJ57P9wpovC3q9SX0QgjTXI4xJ hEgw== X-Gm-Message-State: AOAM5337S/7nu8kDRBD/y2rZUhtf4cZSYHx8OM+bzyqTvYJlARWaW2BE 8yVyzEwpCmpJjnnSyEqtj1Nejg== X-Received: by 2002:aed:2f86:: with SMTP id m6mr2580104qtd.253.1612362798885; Wed, 03 Feb 2021 06:33:18 -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 v15sm1775433qkv.36.2021.02.03.06.33.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 06:33:18 -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 v4 09/11] crypto: qce: common: Set data unit size to message length for AES XTS transformation Date: Wed, 3 Feb 2021 09:33:05 -0500 Message-Id: <20210203143307.1351563-10-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203143307.1351563-1-thara.gopinath@linaro.org> References: <20210203143307.1351563-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 Wed Feb 3 14:33:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 375420 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp389114jah; Wed, 3 Feb 2021 06:35:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxoJz6H4Taw22XnpPAnUDQXvm7zAu7JrsTPuEdIx/oaPIK0hjdeG4mi27SUl7gMTHLZbazW X-Received: by 2002:a05:6402:6d6:: with SMTP id n22mr3245758edy.128.1612362932813; Wed, 03 Feb 2021 06:35:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612362932; cv=none; d=google.com; s=arc-20160816; b=vRCu7r1a7RL3GGvaRKi/Mq/Vdjl7Ii6QGbS3dOVK4JOhbO5IVDw3wCQJzTJlMZ80Se /9BfLoQsNURVBmhO93vet+G65xU8F7UhSfU6QnJVworA2TGk6Rl5FliARh86l5DPkVbB Ymu/mqI9V7/mhal7bNvMCqLNLg2gjKwpMQkFwqQkOH+2FNQ6EQD6lNpwSrloZpwceACx XuSKN39Y/S8932+VOHh7S2wqMwfWanWudepqmSlvcoWC89ALJUFHcLfaWYQ+BLK8DE7y iiR6x59IjMO/SeRx54Xbg3O0NjTre9SN9mO1BCuhBWgefANgTHKeDM4lSSjuExTjKZLx Ldkg== 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=Y7PorUcaSHMSd6Q0x998wNyyRcETvt4i2NweAr1uPGEJ0mnBD++FsXanqiThFBDpVD En/PcgoOVrVdU8s9CgbI0SdhxtwDV/ZI+irKvV57FA1HfdfuJt8gtLSvyMt+ksPLDPd6 M8FfsOCOS4A+GaoCV9294T7a9pXC1SAaMh6mf5XR8Kf9wyCHbGKO6E+If8rN+A/cjym/ sg3eNy6FXBXdhb/dAiFZCzRMg5gwdQo98b/HAbH6Gcz1yFX+fHNN2ytNBpBZdBMt9oVZ u00VyW82zR3xT0cLLJT8BHGZyujTchpYkSS+3Ox6Xl3vWWH7GGwjO7J9trzDcggv6pbv XRFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SJdUE6vY; 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 s18si1533688ejd.741.2021.02.03.06.35.32; Wed, 03 Feb 2021 06:35:32 -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=SJdUE6vY; 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 S232791AbhBCOfa (ORCPT + 2 others); Wed, 3 Feb 2021 09:35:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232995AbhBCOet (ORCPT ); Wed, 3 Feb 2021 09:34:49 -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 7DA84C0612F2 for ; Wed, 3 Feb 2021 06:33:20 -0800 (PST) Received: by mail-qt1-x82d.google.com with SMTP id w20so15426251qta.0 for ; Wed, 03 Feb 2021 06:33:20 -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=SJdUE6vYWhFUDqioD70Bas/UqqRLldg90N4oVMpwXEUF6VEH8kh7yyBgzz5rjSx1pJ a2gP2yoiqctYUMtHP9KuGiMKC+5IlB6SY2iujGxSe70FH5ex/qaY+BkgYgFkIn9jttYK wdWPF4nbDZfqW7NxJehEmslBC2Zrrr4YKqpe+NSHxxMaNjH5cADHUkf9euHOeV1VDIjO W2vf2dn2x28Uk708KnYDQSU8ZUh5YyyEAVZu+g+rWZ48Flz62f3ikVMnFjXb9Gtpkz0Q bjSX1nJBc1rYCeGu1A/Z0G+sj0BQJIna4mn3F/NRU7VAw7AK7sPo4FyOJMM/YX9nYIZE ApmQ== 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=hcign7GKEqG6AtXjaxNdgEyWmIN1uDRjB0uG/KsemPdu/EVOeKg4MspGoviK5xR3s+ g1OaGi2WHJ5omPyWYD8aAx+92qt/r9rNebZhcP0hWgpAuITaRev8zuMJUKsGAKlFmNH8 liDM4DLZ71LcwAwkbrqTymOyoXv0h8TFrVLS63MtlevRZkXLOEKSGwWBjHa8gCVtpolp PKf6N+Je+H6Udk9qj6s8nc+xApPfpgSjN+v+RKhqRb6O1rfvyn02ZmLkqCPG/vZ9vG8W fuV34FMTnT5u/jxnHbrgzzK8qtJv9uDH61WstbLGO6aJzx6jtb5haIYX+lVqnNvwUuWj rPUQ== X-Gm-Message-State: AOAM533IVUdCXLYj3U5mgdNr0oh54FqEjjKwitua0oL27LYIWkJsDVCV TYEG2NERECZr8loAQGQSony4Ig== X-Received: by 2002:a05:622a:1d4:: with SMTP id t20mr2577449qtw.281.1612362799777; Wed, 03 Feb 2021 06:33:19 -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 v15sm1775433qkv.36.2021.02.03.06.33.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 06:33:19 -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 v4 10/11] crypto: qce: Remover src_tbl from qce_cipher_reqctx Date: Wed, 3 Feb 2021 09:33:06 -0500 Message-Id: <20210203143307.1351563-11-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203143307.1351563-1-thara.gopinath@linaro.org> References: <20210203143307.1351563-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 Wed Feb 3 14:33:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 375419 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp389108jah; Wed, 3 Feb 2021 06:35:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5uu8A/NlDiczlpVLuNeZsJR/mqvi0pLyVg2yKEj7upwxFyMIZQIcflnWdSVVq29fe8UWj X-Received: by 2002:a17:906:e84:: with SMTP id p4mr3517912ejf.141.1612362932383; Wed, 03 Feb 2021 06:35:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612362932; cv=none; d=google.com; s=arc-20160816; b=tDMxKMvuS3buG1FUDNahT+aw4/m/AQ3tnS0M8tbdQyXKX/5i/mvtLVR1pgPUdPvdmF tcdmM9dATOamWvo3I4fuJQ39euPT+1HKySFQdSZo7grLbzzqIwOWKPM94FKM3yILdw0j Pcu3Ry77fc3ODasIlBvvjV780YSNSbIKKMLuxugD5KU+la4QZh3/nhBkEuzjrn3GQFIn EU4kse2172QIrp7vd4w0LoKiFokklbJeVtkx4XDCnofYkEmrhZOSSbnTZvzed0EFjdXP zt7Yvtnrzjs6taB15P6Jr5hInp3e8vi+h8Oykp1+ptRzSDVpDtGYRy1emNG/OrVhcVxt ZZLw== 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=+9ityeqdgyZLKc/rh27ogHO9y0MwsQMpPeavkRLsNvQ=; b=YEI7sLJkf4d2B2dyKx1Cx7fEfY8NRSU58IPFkVE7kf6kABUY8+3K14vBqj/TjBSYrY tQMu9BH46GCrlDtdE6r68wfBKC8hGqgPbDfRjykEAKpqJkux/nZghqSxFbum4A3wCpK9 l9+hozbkhzmEjJ92Ws/fQ5kEkmG0My9yN2gRWh3+p1h0Nqo0E2syccVI2VckXtfhP8d+ a6qyFf4JoKOBhp4KFItqFj8tY2Mu/cKut17e5OZ1aFxR7Q0bX9LT/z9xd4Ijqg9YZvTx bC7NlCcFFTW5B310pzcfuwXIlBdkiRabUrkDXhcmdlBjwI3uA4RXXhLTx28S1wrFlvGb CNZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mdHhx5CM; 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 s18si1533688ejd.741.2021.02.03.06.35.31; Wed, 03 Feb 2021 06:35:32 -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=mdHhx5CM; 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 S233033AbhBCOf2 (ORCPT + 2 others); Wed, 3 Feb 2021 09:35:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232791AbhBCOeu (ORCPT ); Wed, 3 Feb 2021 09:34:50 -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 0F25AC06121D for ; Wed, 3 Feb 2021 06:33:22 -0800 (PST) Received: by mail-qv1-xf33.google.com with SMTP id w11so11686354qvz.12 for ; Wed, 03 Feb 2021 06:33:22 -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=+9ityeqdgyZLKc/rh27ogHO9y0MwsQMpPeavkRLsNvQ=; b=mdHhx5CMghbS4mbIJhuv/jCQRTCD6rsp4Tu+mdekLjrwDJVgs98SNFcZihdRaRWxHu mySPOHRRNt6SHjC4nplIMJ3ZrNmk5BnoIZEJfyedrkc5cDtZckkFMKVKpYW22QTTITSS ChfjOHBjB47tnVfVNTA3Zorether7ASYW09kx5UC0994BQZ69/sIFmKg05Y3wg2tTyYv VMxV9ZV3eBW5bwiejboxbMrY9rRx6P4lVTIx5uRGafSq0LtF+0WFPhWpVuZAjPJpGlMR w5PmrnMqs2AUhhYNpzDHmSmRDd+tlfMT3svs9g3cwZzdpBZUPD6nlv4Q8jWR9wRTSdha oenw== 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=+9ityeqdgyZLKc/rh27ogHO9y0MwsQMpPeavkRLsNvQ=; b=UUcjFVp6jmdrHhMuJPrZ5XQ+kzH3wp2OBelgzJcu9bMPwQ8hm0ghgsxZCNcBWfHhyA Z4x5EBlyVmW2oykrgzzcoWu7yg1qaDopusTPWHz5+pT1HOKVErbeOjO2jiCK9xMRFrHE 7Jq4KXcKmPyz5cTc+x24TlcuXje83Gp6bzmsz+SzIawpNUF3dv1GiFwNy0bivkmYF8TE bnte8NAK1K2rXxHkbGGZ/+037/IPsL572mVL/QKrV99r69QQ5ohPo55kJwSLlERTgCSx SC6XvoFnuQ3sHmsk9IlZFDVEstFydIqEtdMLR4XsreoCUQOnwfBfEw2oS79tyy6xFZOG dKjA== X-Gm-Message-State: AOAM533dJQRRb6mXnwj/XbhESmLY1RslE+FCcOHltZoS5tgdID2BjgKm kD5PqtQJ9xgmBcbUzymcneNCkA== X-Received: by 2002:a0c:a99e:: with SMTP id a30mr2823309qvb.38.1612362800823; Wed, 03 Feb 2021 06:33:20 -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 v15sm1775433qkv.36.2021.02.03.06.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 06:33:20 -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 v4 11/11] crypto: qce: Remove totallen and offset in qce_start Date: Wed, 3 Feb 2021 09:33:07 -0500 Message-Id: <20210203143307.1351563-12-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203143307.1351563-1-thara.gopinath@linaro.org> References: <20210203143307.1351563-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 c8bfa9db07b8..f6c6275272fc 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;