From patchwork Tue Jan 12 03:05:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 361141 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3400180jai; Mon, 11 Jan 2021 19:07:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzT8XAqsxh8pjTpbZ69BVN5zGI7sbTBfjCVPHWqhYrKgCvQc9IuynT7ZuWtloEn+qgdlGkd X-Received: by 2002:a17:906:3bcd:: with SMTP id v13mr1673343ejf.181.1610420848191; Mon, 11 Jan 2021 19:07:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610420848; cv=none; d=google.com; s=arc-20160816; b=c3PEra5sDOM2DpXDh5K5gAp0rwPcDC7fiG5dLIWKQmALDZHiOjXJHPU5c/l0cqI3FL PyaYrvYuvW9S6QGHvgSXFppTEROM5E4dCQXpKET4Bn5HYS888Dg8F5URVt3o00WguFEv apJQQKyE3FeNib/yjXC+E06dBrgS/KBLBEeQJgA7kaK6RRz8ykiK13f0Dsac+6Tk+Lzq BEBAxrsyOpIO7iT7T8hi3KR0yZfX7qyiAtjJHStGzAV5VuZfUiZhxtjzi3B3ChG9buvc kwlE7QKSL+a5kHrZd2cb+Z0nN7Ro+51lJlaBxF94JzsOk/GLP/r9/dGEPY2F6p74pJqE gfrA== 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=U+6t2Ro0fRT+FUrbsbn2zgmBqk6HPbwcTPoVJfJrGfA=; b=CGJcH7ROm1t8znmJIQVZnvYJxf9nqRt8QsupY4uxsdTGzUjlIA37WMfcudOCBb3KdX EVYzjkOtMFCxfnljASHasvAjo67TGID0snASu3JD0CoAdtBgMtgfVgeFRd92K/LypAwK MyC2n4WKM+5tFXDZhqy3I4GQRSoAe+xcNbuoLkWt28ANuQaazRJyTws5wjAZrivQ0Lu/ Qi34OK/btT5Y59Dk5MJKlkROf1PF1A8empBPPDPgbY4teWVqs64Wg29LoYSkyuhvyOkt oMHD+rwuNqT35nd5V6H3Dbob3iNC/NgZmRSyyHlpYU5z/9l2Zd2CzLRXtWW4tyyQRouo 8RWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qQVsREep; 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 g3si542697ejf.612.2021.01.11.19.07.28; Mon, 11 Jan 2021 19:07:28 -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=qQVsREep; 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 S1733279AbhALDGe (ORCPT + 2 others); Mon, 11 Jan 2021 22:06:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731674AbhALDG3 (ORCPT ); Mon, 11 Jan 2021 22:06:29 -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 7235AC061794 for ; Mon, 11 Jan 2021 19:05:48 -0800 (PST) Received: by mail-qt1-x82b.google.com with SMTP id a6so742568qtw.6 for ; Mon, 11 Jan 2021 19:05:48 -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=U+6t2Ro0fRT+FUrbsbn2zgmBqk6HPbwcTPoVJfJrGfA=; b=qQVsREepuk6monN1RMMdMSpkfXgi+K/brCAbYu3BlJMQk0qtxhPxVuiYpxLR5GTtoQ Bn1PYR1L0Eo3+kJ+RTQjfCvCdm80Cf+dauF1l2G5LlBhySu27luCq6VL4BarBgcd2gKq eNdeCPuyDNlbTylh/BS5swkXupkAfMwd4UYz7ikEapPZLaw4OHg7vhiaGlbkObBKV2PT KaDuceLCzDxPlMbgE9oLaR9dqND7/To65UfiSzu3I4CUojkLdaqGTAuxlH1QF78OAYob mIFXo8xmxHIEKElAA10k8ILLA5vUT3G02qhSuj7/E4/RI/h+yraYiVVLSheyNO+Du3jZ LnhA== 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=U+6t2Ro0fRT+FUrbsbn2zgmBqk6HPbwcTPoVJfJrGfA=; b=j+qMhzolOz8tMBns3aV+ycZwg0753cfXub4sEsfPxN/Yjt4M3XIZdCYjDEs3QQJmri x4mK3tbwATv6jDNClfkt+cWhuQwbaqDP7jM8wMJiahlD0P83eL8o8d3Q362qw9Ld7lP9 cYKM/QYgHBdzpUiXuvX1AKIPr8+Ut+u7FjU/Zth+pM0HAUIp6y0rMHljKPINqIRa9ZFy hFv8S0Xxe7rluCuQnzqa8p4Ftxmm5lOrLKMDuVseTaV1WRR1TAPzSPZ9fSr0q8+Xg+0W SQ0S9SxJoWo0qXsUOJki9rfEgeR0G8kkQd3kTZBjhU9VHD2kfvqjc4e3GVwiPytqJCFN Jj4Q== X-Gm-Message-State: AOAM530Ajfwo4kI3nsznAhtT4TDWbDuYSPFG7sbEkL1tW0czNYLe0cZQ EPEwMcjVdQSyrXXujOj3wvJAvg== X-Received: by 2002:ac8:37f4:: with SMTP id e49mr2678821qtc.193.1610420747715; Mon, 11 Jan 2021 19:05:47 -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 c7sm814235qkm.99.2021.01.11.19.05.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jan 2021 19:05:46 -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 v2 1/6] drivers: crypto: qce: sha: Restore/save ahash state with custom struct in export/import Date: Mon, 11 Jan 2021 22:05:40 -0500 Message-Id: <20210112030545.669480-2-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210112030545.669480-1-thara.gopinath@linaro.org> References: <20210112030545.669480-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 --- 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 Reported-by: kernel test robot Reported-by: kernel test robot diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index 61c418c12345..08aed03e2b59 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)); + memcpy(export_state->byte_count, rctx->byte_count, 2); + 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; + memcpy(rctx->buf, import_state->pending_buf, rctx->buflen); + memcpy(rctx->digest, import_state->partial_digest, + sizeof(rctx->digest)); + memcpy(rctx->byte_count, import_state->byte_count, 2); - 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 Tue Jan 12 03:05:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 361146 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3400232jai; Mon, 11 Jan 2021 19:07:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJyw0losek2DhXF/BMt59guce43fLZAkFja9VhgJjnVloCPPaYQ9VwAFTqnFrzfZUz2mbxLu X-Received: by 2002:aa7:ca55:: with SMTP id j21mr207403edt.172.1610420853683; Mon, 11 Jan 2021 19:07:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610420853; cv=none; d=google.com; s=arc-20160816; b=MqimL37y4FMgHccoguhxc85IqFMTaTy8KqXnAb9T0x8GQUf5aXqkjVWFjXwmsuxfeN 4qZkdWguE2xsU3fCEylgJd984AcxcU3OmpunccSygvAZTjRbb3d6mkDI7CWwaelmmHOz kPEbIEjzGpr2b0icH73wqJ6hsaS51lx/TYNN1yQtU/IwocuEzaqVBk9cgbvTvRSZmdF+ fKX0RTx8yena6zaG9n48rdJ2Fnvzy5ychxbnrR8gECaiVxKhtakctHRsVFR+BlTS7iQ9 vdLGQvcnZOjsGfhydYTyGgds3WwGkdhNM6yTX3cFv3gCbbtPxJYBGoO0Mi78eGVDWU68 oUKA== 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=FzoTTNnCPyrLt8K8sPUqSR8uOcEXNVFa8VbUu/a/sAw=; b=r60SDQPtDWb6095uS6RPB+kUnBJjsXQ73b0by/p0EEI26j6Y/9EcBjnytb2/vLAK9l cYKaXiUeekqvwOtNpc0s38LEJAVyTq/Df3EghsOt28w+NV5dRRvTPvv/kAgauyXx2gsV 5HWjaPuQoqKNdkkXzH51v2P9OYPQGb30Wwspp0yfOshTlDK+VT0hMUivIoDL9geOaj/a 8+0BxpD0cKRQbDhjM/isyGQe0Av463st4lMqLoX0zP5np8NKeDMKzVwEYZRuvvdlllpF X1Xvtat+LWccywVoclJt6VnqgqHYQl1813daQec9ygVctiMM+qeffhT2foaXV6qwn/tZ +F/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="gOs/dNmK"; 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 g3si542697ejf.612.2021.01.11.19.07.33; Mon, 11 Jan 2021 19:07:33 -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="gOs/dNmK"; 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 S2387577AbhALDHI (ORCPT + 2 others); Mon, 11 Jan 2021 22:07:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733151AbhALDHI (ORCPT ); Mon, 11 Jan 2021 22:07:08 -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 86DD2C0617A2 for ; Mon, 11 Jan 2021 19:05:49 -0800 (PST) Received: by mail-qt1-x832.google.com with SMTP id e15so729072qte.9 for ; Mon, 11 Jan 2021 19:05:49 -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=FzoTTNnCPyrLt8K8sPUqSR8uOcEXNVFa8VbUu/a/sAw=; b=gOs/dNmKiiq2t7vlKbE823hViq8mqDd2xe0FlFuWDbHtxk/AxL1dlbLYpWEpp0IghA XrNfyCXUVO4coU0Q4AGBBQ8726X3da0O55GZD8mfh6rgie+JfTsEBk0SNAWPvsvyqNoW qaBZQnoQRoeg5YB1mUnlFX8+FS4COgYQRV3ADk8RUFSXamH9d25zkyXiKetFrgoN2Fv2 ZWI3wbDSrk40uqz/NQdI3cNDOn09tpJK/lsJiCnhc6S3h04pWVzXkOIZrEU2tutGKSdW Eo9Fhx/ZBvo9eTYvB4mpQZioGxtM1cXoUWpjDUKTxSHlrYYAKDAi+I+x2Csw59+qGyyD pDmg== 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=FzoTTNnCPyrLt8K8sPUqSR8uOcEXNVFa8VbUu/a/sAw=; b=e9TtKjtZCUATYbzXbtKkQp8nnbRh3qlSXILkBHprmpBnQiYsOfmxAUJyZjQvMCp1Bs jKpeaRUW3xSFPqc79P9ZIb73QT5nC1bwBC4Zl/A0Mw/7AquzLG+6QQXbsEfAtkoeoRJU Xrl7GiO/YLKBRRnGeRznMwYjeiSt7BsZJgAW9s/C/NiaBGv/m1V0+J0gzfoK2+0jmOHO zntRvUZIA/MPXAyGacTe9SMrkHkh1vezil4KRl8zWitIHQbDtqrnKJMUspwCnk3HCeZ9 oErJGEUScnfRc6+6Ac8VR5QNVFfjiXtSMyZ7tsxRdy8C+ZN6pswnYwZGSvDFdY/tCqfV dpMw== X-Gm-Message-State: AOAM532tHcNrPTnbX/qlzsU21MggGbTonTecEhbvhpnhsm0b0UUGCpUz 5pONC2Z9FDy0ysPW7p+NAMZCmA== X-Received: by 2002:ac8:5acb:: with SMTP id d11mr2696475qtd.269.1610420748810; Mon, 11 Jan 2021 19:05:48 -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 c7sm814235qkm.99.2021.01.11.19.05.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jan 2021 19:05:48 -0800 (PST) From: Thara Gopinath To: herbert@gondor.apana.org.au, davem@davemloft.net, bjorn.andersson@linaro.org Cc: ebiggers@google.com, ardb@kernel.org, sivaprak@codeaurora.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/6] drivers: crypto: qce: sha: Hold back a block of data to be transferred as part of final Date: Mon, 11 Jan 2021 22:05:41 -0500 Message-Id: <20210112030545.669480-3-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210112030545.669480-1-thara.gopinath@linaro.org> References: <20210112030545.669480-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. 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 08aed03e2b59..dd263c5e4dd8 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 Tue Jan 12 03:05:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 361142 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3400195jai; Mon, 11 Jan 2021 19:07:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJygB5OTiTfRA/aMzKwIE8rYRAj6RCNDnpTuDrqknw7cuiESQhXOcox/J6r1FlBUdaOn67A6 X-Received: by 2002:a17:906:2b1a:: with SMTP id a26mr1635466ejg.23.1610420849443; Mon, 11 Jan 2021 19:07:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610420849; cv=none; d=google.com; s=arc-20160816; b=A2lVNhCsplnkHkp3JUQaFeOvSFe0u9i36clhMsXhgeUZJjKI1KyMeOiO9DqgUqcWzj MatvroZyqqbJ6ppkHcINeKkja7/Hojv0ZE5BWjzC83xFFAf6PqpzaC+Dtm906aVpZ+cT MeSv2MuwKZ2uX17/5T1ymxKIwGh81tDu7lQgPDtHOAZnzJf7XydK/XHV4C1whQ3c0HfI kgQG8Dqj5aP7SAOYdRJFupna+UYVva0TauFQFRgeuDwSimtQabMfjSfAYB+ko1816zhU STrdyIP/Q3FRB9FxP5JTh1Ceyne6eGvGdLwb+etW/1CMvB1CWi8y//1OCzdi7rFZ4QiR HFsQ== 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=bZGjT91YJf1hHkSmJvXhKwaeMO0DjPBWpAMf7imhySA=; b=JQttmvzSemINBzK82RQLSkLPfGb9ysPM4DeF5/qLKUErbHZLiUM1+plRxiyE9Gj9og OQ6qxV7Phr+iqXMy1YglP+21tpiV8ge4x2TneOnaNwLhEigxYZK1zIIk146C3KrOUdGu wY2K5qJGCdlUjzbcwr0t2S726JrOVEUPgGdXFqX/xhMhyQCP6vC+yfyM+9Hk9s6w+j/I SZHXycnnAgXT0wOhIXd0dtzlFy8rIyDr4c7Aqx0zdI8gLgCvM0i2HAMckoAPr8bj4H4u wwMu1JwSIPWxqXe7Cfa9XNqPNPg0JPLS5d7k+9PplwUcwiZO40MxKza42FcPXlLtXVNA BIzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cPwO6Vqi; 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 g3si542697ejf.612.2021.01.11.19.07.29; Mon, 11 Jan 2021 19:07:29 -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=cPwO6Vqi; 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 S2387531AbhALDHI (ORCPT + 2 others); Mon, 11 Jan 2021 22:07:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733089AbhALDHI (ORCPT ); Mon, 11 Jan 2021 22:07:08 -0500 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 989B4C0617A3 for ; Mon, 11 Jan 2021 19:05:50 -0800 (PST) Received: by mail-qt1-x82e.google.com with SMTP id y15so744910qtv.5 for ; Mon, 11 Jan 2021 19:05:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bZGjT91YJf1hHkSmJvXhKwaeMO0DjPBWpAMf7imhySA=; b=cPwO6Vqi8bJ6ngi3tQNcS7FR/RoeqKI0ckxNhL6vozsRBSr05BYbxgzRECpFY+Q7Ha H0uTRrE6fKzoowoOYaxkpzIeq9SljyaNIupkV1UD52Pi1nkDsMcfHMki8MU+j3kv1iFj RbMpplbw8kpWFtsHEjzb7xDPOK52OTJed5gIa8GkaQdmGj0h+Q8enu0SY6u3f+mHR8Fc ygSN4Ahl3Fssor7OkLo8NoAVWyY/eeRz5UOBHBHoI4bBOwAkwC7oP0eTA/z9xiFuK6lT ZXVF2zXyBkP99gqFOS37J2Ub8qcJXAHAYdLajHxbsisMcwUaCU7ruoAwlun2J1J352SW TiBg== 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=bZGjT91YJf1hHkSmJvXhKwaeMO0DjPBWpAMf7imhySA=; b=A76HUutj9Fuf0lC4IxDV5619/GbWUy05N/Iba+Oull32bpRB00ECjgCBC+7ofZKSAT XzEanazPO0lV0YFYYJuMahbJ8QaIU9n9RELOTyasjGnRAzCV9jbSQ0/BhvhIEHIGCY0/ isGsPsr6laC4mjIZ2TmKRqusKZc3/1NRcf2uKpniTKBIWKy2q+vQLeG/jZIHXzNQ38o3 zigTDn0rpZ2AJm87Xkc0gu0ySg+BhSDyCYCw3nqbpPHTXEY6f2iLAE9wBGZ9rLYZu6g4 EEp24WPAv9l+B4C3ZlomHx2OZWI0fw+OaAv9UQcfj6zbROFdNU/k42NHyjKpvGFN0REM b41g== X-Gm-Message-State: AOAM530Yvn1cKA6IgKVeM9X4OSzcWsZ1fQlsitIzYCfz45+PT7K1ujKN Q6b4FDXyjMIKlvjJbKsItsN4Kg== X-Received: by 2002:ac8:6bc6:: with SMTP id b6mr2626921qtt.232.1610420749843; Mon, 11 Jan 2021 19:05:49 -0800 (PST) Received: from pop-os.fios-router.home (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.googlemail.com with ESMTPSA id c7sm814235qkm.99.2021.01.11.19.05.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jan 2021 19:05:49 -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 v2 3/6] drivers: crypto: qce: skcipher: Fix regressions found during fuzz testing Date: Mon, 11 Jan 2021 22:05:42 -0500 Message-Id: <20210112030545.669480-4-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210112030545.669480-1-thara.gopinath@linaro.org> References: <20210112030545.669480-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org This patch contains the following fixes for the supported encryption algorithms in the Qualcomm crypto engine(CE) 1. Return unsupported if key1 = key2 for AES XTS algorithm since CE does not support this and the operation causes the engine to hang. 2. Return unsupprted if any three keys are same for DES3 algorithms since CE does not support this and the operation causes the engine to hang. 3. Return unsupported for 0 length plain texts since crypto engine BAM dma does not support 0 length data. 4. ECB messages do not have an IV and hence set the ivsize to 0. 5. Ensure that the data passed for ECB/CBC encryption/decryption is blocksize aligned. Otherwise the CE hangs on the operation. 6. Allow messages of length less that 512 bytes for all other encryption algorithms other than AES XTS. The recommendation is only for AES XTS to have data size greater than 512 bytes. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 68 ++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 8 deletions(-) -- 2.25.1 diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index a2d3da0ad95f..936bfb7c769b 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -167,16 +167,32 @@ 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 -EINVAL; + } 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); @@ -204,12 +220,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; @@ -221,6 +252,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; @@ -228,14 +260,34 @@ 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; - /* qce is hanging when AES-XTS request len > QCE_SECTOR_SIZE and - * is not a multiple of it; pass such requests to the fallback + /* CE does not handle 0 length messages */ + if (!req->cryptlen) + return -EINVAL; + + /* + * 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; + + /* + * 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, @@ -307,7 +359,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 Tue Jan 12 03:05:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 361145 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3400225jai; Mon, 11 Jan 2021 19:07:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxht39c7k10bNhbUsB0kkwB2zCy9FwuvI7LqMOSHOlaYh0qvPbLMBLIER4fFNtUZumsZ0vx X-Received: by 2002:a17:906:e28c:: with SMTP id gg12mr1796990ejb.74.1610420853319; Mon, 11 Jan 2021 19:07:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610420853; cv=none; d=google.com; s=arc-20160816; b=o4FXNldzC39NpcOw9RncgNKgEOqwxScDWaFoYmoW8VQt2etsilJz7bkXKfjyfLMUSO gJ/K/dnA+Ha9FN2wWdic3P3mWpvGhMijwiD29b4rltuB6yU8eEKCwYhuaX55iOZ+lm7i QETEJjODZ3ikQEfcVOVLPqZnvNPRnwR5cr8J6WwrNItyRpkS72sQjI/OMlzaCMuGP+EH +//jZHElSTcbszkwmPJn2XfZ50jfXJku7jQZc8qSiMbE86gnl62CRV6XIbNj0oWN5IlV l0Z6J0SWo+InYJjm1tjlxh0ZVQ6lV6ouyK4lJXSaUDHGyUgcqLQHm3rbhmjZFIsWlqbD FTDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4ckoNO1YJt5QKI0zTcMaiAvFZHq1fWNUxmCXeDkmSik=; b=Jl1TbOG4lZh6uIkeMqlD5eIWDFHeE/aOYQfKJMluQMD9uTj7N8tN8OS09AnfD/+eIm jVaClbo0LTVedT6q6TgmESkCDm+1TpEhWsAUdEoxNLN6VNVcJIjiwmKFchJpBbkuPk+G Hd8JLrhPVK32xh5hlhAI7A0sfuJla0x6Jd6B0G9zUIfzOxj9P7YvWeVV9HSl09yKUmEt NcNfTN3mQqVJ0iOC1A7q0k38jYfn8xxpYfyx4vA+SGYjj6vEhQqdn6nfKH51Jvz82HNG hlhUJQRqyyt4cbc9SFLOlqXXP1Y830dfbz7Khc4yB0+NR2SvM0u3ovBcZnhvgxo9VaeR u7zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RvUHC9ef; 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 g3si542697ejf.612.2021.01.11.19.07.33; Mon, 11 Jan 2021 19:07:33 -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=RvUHC9ef; 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 S2387608AbhALDHJ (ORCPT + 2 others); Mon, 11 Jan 2021 22:07:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733259AbhALDHI (ORCPT ); Mon, 11 Jan 2021 22:07:08 -0500 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B557DC0617A5 for ; Mon, 11 Jan 2021 19:05:51 -0800 (PST) Received: by mail-qk1-x733.google.com with SMTP id n142so772146qkn.2 for ; Mon, 11 Jan 2021 19:05:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4ckoNO1YJt5QKI0zTcMaiAvFZHq1fWNUxmCXeDkmSik=; b=RvUHC9efiBoahnjz2FjLCD+IuvX86QT5zWbdiCacODGMTQGYVBOLw51LGdvI6/Ce1H PwrDw6JDzPF6Mz27YuLEbStFEnBESjXagprqey7vNXtq8UzW74p+ocfBN9MMH9ipSk67 7S4aYdodeQzhiQLmnCpqaaXcXXvKhvs4FtgD6bsnZUby3k1ssGR/H7eR0P0vklIby8Rd kQ/tL9IdYXWIuBNximdCNNerKwj1C6QyShlSuwi7ktMOOEelrdtSmdiP3SLRz+UpKVCB eZvf9fgLjC/LfI9nEsMFp18YReehWclMoL36KdUCy8JmQ4lP9bbSQPzWaEiXvORERn5y lEfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4ckoNO1YJt5QKI0zTcMaiAvFZHq1fWNUxmCXeDkmSik=; b=ZjIh5z5oi0iVvtYkMUKbwpNPsf6KstkEfb12mqiqWcU0xzwn1CK0r0mxGxCzNqlDX5 oS5GCs1B3iKyxoNQSHU1PP2iwl7btj51Z3qc9Mt4jtvJ8jNrwqtvFgW/L1VHJil60Jxq yTFNdF3L+vRpc8HuPwXC+KqlvVcglOelUuMUsjic7FcopqAx9Z5iywJr3X/yb9v6Bqlm LkotJpaB5Hh7YfC+jxaitqqCeqJrE9TRwLtbOf5i4bEy3rKC/gjfBKEfYPLb/+pZsRMC CYYc+4cxNd9MWXcVBObhZKVDT0Xa4Ys6LoZBe+1uW+SonYivnq+qfRX2WRnNo5Mhulcd y8Ug== X-Gm-Message-State: AOAM530mYD9/8mRDC4HUnlWVPDFK7lhoCQoGqXC7QKBPFY4rIRHMOkVN ftDUjcQAXd2aYXsgQClr0XyLbQ== X-Received: by 2002:ae9:e8c5:: with SMTP id a188mr2405243qkg.479.1610420751003; Mon, 11 Jan 2021 19:05:51 -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 c7sm814235qkm.99.2021.01.11.19.05.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jan 2021 19:05:50 -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 v2 4/6] drivers: crypto: qce: common: Set data unit size to message length for AES XTS transformation Date: Mon, 11 Jan 2021 22:05:43 -0500 Message-Id: <20210112030545.669480-5-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210112030545.669480-1-thara.gopinath@linaro.org> References: <20210112030545.669480-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Set the register REG_ENCR_XTS_DU_SIZE to cryptlen for AES XTS transformation. Anything else causes the engine to return back wrong results. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.25.1 diff --git a/drivers/crypto/qce/common.c b/drivers/crypto/qce/common.c index 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 Tue Jan 12 03:05:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 361144 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3400221jai; Mon, 11 Jan 2021 19:07:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8OKmS/5Gr5WrQZ9Txi/Pf7gmJ6wof8Q6TB/uqpoG8aW6DbfTn64xHJlp36T+LttfrjMZP X-Received: by 2002:a17:907:20b5:: with SMTP id pw21mr1721301ejb.494.1610420852990; Mon, 11 Jan 2021 19:07:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610420852; cv=none; d=google.com; s=arc-20160816; b=lQ/6nZpDKheIAyKHYbSKopZ7VccxpiG4//Lx+XEaP01MdUmTz6YegANqJdrqz+icdj /9wYD14XPBtqyOHCNTYtoU1weQVGbHaF/6WSiucCiRidOgbihtqEHi8UzNyjzb/T3L98 mwl9+WiRt0YZnDPGKmOrbEBuDhaAAr23TnAoIZ3OEXm2q/hXmJsapCN4J9fMsGXH+0Qy DSvPPkMG9PTMH6AwE4XHNDa6TqoEz5VfO6N8vZJIFg1nK7marfqMuMseqRCbA65QvSR0 gZt4GBqBYp7dgyq5jKu1hQmNJpv1jz94Qr5WlErv9Hn1o6UayvcnUkakymvR/yEnWar3 5JGg== 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=wMBNoXlOQQgbEyRNYqWOx3aqayV7RDKlngQoT+MuKEzRaCbXon7Z2fCPvGa/87bPkU y3RiyJ1WtlENspPEBLPK4ofSMcNYXYD7hwNHdI/A2WNuNxdJCIb33YmMYX2AtXxzZNcV hGDkLp4e1KZVz7NngVVoVd82tWcCgurcrH2Eaxih6wDvLAN5Wn2xlnph10eVE7C0CVy2 zMJGVHk8KKWeXyDHfKvkiCl4mYXGdUjZadbqqqQkDPoFR5UgmXpJ2y6tgZNTZGj0D0Dc eV2a1ITeidqN0h+tccsmerLLFD6nSM34pZuP01muJAyjE9TEFnip8ifgjA/NkXlLRrKQ rDIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FHZHVAvQ; 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 g3si542697ejf.612.2021.01.11.19.07.32; Mon, 11 Jan 2021 19:07: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=FHZHVAvQ; 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 S2387683AbhALDHJ (ORCPT + 2 others); Mon, 11 Jan 2021 22:07:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387682AbhALDHJ (ORCPT ); Mon, 11 Jan 2021 22:07:09 -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 CDD55C0617A9 for ; Mon, 11 Jan 2021 19:05:52 -0800 (PST) Received: by mail-qk1-x731.google.com with SMTP id 143so732602qke.10 for ; Mon, 11 Jan 2021 19:05:52 -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=FHZHVAvQFH71NDVBauCoz+B55dhLcRsdkajoKvOLnZoyTJq+4I8K9Og8Lk1vZ7rWnC DiAOSAnQTdcbeqKTyewqxEjHVDsHsfV9lmTTDtDNmxWm6gSgVHnEf2dEFxMM9lVfjq8F c9OTxAEXZTI5VpUbHn9dmEy5km2cowmprq03G6Bt2CxoySAKyTc7v1Oj67n8zIayR0Hy VfTyjF63WAR8kcnGg3nf2tPJJfW+awfpEhgVbgV0ggs7IJ78usyrl/lCS3yDrRnIEcSW Z++bgygu65OpIU2QEo9w7kjmeYf0DodFQ9F8mSIereqv1n43Yy+zpYvpTK/tfGqoDmVU f/AQ== 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=A0xzR1C2Ser560HNxWHg8FfYhX+6FHz+HOgwJk8VHofKirwZt8QUIso7WO1jvNwK2T qjsFM48N7bqALOIPxcS+RyKyS4plCoIXS2fpnY7+dglAXlbT629DbsEBKZuqINvzh4o1 8fdlzTf+7Y08iYeXak+jqXQkxUsv+0CDsKD3bxKmht1zuHmdczuH3ak0ztCgg8pl6BZy nTn7Zu4t5y8knmHfAvftakSqtrztXbytn+1ucbC/bI0A2Nhnn6o4HapvK/vTxdqZ+3am 1QTXl6BIl+mFbn8643hMy13MX2cpVbSArQSnUL9Ba2YQSAXIvmgVhOsgB4c0/3Y7iEGM /EDw== X-Gm-Message-State: AOAM532gwwg/KWo/+exQ4GlF8B8SXQisN6YDbaavtHMMty7RJVD/oaqn srd6xJrcqhh3CSI1o3yufFLgQg== X-Received: by 2002:a37:5b85:: with SMTP id p127mr2514915qkb.180.1610420752138; Mon, 11 Jan 2021 19:05:52 -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 c7sm814235qkm.99.2021.01.11.19.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jan 2021 19:05:51 -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 v2 5/6] drivers: crypto: qce: Remover src_tbl from qce_cipher_reqctx Date: Mon, 11 Jan 2021 22:05:44 -0500 Message-Id: <20210112030545.669480-6-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210112030545.669480-1-thara.gopinath@linaro.org> References: <20210112030545.669480-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 Tue Jan 12 03:05:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 361143 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3400214jai; Mon, 11 Jan 2021 19:07:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWe7NnOhrtzvrt92gtayNMiWax6KcACUvR4CDOEWRmsSCT/lATMxOsO6BBnRzAoWTH18zl X-Received: by 2002:a50:8b66:: with SMTP id l93mr1657164edl.384.1610420852634; Mon, 11 Jan 2021 19:07:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610420852; cv=none; d=google.com; s=arc-20160816; b=j+Kl2Bxr1a51xKzqour73JO/b8eyajSE/4ElclCzDr0/xRpJAu/rmqsR7QPn+O1XXT +o65xCDIwHNlsYarPMp5rIpU+cR75UcnJpihYeS9Lu0pT//wBsTTi/4O00etWAb5xS1c uLoND7FSc4s2GzVv3l9qDWOqupH2BigLkwKLg0LjJ5M3IFelosGdyI9Eb1fIhIj5NT/I ITboTtLTA44eP4KwIln+XhBOPKws8pGrZev89BuU5yF+DYWPteWUoc9AJ3LaiGxGrDZK WD3D5dkJ8f/irE0yN30rjRbCHt2p8DLrPy1osIVvEv/rbIiiSUJZMaIl9KUkBkiGd8sc FUoA== 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=xgi65kSxCtkSEFXSk+Ziqt8xvxh6x9q3ozPOFxdoDG4=; b=mYwcjGtbJhuWpFDqGdx2LVbjh0D9692gf9KqEqNR5TWh85zzVZsX55SX+pizWHnw2L fmiUGApQqwt5izlJrfvgwgPqKbcs1LxRMhIqe2bEtuR8z3lb8JMIQDTkTalFBIuUXcJk tB0604EWmVz+OqT+q6RQesYNfzKihsetJWiNr64XM1ZHjAnKF+KbNUPIf5C7QjGOajxT Ci6xeAd62Afxe72LbJOK8MgHpXTmW+4HD5mIsFKF5azr0HaH0XX5Zg5iQv//pjU3Okyw i99p4DtOWbvvpOpkI2J2D8CHvNZfLLVvzL8cbAIx83BP+tjAU/nrrubD3uTiQ96MJas+ tHSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Qu7gN/zv"; 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 g3si542697ejf.612.2021.01.11.19.07.32; Mon, 11 Jan 2021 19:07: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="Qu7gN/zv"; 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 S2387979AbhALDHQ (ORCPT + 2 others); Mon, 11 Jan 2021 22:07:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387674AbhALDHQ (ORCPT ); Mon, 11 Jan 2021 22:07:16 -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 EEE56C0617AB for ; Mon, 11 Jan 2021 19:05:53 -0800 (PST) Received: by mail-qt1-x82f.google.com with SMTP id j26so734910qtq.8 for ; Mon, 11 Jan 2021 19:05:53 -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=xgi65kSxCtkSEFXSk+Ziqt8xvxh6x9q3ozPOFxdoDG4=; b=Qu7gN/zvRvs+jPzDp9Zw3b3JjdN0UK7EtPq+8hW/7hXtJQwlbzYxegrnBvZnd1iMkU 6lLN1pL8DZbDSiG0wgHurOFto9UKIcMjNlxDpgmOasSO25RQNeFKtx1fQwDfy5lZrA/e gIKVt7OrMs3uJ3IiXrnASqhYxXmv0uoBe6lyyR6O76mqakSTEiRjgCBmP7JVFdd1PjqZ fN5mmbYUp5ZDzpzxypMK4bv9yDvoB34xD3loNIQSlaAsUrNdSspZjxbehIxs+UV8drcJ wjnxa9cof6PgvoyQrIUyOafTxuHwcBlWcTvo0MXAz/0tmKfa7/XUXAkICKQLAFAW/ZF7 k+sw== 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=xgi65kSxCtkSEFXSk+Ziqt8xvxh6x9q3ozPOFxdoDG4=; b=twKu53AIZEt4xoPJeBvvEdgkYIZyrgv6lDZ/KcTyRYSjimHJ4zsf+A8MtzPEbrQvJe d7QNB83Si89CQ5oVD4d0zSV8WxnAEoQ40nElo/feJWscKVGK2uyvYoTejT+ccQBiJubO f2Wph/MUTQL8SEsY+S6tnvEdjtCqIsjK74hf6Y6PoibbMh6YugZmvHXx04lvjG/Ot9AC 3OZM7o7lIzQsU+LEFpD9i3eCR8VisDR5OeaU4Rwx+0H3h87vdeDWGbrur90zmfrlNWhm KPrIUi8nMcbg90jwE0ec8U3yvefQnM8oQY545YGQl6zwC4rdHcWmgtyPH7YtaMNLhRZJ E8Ww== X-Gm-Message-State: AOAM5332CKDyY2JTjYROv31c/tRGQJtZMlK6ilL6Qi9jo6Mb/516b60Q I7C7gpuWvSXtrSbyz9RAX24tOw== X-Received: by 2002:ac8:110e:: with SMTP id c14mr2586459qtj.293.1610420753230; Mon, 11 Jan 2021 19:05:53 -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 c7sm814235qkm.99.2021.01.11.19.05.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jan 2021 19:05:52 -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 v2 6/6] drivers: crypto: qce: Remove totallen and offset in qce_start Date: Mon, 11 Jan 2021 22:05:45 -0500 Message-Id: <20210112030545.669480-7-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210112030545.669480-1-thara.gopinath@linaro.org> References: <20210112030545.669480-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. 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 dd263c5e4dd8..a079e92b4e75 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 936bfb7c769b..2f327640b4de 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -143,7 +143,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;