From patchwork Thu Feb 11 20:01:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 381030 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2372245jah; Thu, 11 Feb 2021 12:02:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJxyyakWdxjXyPfKEj3KCP6rZpcwvhYNaxV0ev0me2IDeOb3eTR/wTpIuW+BOCiHGnDCqfEg X-Received: by 2002:a17:906:ff48:: with SMTP id zo8mr10419150ejb.292.1613073755247; Thu, 11 Feb 2021 12:02:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613073755; cv=none; d=google.com; s=arc-20160816; b=EqTcwrmAiwDYZI1gnsA3Z5qdFcTyYCBaraAM+e56QV4FSt3Ihpim3IGjkOmaqJHumz hYcPOhe8hnnYj7cBFDsieBW9kJHeroMpRWIbZggkLYxY/3vTeAjexAtpm6fG6NypmAN/ QyRkZN/083UFCi+fy5OVXiK2PjeilbL4J3BLLCWs51pvfdGnL6IAj1J5ROwrSndLqu2u ifqpTfs4zDTdao8WgYDQty0jdov6a88YIBjHs0Zte8IyoaJK285MvHLOHC2bUis748kn MKxK9JDO17/TexOzON6Uyb9aKJ07qcMIlCsp9t93Ve7BpPRgs9TKRD8EH/5j2aAa6cW6 7MGQ== 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=EEsv4osCPta4RsFR2aJcrLpn/MC51udl1qpNsV7g5MKX3I0eAZSjHZGWkiu8j8g/jq 0xXT+oDqNbe4zcJZepqkTpzolbUz/8snvJxjV/118IxwmQLd3swOQrAnn5d4ZJ93IR8F uvyN2COYI/tbla4/8/AKSCU+3QaJVRy/vaFunHJdfaJewVNQx3p0g+Q2fNzYnL1pj/f+ OYI3QqpECX6RALsJO6RRYit/IvSyxU7flYMTUnLmvFoQpFfc56Bw4mhw6kuR3CxAzb23 SfPfU/miM6TvlWPERDvHTcICkNF6Af9e1OnCKQHdeerOLA0vwLTmIk8EKpw7U20vIMSW wCbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dO+XL05E; 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 kx25si4474079ejc.434.2021.02.11.12.02.35; Thu, 11 Feb 2021 12:02:35 -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=dO+XL05E; 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 S231486AbhBKUC1 (ORCPT + 2 others); Thu, 11 Feb 2021 15:02:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231343AbhBKUCL (ORCPT ); Thu, 11 Feb 2021 15:02:11 -0500 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9A00C061788 for ; Thu, 11 Feb 2021 12:01:30 -0800 (PST) Received: by mail-qk1-x734.google.com with SMTP id m144so6499115qke.10 for ; Thu, 11 Feb 2021 12:01:30 -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=dO+XL05EXMTxsPkfh2TslSCw5vPK9eq/OsR1PGv9WuhlruX9G0nDaxt52yNN8Q4HTd rOWLRhOGVe1ws/MjJzHva9kDt9M2mS40PDDP7X0gVPz1JkHsg28pJmWpKQDxTFH3c6Zq /8k9erWJw7Bk+aSOK8k67eOTAx29VHkpYXZgKmS6BX9pv+RyFHJPRgm7mzrmAEiX9s9g dXZce8fg7liBoxiN+ZRdR7e5lXz6SD1bfZUaLvXbquVq+8ArCB+XvBRdDqAnI0x4gRNv Z/M3stqyNpiq4GUy6UA3rn02NXo+qzUv+kcxkPRWV+JsAKgDGu01XSVp2+aKFFQwGpz+ jEag== 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=WSaq+jH1KEPM137uUF0qqYjgp3SR0svhYs3xSCF9VsyJv3X4DhyLSgQ0+7CNTF7ZCt IYMVEDoEaXc5TanawBDgDX3xvJdTyIuCarmy9/UIp8d0Wi4IRN+Wh6R5zcBIO0WJz9tr KKcYbhxJRjwoAu8hJIJZUpWowM7g5ARjNKNKMjO36W51bNCZmd5Zti4OHcjlpmalJOlV EUouqxc31OAVLdABGbzgb1tyV3q4m9OoI7J9o2ZhQz1kk+JnVa38l2XCEsZjHntikC7X zDLPfI5/c7uvlVrooerImuvYHSjZyGjibLg1eh1eRdUECWzUJoy3efw/GvMNiBkfyN2g 3nfQ== X-Gm-Message-State: AOAM530DXukJx4cDnDG2oFB5ECJcPnqS1zi4gnaWkn3b+8SyKULk69ky 4GNK6rt4WoVhoXluBNDvqmXBWQ== X-Received: by 2002:a05:620a:2281:: with SMTP id o1mr9855196qkh.313.1613073690171; Thu, 11 Feb 2021 12:01:30 -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 17sm4496243qtu.23.2021.02.11.12.01.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 12:01:29 -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 v7 01/11] crypto: qce: sha: Restore/save ahash state with custom struct in export/import Date: Thu, 11 Feb 2021 15:01:18 -0500 Message-Id: <20210211200128.2886388-2-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211200128.2886388-1-thara.gopinath@linaro.org> References: <20210211200128.2886388-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 11 20:01:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 381031 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2373601jah; Thu, 11 Feb 2021 12:04:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWHJCwtEqXi76Cun9ap+fY6ZiZPEsUzSth/lnzKFiSr1RBTzenI3EwUDgqCAzCRpiAflsd X-Received: by 2002:a17:906:a448:: with SMTP id cb8mr9936929ejb.174.1613073856328; Thu, 11 Feb 2021 12:04:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613073856; cv=none; d=google.com; s=arc-20160816; b=LKJU15SZe7nUssfEJBsqCbpEeItQwt/VTID7u+/m6KTiOwG7ZYWprkvxh7tr7FgIxt d61SPl4Sj2I8cm6hiTBt0SbwqCsfbp+oOpHLqIO8nvRuGFYIT18HIWAh77Zom9qn4w/c vYJLB9illO8zXm6KkXeGkm4tSWB3JvMGmgu3tOAfu0X3OP1TwDWqVMuQ29mtnMMVYzy8 YbzZdq09G05/IgtSvjrBRTzXYbiIPaY29rmisawVN6Ouuv6HKQZ/VJZvC8uHxnWUtFae jIDefdau63mqzw9BoVLq9Wr6ntVrAbK2/YGUJ2iUnzH7nVVahYghl0TPwI4CZiykO6sw 8eRA== 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=glzbodBlkqRudXA8BrOymXwZLhE/jYndWJzZiFeaGIPpeHObeCYQe81/rsR0cklk/h cjLwlCVmOniwK5eUVNo84UjnHA8TygHT2NZvyuZsIJZQEDue8tQfs7y1TLyU+6BYcJkj 5SDGsilYywnVPtm9g1KtqfAxrLXIfeNXTslS4hZMrn/4r8hu1tjXirmXoe3HA2aOGhrr KwLpTm5N0g5V3ggsBYczMtRWwiZsBh7rzGiPHzVnSwohTUN8FG1HBFv1JthD7Mjd7fgH zHtrKnUHUupzsnlrTExA7AFRjiwRlliu8jZFMisgP3vk+pUPilNFe9tF3x1kf06RPMea V14g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Cr/0Xzp4"; 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 t20si4378108eju.239.2021.02.11.12.04.16; Thu, 11 Feb 2021 12:04:16 -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="Cr/0Xzp4"; 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 S231304AbhBKUC5 (ORCPT + 2 others); Thu, 11 Feb 2021 15:02:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230265AbhBKUCR (ORCPT ); Thu, 11 Feb 2021 15:02:17 -0500 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55C8BC06178A for ; Thu, 11 Feb 2021 12:01:32 -0800 (PST) Received: by mail-qt1-x833.google.com with SMTP id n28so5071922qtv.12 for ; Thu, 11 Feb 2021 12:01:32 -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=Cr/0Xzp4NcBg9CJMoY2MZGRGaHzQArd287KXJSudEfKvWZfiGlX51La0k+4m7JIovS DbFOazCu9vjUxkquGis4YogcImJTtrjo/xM7FZCgHJMXSaWeGA4yThC4Iw43xGNKhoqL vmia+BJnRQvca9G+L1XgPqY96T5C2E6JsgY0odnnXXelNMiOShhBFIV613zxnlAae6bX B9ZfVZUI+r1nuhDyBmNUgaEHfFF6tRmia+yOSFUye69dFUUBiQJH7/DGJRQwLT+GnOxI P6m7LbkzFolWYhOgCq0sFfVyHPTaUehVTpsmYfD3yyUW2eDB1Oa2NNFHUhE3A6F6ZACC 6vTg== 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=IX7Chf+rifckjJxlMAIRG3Nt+11VmRz6KSQEFlk5YIX8NIMFIlzgyi8Twz1wCCMy7F MLHM8HlVKXZM55g7hNSqCb8QVaJpzs7kxFk6BznnXW5VtVWCepQfZ/kmYz49ry5gDcKH jWfzvv3SEyuCRAcZhutmFo3I4MuKZQJlidiAYkYXsL+3D75Mk8USTWu3e26y0F2LM+lY l6Og11YEoSSs7l8vgf8Fh8JWvKbdkZ4oetp0LUPN/iMbXKVTasIND5mjWOBzXe+DoeWT Q2eo3CHGpiZhj1uNOTbhD6SzLY7v8HZdoB5NoGg8CdT6VIrs/s93Pg3bna3SgANsLVKm daLQ== X-Gm-Message-State: AOAM5306EMLeXt7Ef9qNNAOJTWb7rksEMld6GRjWHobpUkTNt+c9cfKH SMo0v/H9gXdMhjAnTuHJPE/8Aw== X-Received: by 2002:ac8:5a0d:: with SMTP id n13mr8795872qta.172.1613073691589; Thu, 11 Feb 2021 12:01:31 -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 17sm4496243qtu.23.2021.02.11.12.01.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 12:01:30 -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 v7 02/11] crypto: qce: sha: Hold back a block of data to be transferred as part of final Date: Thu, 11 Feb 2021 15:01:19 -0500 Message-Id: <20210211200128.2886388-3-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211200128.2886388-1-thara.gopinath@linaro.org> References: <20210211200128.2886388-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 11 20:01:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 381032 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2373623jah; Thu, 11 Feb 2021 12:04:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJykl/qaIVWAl9gbg8okRCI19FNSff3DxXD0OqCJWzxhhOSWNabditj7KQ7XSRU7DdOkAzDj X-Received: by 2002:a17:906:1199:: with SMTP id n25mr9921394eja.431.1613073857853; Thu, 11 Feb 2021 12:04:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613073857; cv=none; d=google.com; s=arc-20160816; b=AuPpuW2CFxRfkyYLjZ6b1xo6yRYevYrmYPfPCU0PPRRteH4qhWyuOkkDmBErylWz8Z kRCsNbHsNVwTIQxPtKrT8yarveM/O0kZ1fND2pLY2/NwHvd/4MpO4HRCt69VM5at7kHD maalQpIDbi5zwDUcwpMcFldsUbpG3XiXV3ECVXXcsFFJ7v6PjfNHI662V+b5fY4IytRl qvjgTq7OE3pmTL+4Rx/DHvQTbRHn1JHL7SdsaAL/ZZBEiwLvJ6oKIgFokKpJffP5w+Hl ThfIQVdluoP+rZWjcvsCYhVPaHmyktu6KQyjA8glOXAowH8IUhY4i/1ked8sU9aFeQpX aveA== 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=MJ3JCsBxKkmMu/kcyVpeR8eWaB7r6Ng7CNrz8FurDInDY3ODvYbFJrvITVZtRX1VId K6EnCsosXzaDD4qUXYIDYoL1lyVn02uU67YmLc5260J/n6ZU/o/l9mvXvukXAf5G1MGz Pjlx0Tyr+GtRFbvnc+NiaC8iAa5J3YFI6CG3kDfe6GXcj5R146NawHbBXysXl3LQSMbB pA4WroUGtV4u8H7YYdmYCXB3uuv2pXv23PUnxZ4Q2afkQ9zycvsSLtJzBbYDd4eMTfBI iPDltICv87de0IKmgFztYVML9Ewv/DblmJqscLt/V2aXkQShfTESXNM5Bxn9A0LF0Epq n6fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eINM6deG; 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 t20si4378108eju.239.2021.02.11.12.04.17; Thu, 11 Feb 2021 12:04:17 -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=eINM6deG; 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 S231863AbhBKUDf (ORCPT + 2 others); Thu, 11 Feb 2021 15:03:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230004AbhBKUC5 (ORCPT ); Thu, 11 Feb 2021 15:02:57 -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 8FF5EC061793 for ; Thu, 11 Feb 2021 12:01:33 -0800 (PST) Received: by mail-qk1-x72e.google.com with SMTP id m144so6499309qke.10 for ; Thu, 11 Feb 2021 12:01:33 -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=eINM6deGLuZE+Vv0pTKoDilO23CRE2BaIW+sdCGXsAVFR4bVV5/js80jZGOiWx6YNR L4tH8VIAvobrNDjnxCkYCVgvKxJn9Y2zfGYwUMGnaHyiCKNtr/SkFTaFKK9JoPah+0WU XN7Ygi8vgH5E/ivsjQjyKm6F9thX9FEUhJ/PVNOWLDxPY1fN1OUGiY4W0edLXuI3J8gP QH+wXjKzeLObSXvUT9HNTkNUrsLCsj3nlzv6yoVgwyIMw+8fofiaQE5My4ZF3IEY2iNw ggyHVLX43WBfRBv0E5SK5FEOT7tu0qsTE0N4fpRhis0giBWjuUf4M2Pslw0ixYa4zn2k BWsA== 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=diDQcAeaqiJc3yz+hTi1DINcFuvoGRNdC5OoosG236d94Uet32y3N3cwEkAkEoWOt3 UMJpRokeNw+hO4V3JFzmm1phFKbjG7tIQnvYRvxBXV6iKZNvo7YC5EV7nUzsxMdYgCLe 7OLSaLtUGtWXZBNclknhnA9Vn558FR1QUun+uu9DgCNk7s6tLJ9prPYxXwUou7PgKUKP pbMkHMvN6Jqa9GZptwManPfS98t/YhOf3D/76RMiwOlR77RiamR8wH/184+PD7nS6dI+ hYm7GEcATezeJdrwHC9wfcDJzAOxdHm1kgcQdNrgOhoTWGasScm/THEr0a6Eu+InBArC Pcvg== X-Gm-Message-State: AOAM532e6D/igYioIy1cxc8JlnrphmnHc1e5YwSZ+v4F05Qus974gzej xWEDME1gwzdum4eqi2mj8yqEEA== X-Received: by 2002:a37:6503:: with SMTP id z3mr10104887qkb.330.1613073692581; Thu, 11 Feb 2021 12:01:32 -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 17sm4496243qtu.23.2021.02.11.12.01.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 12:01:31 -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 v7 03/11] crypto: qce: skcipher: Return unsupported if key1 and key 2 are same for AES XTS algorithm Date: Thu, 11 Feb 2021 15:01:20 -0500 Message-Id: <20210211200128.2886388-4-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211200128.2886388-1-thara.gopinath@linaro.org> References: <20210211200128.2886388-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 11 20:01:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 381033 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2373630jah; Thu, 11 Feb 2021 12:04:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6vgR8r0U17f5J4+GrNpBGK7Q01cO6ATKE0hFpke46Clbf9if1TDn4LNaU2Y0K8dWdffHR X-Received: by 2002:aa7:d345:: with SMTP id m5mr10139227edr.30.1613073858268; Thu, 11 Feb 2021 12:04:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613073858; cv=none; d=google.com; s=arc-20160816; b=gNPK+zxiAzYnq6vKAMIsLTHGUpM/SD0V8+p7zOfrIJqra+uKMXmtHuISCdSPmWnN/K sEPLvsonrIuzAkD4IjGOfUzi6W9mYbsowBNr/z/C0vSbIF0DA+4tx+ftWFmtHuwvuM27 /RZrXMWefW1lWqXyw+vswM3yJ8u8eXU61l4M4SIzN6wupRFYfAWrpiO1WnJKJtxmQjHA /KjtlRk8URVl0qD/IOcJV24+3kVCRbGjewfrBB8ZVwGMqQ9VTWggSdxAourAyFMzEJWZ IM67LCP4SuL/QVPLlYmziK8m1UrIpT20sh0KiiJH4xSjsvf1RMYsgE0Ng+HefCxKKsFu 9y/g== 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=N23pUSUU7iQvfUHxPcNVoEdixxNGRArc1osHV7Hwol4=; b=U6JPSbCUPSpNRjlSWMXSfFy2Q/b55dPMi0Y7GhMS7x7Xvv3rK56daZAYdZS/ZhUStm evrKPCSkHJIQFtVG/id72+4zuoexymU4RYITWdRp57IrNVFDu2fxrX2M+iyre0+CN9zx h0G3FtjFKSdy+5kPPxeL8IsPi+iFVwCIlzAbzgL7mjz0gEnPOKWKjtztmkNsTSkUB57T Lc+ywZXJaD4bH/6fGQFkLB+b8VNJ3taQEA8frBHDIDHT+446Aus3Ld3xePZedIAeg9lr ZDSvHCyna73F2ZfvsDfMjV3mxGlhsU4Dnuk5+l7YHU1OFGE/Zhe4Wl1YoVNGlNYALCFz /6Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BR602T06; 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 t20si4378108eju.239.2021.02.11.12.04.18; Thu, 11 Feb 2021 12:04:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BR602T06; 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 S231273AbhBKUDw (ORCPT + 2 others); Thu, 11 Feb 2021 15:03:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229938AbhBKUC7 (ORCPT ); Thu, 11 Feb 2021 15:02:59 -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 AA432C061797 for ; Thu, 11 Feb 2021 12:01:34 -0800 (PST) Received: by mail-qt1-x82d.google.com with SMTP id e15so5078099qte.9 for ; Thu, 11 Feb 2021 12:01:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N23pUSUU7iQvfUHxPcNVoEdixxNGRArc1osHV7Hwol4=; b=BR602T063Y8RPEJhaSQOgDGirNGVDhshaj5wcH3Ip3MZ4Dl0dW83XYly599Wf8K/Ch eHeXsDgpVBTukHj7p4U0AZPeyzPlpGTBvV39ct3vSn0af4fcoMjTy0ZvzQIjvZS0zOLt afb3oKaf/O4JoX/VaN8jCtxMHMFEQ7lVsBx1NOM7qa14CtxlTT/mT7LLNv7SY/cNASHI iaP+SH+vR1Eab6CRcfwtgX/RfIYU8QYOf7JHeEel1Yja+tuuP5GQ4ii0H5Q6JH9GTwTi pnVA8YTbV2RNsoMQuc6Jsz14rOmXu8HlgoRVSFxERNwfUXX6ljOrrAQva4ZtAPzn2PFk mJpQ== 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=N23pUSUU7iQvfUHxPcNVoEdixxNGRArc1osHV7Hwol4=; b=X+KC4HmULNb2ahoof9OSD3C2IEG+4MddQKmaTvliPyKbUg09qzhdOFo3gh/EtP6S+l Zu4zmp8+O5jlDvpBnYMr7bP4cAXSRs0IksEMS12GF+Ss/2JbNAinEAaO1F2ZvkO7oN1g J0o42qQfX+htgjOUD/LrmIRPsSQbtixhgULqmsFRhEUTY0LJX4B3TyexcxJZnbgKzDQq /qAe0e+j75G/rxLVX7/oUnHxu9TSHhiw+hxZ12GowAeh0+iUkhXJj3G7HtFp88e0TVZ0 yObBKMXWkvI1Vdxcvxj6vj/TSuqU4iyYtRAbKMhOVkqwyHNZ4oOzB5TYs0Po6wj55PMs 4ADQ== X-Gm-Message-State: AOAM532d+QAvl8vSRCKrjWcgWfIYtQ1pUIm32rFaluxpJTQVftvTFqbI xlK2HZt6fsXxOHVo92hwFh81lQ== X-Received: by 2002:a05:622a:552:: with SMTP id m18mr9217830qtx.207.1613073693947; Thu, 11 Feb 2021 12:01:33 -0800 (PST) Received: from pop-os.fios-router.home (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.googlemail.com with ESMTPSA id 17sm4496243qtu.23.2021.02.11.12.01.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 12:01:33 -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 v7 04/11] crypto: qce: skcipher: Return unsupported if any three keys are same for DES3 algorithms Date: Thu, 11 Feb 2021 15:01:21 -0500 Message-Id: <20210211200128.2886388-5-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211200128.2886388-1-thara.gopinath@linaro.org> References: <20210211200128.2886388-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 --- v6->v7: - Fixed sparse warning in patch 4 as pointed out by Herbert Xu. This means the checking if any two keys are same for triple des algorithms has been reverted back to using conditional OR instead of using bitwise OR. 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..8aeb741ca5a3 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 11 20:01:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 381034 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2374922jah; Thu, 11 Feb 2021 12:06:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzjwR4XSwjCvxJ7c4doH2lXoP21okTcJd2kkiMRi1u+9PnxLLyv6e/j7qlCokls8VY0ICeI X-Received: by 2002:a17:906:8507:: with SMTP id i7mr10111559ejx.175.1613073959904; Thu, 11 Feb 2021 12:05:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613073959; cv=none; d=google.com; s=arc-20160816; b=ieA1HSVjVlg4vBQ3ADl+4B3Pnnd86eqMw5u9S6f6ExehlcFF1qt1gDg7vNA+9Sf5wK uUeufkyOZB15D1j3X0cP6QW44Dhev/mwh1YiNvOR7rrt2DhBa5tnOMXgXpfZM1vxHbGo vyu3GLb/wJC3ALVDXU68XaRBz96vUYqYzW/rbbMuvNpQCJTQZE/jgwl4B4MxcEOpveQQ UHEj3hGLToxHXgFdUcixDAJK5LAxuvQVmvIX9Dne0CPZskTV0WNrZOiUr5Ox74XOOwEk 1Ck/fMB2PQqYlSBIRwm87xk6rjZncAAfbfDtZDxmGVpwSHgEI7F2WQv7SCJH6OegGI9U +PXQ== 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=1CgjtrleZBn361kEsQacHmwktwYHTlh2i7RhqRtwQhU=; b=ABP0yUBtHYNaSSZnDl96r82Oc39sC8pYRW7MhmOaJodLWAqon+ojNH5l9/rOl4Ia5u +yQ8Pli9h0uNVGBncouiM6zxmZfmFutGFPmFFE5yQyV/IzvctEFg4eQzcPn5aSQ392Ck k64PddivLa4W09fmpFmbBZglx03D8jTZNTlVPCH7HR3qSfPGk2IVPaNv1YdNdCGG+lXx GPHAnBrgg2wx7Ts/UOtgxK44xAazszBHiwsX0BHFttTYEF0PTTtdA+IQRkdnr3vju/Cg cZsUw8YV47uLVtKNtsTuHWfUzhGa8LlUr/+BHL44d+FY+rK55rQ5lwLLVLelCNImNWiq Inrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ys1ClJjc; 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 hy24si4520322ejc.149.2021.02.11.12.05.59; Thu, 11 Feb 2021 12:05:59 -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=ys1ClJjc; 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 S231752AbhBKUE6 (ORCPT + 2 others); Thu, 11 Feb 2021 15:04:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231408AbhBKUDF (ORCPT ); Thu, 11 Feb 2021 15:03:05 -0500 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B11D9C0617A7 for ; Thu, 11 Feb 2021 12:01:35 -0800 (PST) Received: by mail-qk1-x729.google.com with SMTP id v206so6522336qkb.3 for ; Thu, 11 Feb 2021 12:01:35 -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=1CgjtrleZBn361kEsQacHmwktwYHTlh2i7RhqRtwQhU=; b=ys1ClJjc89p3uIaKVv5nPzEGLGYSpyZfo96p7Ho137WBXWf4266h587cPDZnOwuDgt aj9XK0idolxShycDxNigx165a9CaAJz7AZW+C52i6odq7YLRiDEKU6e6O7MtmBPapKix Y54MCwi2HRFFi7xBAXFl8Z3Thxi+nH912l4cHaOv6Fk3oOJAwSIPsgDTyRq7pHa/h3NB Y22uTRSobrXNdkVbkr+7en8T0i5hUKwAUp8p7lkADan0vf7+k6D69BdrtfSIHGedJDzi 4b94tnuvLhDGwwid/GRVCgNkkGNvrEwi95rjtZJ5HaU107Vm6WuW/WH47nGb8g3E+WTq XnhA== 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=1CgjtrleZBn361kEsQacHmwktwYHTlh2i7RhqRtwQhU=; b=MPvH1EBWfPF/21o7wR+0JuaCV87MyHQKy/7SYXi6rh1thNj0RXo0dm7/YX+aARLUPs 4nrgXTlcNJGASEEWeegHkNlwwzU3XYFjkXDJuOjgIBCW12LOAjsuJj1TedCYuQJVK0wd 1w+rEaCuHidEkKq3C38j1/xcmtnulvx1MuLRsWC8vs/OHhqEDB1CfLYZp51vlKARY6jK UD3hAYOkGpBmps2suknjv0AFxpFsXs+S43ObGp5Ra2AHE9ELliOQeE1f6srsnP9VnAWy wGjoAQX45Y7GS5koY04ZS/RRbWCFogmyJu3GpD9370qvTwfQBHq2iDDvWxoGa4qHudYD A6TQ== X-Gm-Message-State: AOAM532AuauyZyY6+sD/O7yf/1P49DcZgd7fbtbC5JlxC5jcZaN0JNL8 SUg4PJ4QQrxd2LhAGcr1wFf/qQ== X-Received: by 2002:ae9:e883:: with SMTP id a125mr10206879qkg.431.1613073694918; Thu, 11 Feb 2021 12:01:34 -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 17sm4496243qtu.23.2021.02.11.12.01.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 12:01:34 -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 v7 05/11] crypto: qce: skcipher: Return error for zero length messages Date: Thu, 11 Feb 2021 15:01:22 -0500 Message-Id: <20210211200128.2886388-6-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211200128.2886388-1-thara.gopinath@linaro.org> References: <20210211200128.2886388-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 --- v5->v6: - Return 0 for zero length messages instead of -EOPNOTSUPP in the cipher algorithms as pointed out by Eric Biggers. 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 8aeb741ca5a3..6b3dc3a9797c 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 0; + /* 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 11 20:01:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 381035 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2374943jah; Thu, 11 Feb 2021 12:06:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxvTp089SdB4/RGqMHh+lxg/Qr+MpOjAdqqnEZiBuW3AUane7rjgeZ59WTTsZ1igA2XyNiM X-Received: by 2002:a50:e14d:: with SMTP id i13mr9812373edl.106.1613073961562; Thu, 11 Feb 2021 12:06:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613073961; cv=none; d=google.com; s=arc-20160816; b=kSIivljW7U84NNO63JX9//Tm/oseCcwtps0PU8051rfD2yi0f2vpYi59HwyPiCOITN OQammwiMxe+D3VWDEIYdvzA0LOvo+ViDnHKTCkyUDI8icqXGyVy1S2QPEb09/ftJ1uPg H/eOPplOHHb9ck029W9rOdO9moxaQsa8cFQKiTj0cWD2am1mJ6D3ytxHpKMGCxlcegwJ fDXhudrOCa1ma+OVe4rAvKgMFn8BGQxS0MNdBCi7Od82lNa2IRUzB0plqORqFNBcPXol 0rujdzLLMjJzLVmOyt961PcI7tEmctrUJmeM9PvWWkhnwzYFPL9ivxRSGDDdqQd0g+y2 9Pvg== 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=YQw1QuSS5oaizNhzVqE2AsZ3JEvDzAP/RbpFDDieAO4=; b=keemu+gEZypaJ1qfN6yPRHXjMf72kkNT0SLwgDBlT5OqOLannyn6Tvd9OpLnOogAda emTP+hY3UeBIyiikCLEaSThA/QbSEzCWD/45g36W9C5edQNVH4e5NZgZZ6nI+JRdkXJW rtiExwZ0qfy89/ocOeNxiRxbORq+DLODoiZz1BSYwJNHZuQHTkht/82NNJXK2fWQy3kA GXgIdS3a1OPsJECIlT/KYQTPJT8s9ba7bNYkgXSSwgbZifY5asFxsGIOP+RAqufdEwV5 84RPjS9fy9jlU4dWhrV4AhpYZaiLmHXw/hxKKKI/4yQohFzzGgYuyi2f0thQOGZydIyE 8o0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=elxvkxij; 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 hy24si4520322ejc.149.2021.02.11.12.06.01; Thu, 11 Feb 2021 12:06:01 -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=elxvkxij; 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 S231667AbhBKUFI (ORCPT + 2 others); Thu, 11 Feb 2021 15:05:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231423AbhBKUDF (ORCPT ); Thu, 11 Feb 2021 15:03:05 -0500 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84B49C0617A9 for ; Thu, 11 Feb 2021 12:01:36 -0800 (PST) Received: by mail-qk1-x729.google.com with SMTP id w19so6064992qki.13 for ; Thu, 11 Feb 2021 12:01:36 -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=YQw1QuSS5oaizNhzVqE2AsZ3JEvDzAP/RbpFDDieAO4=; b=elxvkxijIo5vM1d01jehM7Zocli7jXl4HHZG/sZjNMJgPZ5LJyofQWYcHuMde1I/OR tOryM5IAtZIQQ6EOCGjoC0dtjeVvxyT2L06Sx29SvB+/CUKZNMGKaGTz4YyFbSeM4xGE bOoEkE5moR10oJi0cJP3Nlk5iwsqCXT0mc6O3WiR1I6hib2MLVk24ecLg7jtSPIMfwvY aOr3dUrRbuXA6D0nEdLncYFbf4JkEd+azicP7JdWkYCxpQKUnYsnGTRSYQ6XvWiVgTHO SsePqoYsJ8XHMrOvUhDX5VllRl70bdotzaIfJ2v6tJv9O91rS8o5gnOsnMNW4a80u4sl 6aUw== 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=YQw1QuSS5oaizNhzVqE2AsZ3JEvDzAP/RbpFDDieAO4=; b=drnu+D85mauabfLkwAo3hTQqe/GnsseMQfrC301sqVCirpblDaystaD7HRzQcgCEKo ht9p9WKNvM0v4YPaNU5p/kPEltDRmmPOrAgvsAnjXPROkwBU8RiI11D2BqE7s1TAPPT4 ul341KtYZY0dsmPFRvkMhxuDdT/4UVHvfiv/KdKYUoQCJMMKTv8L3BrzeahRmuI5s8fE yudZSr6yZ89Ybtt9qRhSiduV4JCRUsCDyvjmU94wBfNQkaaeWuZLd03O4xE+ZDOYdJKc 56vZNXWo/gQpAfIVA3oFlM5aHSw4Y4jHZWptfLI6QrVznFtQ6sfY+Kio7OnOlpz5gZ0E tE0A== X-Gm-Message-State: AOAM532IHvSWYrwNc93dGtY0ZcDVRAD+3N1ZI2s5B6KqjBiwmPm8mvn6 l8dL8NY5m27vt4S2oQDjbOgYoA== X-Received: by 2002:ae9:eb95:: with SMTP id b143mr10182741qkg.442.1613073695803; Thu, 11 Feb 2021 12:01:35 -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 17sm4496243qtu.23.2021.02.11.12.01.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 12:01:35 -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 v7 06/11] crypto: qce: skcipher: Return error for non-blocksize data(ECB/CBC algorithms) Date: Thu, 11 Feb 2021 15:01:23 -0500 Message-Id: <20210211200128.2886388-7-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211200128.2886388-1-thara.gopinath@linaro.org> References: <20210211200128.2886388-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 --- v5->v6: - Remove the wrong TODO which implied that AES CBC can do partial block sizes when it is actually CTS mode that can as pointed out by Eric Biggers. drivers/crypto/qce/skcipher.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.25.1 diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index 6b3dc3a9797c..c2f0469ffb22 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,14 @@ static int qce_skcipher_crypt(struct skcipher_request *req, int encrypt) if (!req->cryptlen) return 0; + /* + * ECB and CBC algorithms require message lengths to be + * multiples of block size. + */ + 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 11 20:01:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 381036 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2374960jah; Thu, 11 Feb 2021 12:06:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJyt1q9CNO61GL3YE92O2V8dmfkh0M4+oxp7HCV2gy9ZMxoiCwd2N7gLwqFlzSvgPRstK53z X-Received: by 2002:a17:906:5d0b:: with SMTP id g11mr10013378ejt.542.1613073962433; Thu, 11 Feb 2021 12:06:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613073962; cv=none; d=google.com; s=arc-20160816; b=j1dcteRGJDondrpmDuRBXAO+7kHattYSedj60SmQmtG2MEJHgoBvMEbnetnucOjCpg 8OdHyeexzN9ri/StlvJdLfqQMiiseVI/rNCZetBHalYpizrffoH1BI16waqQUC/DeeGV nNJ7WhW1fLJhXblNbHBVEvQyrolvHG4iRf2yJW4VB78UjFyfm/zG1XQ9Ix0LSVGN6vXe WK1gpNlyrLKmEYivPB12lWeh/UJXvZIwLOpa7Bjn4PjHVEtbIVMOKZq+gPnJ86SlyW5e XAr+g5QSbONHDhF3wHtfexYLjs0V0GwU4hqYT1Fimctr7O1rBr69baYVbF+8cm6eB60q /ZNg== 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=QVxt07NhH8i9s6gtmli+U/sos51ULXBrf5Wyl507Yss=; b=cWZl8MMkXfCttWxsl4ICU4SIYFfUwcre9S9dkIK6iziOUsDag7PQcT3T+YKCVwVX9c xrpQwlvtIvpfOks6PIxA/UugPFRcG9kNDnp5T6lb483/ZM8Hx9NmLGujTr6D8DR10Vvg 1Qsb7c6O5ZJ1/hHn73LEA331jZjzWepKW+PqhJm2j+GoMDvEWXedmpceml/tdrvDZxnn GiXZiM8qC4ArqGsKpEPs1IKrHFFDIpFBzSbJCD0Fc6r1f69XGdV+e0UrnCJIuzRJK/gd HQu0t56PphvhKmdq8wiDh1ku1pDCWhzY9RmtzDq5UKNbA+91F3SXVcuoIFMvdb9o7slX qWJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VpBxqcUz; 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 hy24si4520322ejc.149.2021.02.11.12.06.02; Thu, 11 Feb 2021 12:06:02 -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=VpBxqcUz; 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 S229517AbhBKUFc (ORCPT + 2 others); Thu, 11 Feb 2021 15:05:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231680AbhBKUDS (ORCPT ); Thu, 11 Feb 2021 15:03:18 -0500 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F25AC061356 for ; Thu, 11 Feb 2021 12:01:37 -0800 (PST) Received: by mail-qk1-x72b.google.com with SMTP id j3so169158qkk.9 for ; Thu, 11 Feb 2021 12:01:37 -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=QVxt07NhH8i9s6gtmli+U/sos51ULXBrf5Wyl507Yss=; b=VpBxqcUzxTQuw+QYAmzO4hctY0VmJspmo6/IK/9FR6aVlrjGAJGeIxkEzHKiNBkGFP ByDXFmIKqkDmKiOCN6tslPbHpuitSWg/mkXhyS9G7cK+AIQtliCkrQl26BZETz4kWxWZ SmQeMhN+G1Ond83VwI3HEn/gx72dnkCp+B5ppeup4rY0CBAe5pgP6nAsXyv+Mzoi88Kp 0dpgb/sc2TIfSun2TY47DZ+mWujQHHUB1xRG5CI7/NnpueQNOinA5l+DKnI4ftTcxNKW 1tQF+yP3VXen3hJVKLNmZw7wPlS02sN7ID2Enj4xS3hcAE/Tvbzj0jUFk3pSNOwqrQOA SMLA== 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=QVxt07NhH8i9s6gtmli+U/sos51ULXBrf5Wyl507Yss=; b=f+xzResRMARSkyGc4Jp2r6R13h+4qkL7DnoC6F5wQVFxELLO5PDVwSTllCmC8qwhW4 H3woD4ffha5mCXk97IYCb6rDZOijtXNLkeblGD0ni6KOFmWWer2Lz98g0IrGCBTV7kDj jBAQwb8/3a778UhjiJSaAo2hqjsGvgl7MI+B4oPZprhL8bHLjJHqf9qCj8s7xAU7js0Q FslrpOOKKYexPQC2Cpr4vZnceodNqFB7UaCvhrCoOlCdxsGhU8rn2EksTE0F6Gmp1sKq Rlp736ni1TjdL9xo05BbeAx9zQ3Rjwipp0JoLlTV9VX7Piz57+2/28gtTzEVO85Sijij YWfA== X-Gm-Message-State: AOAM533muOMMms5ipsDECBZncjsbhu0voGPhxFV0/Qbqwv9huriffuxa H5dSI3qrtWNQq0tXgeQhBU5x6w== X-Received: by 2002:a05:620a:80e:: with SMTP id s14mr4872595qks.20.1613073696594; Thu, 11 Feb 2021 12:01:36 -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 17sm4496243qtu.23.2021.02.11.12.01.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 12:01:36 -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 v7 07/11] crypto: qce: skcipher: Set ivsize to 0 for ecb(aes) Date: Thu, 11 Feb 2021 15:01:24 -0500 Message-Id: <20210211200128.2886388-8-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211200128.2886388-1-thara.gopinath@linaro.org> References: <20210211200128.2886388-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 c2f0469ffb22..11a2a30631af 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -353,7 +353,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 11 20:01:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 381037 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2374967jah; Thu, 11 Feb 2021 12:06:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJyA2bB+azydhBwVRGOiuhhWPIPBipBaSYkmU09ywo6hVfDO+xCCQPBTGOV+PDkHerKoKNs5 X-Received: by 2002:aa7:d2c7:: with SMTP id k7mr9947476edr.374.1613073962812; Thu, 11 Feb 2021 12:06:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613073962; cv=none; d=google.com; s=arc-20160816; b=VYC6kUBv2Nh/hfhlRlB8xq1sjckrgm09UQuF7F2g4LbGrnkR/1UnIEkS3qu6+lxqBA mVDQutsR7LX3wh7FRLMYkNjw/ufjpGCmukg5Ovl+Ha+vm0whWLdUA/jy316pW0QgbH0v UXQB50uLlLWH0f93evo5/nmCoSOMLPXwvkNFNjJ5zKi6F9THbpKBdnNiECkVQk9BHYmc WBBWAz9AP9wcqkD6W/HxY2Wvq+iAguCvqtnCMJ0KaYm7LHtrJna0rXe/97Q7guis4xdk GPPp1imDiYfJA1jsOwTOzeFp0+upwrfJXKAZ32zLjQ2J8vbWvp7Evh5Ib2HbfG7XEv2B Juhg== 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=bL5tBDOEKgNdAp1Fa/CljitFahbwVqV1YSG/EkXQA0c=; b=V7S4eHfg/IfmowL4fzm2yfoIZuBaArLfceRBO2osmdZv+sKs2x1vdLFDHsXRv+iSD2 5VGGZ5XnjTzM7N4Dc7QtzmBjbdXTB7mmOsJCLSAtPlGxGW74c3KgypWWhgjQiAulVY8m ivs6W4EU5GFWOhgh9oUqhXJUsXdVY1ZXAEHfpml4XRGYWyX0ldod/RZcRotkvUi5jOVP EcY4MwcX68ZJI2lXt0uErCTCKbBngopJJ7k4t1V2sMU/5dbDLohnYWfzHhKFiL6RIge7 ydbQcQcndjsWwCXBXdMVS5KGxdzYrWv2F/Q3VByKoGsiyi/9XmAUvq+dYM7wxj9wD/FB odjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=koec8wpR; 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 hy24si4520322ejc.149.2021.02.11.12.06.02; Thu, 11 Feb 2021 12:06:02 -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=koec8wpR; 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 S229997AbhBKUFe (ORCPT + 2 others); Thu, 11 Feb 2021 15:05:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231322AbhBKUDW (ORCPT ); Thu, 11 Feb 2021 15:03:22 -0500 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C1F0C06121D for ; Thu, 11 Feb 2021 12:01:38 -0800 (PST) Received: by mail-qv1-xf32.google.com with SMTP id a1so3148176qvd.13 for ; Thu, 11 Feb 2021 12:01:38 -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=bL5tBDOEKgNdAp1Fa/CljitFahbwVqV1YSG/EkXQA0c=; b=koec8wpRvuhR5tv/Ao6J+GJABNrBwHe5+cC8LGvp6bbyx7drnjjNsbwMfn44UgLQt5 x2FjR1ObKQbGaZz+ctKNvqNm2oL5ip9RGq1vlY2u4szlJsliW/IDaMZjeNVWDwu4ywrQ dxUYNRXR1KmZ2T4kLq/MDVvdzq3Pu/NG4q8XNIMYzFyVrqSGi6GMFx7iz094u0Wzv29n iXwsso+pdJyH5uxg2l3T/HD2YRpRkpbZv8AMaw7wCg9r4TYxfqRAmMg3hVNJloBhgy02 W6Hi6WN+UHsGXE9OUQGvKLyTrT5LnQIXPh7qY1hCqHeYXe9o8yfaykUYyeeaj/c4D5xe vw4w== 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=bL5tBDOEKgNdAp1Fa/CljitFahbwVqV1YSG/EkXQA0c=; b=FkHEkrYGoeFmc4OQq/bfjr9z6Z5s94zCLnmXIy4IY8AUl1k9a0YyR1EUzzve+/eB9C ViHPqqqWfPkhu1VusPTYlIxfn7IInA7ZkizJYOTdfQP4HTxQuvFNql3PVr39AlzKSilZ EDqY54t9/jTvIYMadfhXriW5BiJIIORJPS5AUEu11ZShm8u9EB8FQ0Zo/87CUJqN42aN PBMoXmGrjZxGH1KtuREkhAPZPz4l+6AegmKyKdQyBzQ0OFLPwib4CaEoGD5Dq5l63/m1 sGHTGI2zZEqcpZodfUHZqqUEUcF0FZ6blO6CuLCEoxCcJ/6CEDPLVSiRlr+MZT4iQ9qk bxLw== X-Gm-Message-State: AOAM532rGAUXO0GSFAy5ClFHQIwV8TDw9mVnmtv3u+YzSR00LxZ+FbWM xvXL1ECP/it1k4LcUR4euODhbg== X-Received: by 2002:a05:6214:11ab:: with SMTP id u11mr9210776qvv.17.1613073697388; Thu, 11 Feb 2021 12:01:37 -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 17sm4496243qtu.23.2021.02.11.12.01.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 12:01:36 -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 v7 08/11] crypto: qce: skcipher: Improve the conditions for requesting AES fallback cipher Date: Thu, 11 Feb 2021 15:01:25 -0500 Message-Id: <20210211200128.2886388-9-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211200128.2886388-1-thara.gopinath@linaro.org> References: <20210211200128.2886388-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 11a2a30631af..2e6ab1d33a31 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -274,14 +274,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 11 20:01:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 381038 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2374976jah; Thu, 11 Feb 2021 12:06:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxREu8khxnmG0Yo+MAjpyo5NtBOMeM+MgTFkFo0oPxaKlzdHs8h2wMY7zPpfftsVo6jhF3o X-Received: by 2002:aa7:c7c8:: with SMTP id o8mr9941807eds.137.1613073963152; Thu, 11 Feb 2021 12:06:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613073963; cv=none; d=google.com; s=arc-20160816; b=zLTOsj8OX/pMTg6LRlP8eKAZa6/wOiB5Cygu0MZKvHQqtlOgBWnq5aNbQjh+pHfS1H 3GL4yb3J548yGjjMeUpOzxEzx3xtkkqZ2mZaXfZD3KKjsEUmTVxw6upBAgTaEOes2y2x ZK+k3uDeTm7YU4ORPPbplIZ52gRkNzRpY9h2btfOZkmo2Y8TLAFIxmgT05oe52tgha/h xWtuDCp0vjXR+YNrxcU0WNVvKzMPq1T68ugcG1fu+WhRvAmb+DFp5ARW32Tq/eSfMuqr yNCBZc+XKpZwDGwS/GXNHJyYw7ChcxO1N6SrsEHmSeo1AcqYGys2O1aMuFH2cN9CD6FH 5jsA== 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=ICcPZzyOwV4mEa76Ls1tmpbBcS5X4vYSxQKLt4AkQcT+QsxBBg2i4kkbqq5fRD+FpU KTQbcB4W/Nj7MoH+8ab1IP75NnCXR1tZSOUsO9l96jtfSDHncp87KEys8qBDmh9NCKt9 b+wt+DGNDIN+y4Q9dyBKEiGfwWN6Aql8cfLVyEW34KTCM7xg+odf0rKhWLsCcaAUx2iS r/9qmNQVIqb3qkFpeM8wphbmIFZYZCc8W2X6vCUVZpoU/z74zwrPAygJNQeh4Xir5C13 mFjGFJQ64Hpqs7EgpOPBMI6MbtFBASg1HTd4KmPLMzQufzcxQrWSCRt7mgctzofkr5O7 n/mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d8ymdmwF; 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 hy24si4520322ejc.149.2021.02.11.12.06.03; Thu, 11 Feb 2021 12:06:03 -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=d8ymdmwF; 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 S230239AbhBKUFh (ORCPT + 2 others); Thu, 11 Feb 2021 15:05:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231865AbhBKUDg (ORCPT ); Thu, 11 Feb 2021 15:03:36 -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 04D61C06121F for ; Thu, 11 Feb 2021 12:01:39 -0800 (PST) Received: by mail-qt1-x82b.google.com with SMTP id b24so5063882qtp.13 for ; Thu, 11 Feb 2021 12:01:38 -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=d8ymdmwFXCwez4mLOrfhKf5mFT0mnFj75aMOO4K6woC6nV8wCoQmGV1QYH3VAl3Uoq YgUVNwD6VcAu2MtRViHxmnA/sG2aJN2lKQsaKyZE3nas3C/Rxn32TDXlYHJYU8mj19zb U8eT3V9ICgvWeem//Hbl/x66G2nQXDXcvsgdjYbh8z7pH2gKpoiYzc+dqc9mUSH2A1zN 6GqMDkGXeRidVvXqN8aa1dGIzSSa+kdDA4s8Ifz68XrFZhqZ/Xb8/V/GB6eTnnVFiw9S 0Xl6Zy1hGthmd3iI1871kouJz4sFS5GbOaXXuiP6HwVdu1WvW5/tZCDjxvsXbp2sfDm+ TpjA== 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=OiuwO58gUDFcaaCClGO6o/7vG+Esn1jHugKIgKJN5r5qKTVbG8MZESRj8WYtYgPp1g zOrXLIeZk849g3kju0DxAKnK6AIX6V6qDj1NVgAplfRg/2FyeKq46xA6NKafE7GIxlco MAuThH9jKG1gjv/3MbHAMkFY+xNTGRNBd/EJQ3gEL/FYb8ZWylSshp+HZjmJPKtTLJjA IiVJgVMfcb2IpkutYhlM98cod4jujhBynenqU2Dnn4y8QMjaom8Mpx4C5DYbNtIiwkq7 HfZaANq1WZp7S13ccmo+EYFsvFuE04oKQC+lnQ/l4aTgJS43oWwGK6udbL4uQ7zx2T2N Yw3g== X-Gm-Message-State: AOAM532OjblJkfXjKqiLiVFYmMnoLUqDN6MhCTuRUOHsj0Q8yS/5E0SJ +c9A77m8TpaAUIlexSkOXZs7GRk9rQesPg== X-Received: by 2002:ac8:5992:: with SMTP id e18mr9063133qte.177.1613073698273; Thu, 11 Feb 2021 12:01:38 -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 17sm4496243qtu.23.2021.02.11.12.01.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 12:01:37 -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 v7 09/11] crypto: qce: common: Set data unit size to message length for AES XTS transformation Date: Thu, 11 Feb 2021 15:01:26 -0500 Message-Id: <20210211200128.2886388-10-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211200128.2886388-1-thara.gopinath@linaro.org> References: <20210211200128.2886388-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 11 20:01:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 381040 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2375350jah; Thu, 11 Feb 2021 12:06:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJymuNZNJ3P5duiDk0PtkYh9jaBjg+dVbtb10JrhykHGMA2bnkzY9jjPEVjoNEadBz5iTka6 X-Received: by 2002:a05:6402:190a:: with SMTP id e10mr10004831edz.110.1613073994109; Thu, 11 Feb 2021 12:06:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613073994; cv=none; d=google.com; s=arc-20160816; b=dqD/iCdgUGCmLTeCLZsanCFxdJ99YXCjYqtWOPPgMO0Zs0I4f83YRPqJo2qRzImGyJ vdT+HU3tIgwy6GYfXb2DLh53X55mC0/rqkstgOH8AOlFW/8spZX0a86huYhO+yNY77dn 6lXX5QcfCnrqgQrktZn/RtvNcJJhedfeDJ41joB5QX9/qjnWpRMIkTFicbo5c46hjNwu JYWvLlSZNIVB6jwUIweIVNOm2yfazopkBbxsr81MfutNwv7VhgN+apgcvrROqOILPuD0 klSab0FJZbS2cUhvTozD1LN2Xx1c8qtSX7zJ+Bnf9L5NbqaFEcFFxV1Xsd1AQ8lEYyQ/ haWg== 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=dqRg1h0LboXXEy4lmOpEMqYSIDNLa3j8xoIEYXfWQfiv9GVH0o4BvH6uPk7Z+v4DOl Toz03Hm4Si0is1t2FiFYNiye1WoE2BGb1A5W6q1t8vZwvRcjUZc6ukwZBTkirEgeKl4G /wIyyl3G3Mi8YE6E/HGxe68t0TjRDk5R/u2n4cY5QMQ1fxTYCbnM3nTt0UXmGykjmLXi 3BbII8U30HkpjyUbRH1SzWhm/0HH9vHfIdazLhxpekvjXwK76lO3ZJ/kY1FULRrt94yz W5vtBmfhZNQ3iQPQaQIv9ytktH36EysF8M/ISfaEHB2knzwT8W7C0x9Y38qF96FtSwd1 K4xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DGSt07jo; 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 hy24si4520322ejc.149.2021.02.11.12.06.33; Thu, 11 Feb 2021 12:06:34 -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=DGSt07jo; 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 S230353AbhBKUGX (ORCPT + 2 others); Thu, 11 Feb 2021 15:06:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230315AbhBKUEM (ORCPT ); Thu, 11 Feb 2021 15:04:12 -0500 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D583CC061222 for ; Thu, 11 Feb 2021 12:01:39 -0800 (PST) Received: by mail-qk1-x731.google.com with SMTP id x14so6532159qkm.2 for ; Thu, 11 Feb 2021 12:01:39 -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=DGSt07jo66PKKAE7l+SyIEMKfRHrgcFo/8QAJwD5aMsR2TU3gdrwcxHsgkcnBKdMCi 4McoN6vQs0WGQwjyp2hofGeYIjjqAwR3a1Bc5ZS7HGmAm+e9M8bTRRnrpF0l8JTQgy+l V7bSVHHJKM/GRukriyE4Jsmx//OLVWakimzO8oC/S9rbuEawAKlBti/mQGTOLkYaqNI6 cLmxHn+sUkMu13u0kikJCKX8e1kVV6QSr+c8y9+BZD84swd92hICfSi+2FPI2zF14HDr w7vsl1y54gZCjde/36GGPI+vbFi0KV6T5FveXT+FV9IUYcT6cBxHI7ytOZ3a/dAOrB4N vvkA== 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=cB9o2O06ko+zjvPQNcocG+69LOdXVwTyf77ppbHspru89hZ+6PJJvtZU8FRS4KZFJV 8Y64PiT6ofRgqT+S90B6jj3uK8/G99VhvNQN/BwFWR7CHemAfZts0Dq0MXeYybtVwzmq aMM1UYxSLCe1o/s2trRSmuC7divWFttGHTz9tybhoIy0tyUrJk+swNstSIZfob0GqhkY BpjdKCYFEia9gpfD8jxGOAaI96nva6O4piDZcA9htV3zFNKhwuJBizMWHieJUHakYaBy pt3RTsPea4j63lvCs65fba1lJAtpYhUG6Pm/t1u8ngCaIkx2wSF41dYa5tLpBGPwrKcj COgw== X-Gm-Message-State: AOAM532ERxRHME+m26SxeOPCuKouoGeg65Uv1FYHeYNhkBFIjlxuuMR9 Jji5diZ4/3H/+ek//dF7YpK7eZrno0iuGg== X-Received: by 2002:a05:620a:2281:: with SMTP id o1mr9856106qkh.313.1613073699132; Thu, 11 Feb 2021 12:01:39 -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 17sm4496243qtu.23.2021.02.11.12.01.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 12:01:38 -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 v7 10/11] crypto: qce: Remover src_tbl from qce_cipher_reqctx Date: Thu, 11 Feb 2021 15:01:27 -0500 Message-Id: <20210211200128.2886388-11-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211200128.2886388-1-thara.gopinath@linaro.org> References: <20210211200128.2886388-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 11 20:01:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 381039 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2375214jah; Thu, 11 Feb 2021 12:06:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzm+GR/sMaOxt1woML8HdLrmPfMdH1l7oHatA5FEp/hDTxWzXGdY/uVEZHahwItqWNvnJ2Q X-Received: by 2002:a17:906:2747:: with SMTP id a7mr10372347ejd.250.1613073983169; Thu, 11 Feb 2021 12:06:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613073983; cv=none; d=google.com; s=arc-20160816; b=rXB1rg3gQNM2vmm0mgM64u3BKpG4A1sMeoCbXkdYn7ikmvknCw9btm6gLXqNRlXaLx xJjpjAYiR2zj4iUCp53hHnxuEUdp4uoLg43kvhVbB1MxrEYz+oZl8tamtHZthV4a14lY sA/9+1u5ZH5sFNmjAhq9OJ+HqhE6S8LCtlKDIBMypB55fMAi+2p36FbWMMFy0t8/m5H/ dipih6KckPisLvJM0zeUdw+In7DZQ4kSfc9n4ZsbIqb73LgZOS+4Vg2YdGVM7L8Xqc8b MudrcxUcT04wt5EwMgwhjLRnGBNCS/J6tMz+KKzcCUxAcVbtxfsZ3Gj2LVsIM0tlrSbv UCzQ== 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=yUg8PjWDYd61mmuXP9fMk4GBLqx+aixrVP+sxaFHojE=; b=YeHnvvbMwy0iPS5H9bv9F3A2lRkTY1h+z6ddFtOhZ4YDG8of6zBKeJxU0tvTpz6Hqe ILrgY8X2bXszW5KyyyUDrgcJT/JljOoG6HTX+b2g4TPzOVsEx3dOtiQIr+AaLaX86HIo q8gx+sTAOl9eniCKFBdwm+N/AdYJog+QrgBUzTg1mD1WnEcFsF4ti3XJrmqFmqJ65s3k Y3h52eZQTmm2pN6fkjvra+1Gtq7vX7/ycnzjNuT5Oa0C8er4Xsr5iqNPBWmGAYMSMXK7 OZiqBnlU+stX0KMFTVBBjbQE/XxxDGirwwaO5jEWn+IrEvu0j9czlWEsLsAgH5UKf7Ax j7lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H+iuusQ2; 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 hy24si4520322ejc.149.2021.02.11.12.06.23; Thu, 11 Feb 2021 12:06:23 -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=H+iuusQ2; 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 S231561AbhBKUGF (ORCPT + 2 others); Thu, 11 Feb 2021 15:06:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231209AbhBKUDt (ORCPT ); Thu, 11 Feb 2021 15:03:49 -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 00D3FC061223 for ; Thu, 11 Feb 2021 12:01:41 -0800 (PST) Received: by mail-qt1-x82b.google.com with SMTP id w20so5121986qta.0 for ; Thu, 11 Feb 2021 12:01:40 -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=yUg8PjWDYd61mmuXP9fMk4GBLqx+aixrVP+sxaFHojE=; b=H+iuusQ2wjFpZVfkabh0ima5dHCfVyuBGimWWiag35rG40BUAOpRl8HGilt0sfR6FF TluNCdAM6w+JsuDVOhPgm77s9xXntGbFJ8vJx7saC6HvffOqkDlLCLBblFXAmW5COVx2 dgS8ILn2PTfM3FlLOXiOEppRTHBStvvg5CT9aqeiPL7Wx3UOA2+7r4WQuRDGlYVaWISb ECnw3zJiVTFrsoJeNPVlB9loHg0hJ8y/xWqKb+TxgsonFK+oJQ1qQPSNl2TadLSscHbh axjHqA66zGP8Hjj5Nl1g9ftka8vbn0bmqOGOm74LZxX6tj/VLcPVz/UJ58vToiBAxMLf v6pg== 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=yUg8PjWDYd61mmuXP9fMk4GBLqx+aixrVP+sxaFHojE=; b=uVLzguPL6mc5GlP13yXedqbwm3bFM5+xcZU9feVXg3xS0uSO2wKgtkQRw2IxkWOD7i bxmaJaU6K5X7xgak2vKbZag9y1CFq9Obbwpih5ZlL2XADcfl1yZRcpHYulJ0A1AJ3ZPG xZTQ9EBBWen1JgrD7xLA/ehrxjyIzlfd1c0sSmK/Q4uK4yb1B3icYC+dFSQ+Kvpurfz/ knmb/UerhrOcNCrgGcg7qD8m6f6JEgradGvg8CWZWQDgTnUvfzODuO1E/6ln4ksP0lVe EwwsuPSiBdrVqGuyR9GcMUtrrMOIToEIK/RwHyIDVXz3b5y5uznv5prnst/2Pu5b9rPg lpjA== X-Gm-Message-State: AOAM530oHAuHF1QLh3w/St40g+Ggtw1LPqLS6Ho7rnW+sEabsNaOI5cq 8KMpXsb+pj15buiBHVCFIBpR+HX+zE+jqA== X-Received: by 2002:ac8:4cc8:: with SMTP id l8mr9071981qtv.284.1613073700051; Thu, 11 Feb 2021 12:01:40 -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 17sm4496243qtu.23.2021.02.11.12.01.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 12:01:39 -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 v7 11/11] crypto: qce: Remove totallen and offset in qce_start Date: Thu, 11 Feb 2021 15:01:28 -0500 Message-Id: <20210211200128.2886388-12-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211200128.2886388-1-thara.gopinath@linaro.org> References: <20210211200128.2886388-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 2e6ab1d33a31..c0a0d8c4fce1 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;