From: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
To: herbert@gondor.apana.org.au
Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, benh@kernel.crashing.org,
Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Subject: [PATCH v2 10/10] crypto: nx - fix SHA-2 for chunks bigger than block size
Date: Thu, 29 Aug 2013 11:36:40 -0300 [thread overview]
Message-ID: <1377787000-4966-11-git-send-email-mhcerri@linux.vnet.ibm.com> (raw)
In-Reply-To: <1377787000-4966-1-git-send-email-mhcerri@linux.vnet.ibm.com>
Each call to the co-processor, with exception of the last call, needs to
send data that is multiple of block size. As consequence, any remaining
data is kept in the internal NX context.
This patch fixes a bug in the driver that causes it to save incorrect
data into the context when data is bigger than the block size.
Reviewed-by: Joy Latten <jmlatten@linux.vnet.ibm.com>
Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
---
drivers/crypto/nx/nx-sha256.c | 2 +-
drivers/crypto/nx/nx-sha512.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/nx/nx-sha256.c b/drivers/crypto/nx/nx-sha256.c
index 6547a71..da0b24a 100644
--- a/drivers/crypto/nx/nx-sha256.c
+++ b/drivers/crypto/nx/nx-sha256.c
@@ -129,7 +129,7 @@ static int nx_sha256_update(struct shash_desc *desc, const u8 *data,
NX_CPB_FDM(csbcpb) |= NX_FDM_CONTINUATION;
total -= to_process;
- data += to_process;
+ data += to_process - sctx->count;
sctx->count = 0;
in_sg = nx_ctx->in_sg;
} while (leftover >= SHA256_BLOCK_SIZE);
diff --git a/drivers/crypto/nx/nx-sha512.c b/drivers/crypto/nx/nx-sha512.c
index 236e6af..4ae5b0f 100644
--- a/drivers/crypto/nx/nx-sha512.c
+++ b/drivers/crypto/nx/nx-sha512.c
@@ -131,7 +131,7 @@ static int nx_sha512_update(struct shash_desc *desc, const u8 *data,
NX_CPB_FDM(csbcpb) |= NX_FDM_CONTINUATION;
total -= to_process;
- data += to_process;
+ data += to_process - sctx->count[0];
sctx->count[0] = 0;
in_sg = nx_ctx->in_sg;
} while (leftover >= SHA512_BLOCK_SIZE);
--
1.7.12
next prev parent reply other threads:[~2013-08-29 14:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-29 14:36 [PATCH v2 00/10] Series of fixes for NX driver Marcelo Cerri
2013-08-29 14:36 ` [PATCH v2 01/10] crypto: nx - add offset to nx_build_sg_lists() Marcelo Cerri
2013-08-29 14:36 ` [PATCH v2 02/10] crypto: nx - fix limits to sg lists for AES-ECB Marcelo Cerri
2013-08-29 14:36 ` [PATCH v2 03/10] crypto: nx - fix limits to sg lists for AES-CBC Marcelo Cerri
2013-08-29 14:36 ` [PATCH v2 04/10] crypto: nx - fix limits to sg lists for AES-CTR Marcelo Cerri
2013-08-29 14:36 ` [PATCH v2 05/10] crypto: nx - fix limits to sg lists for AES-GCM Marcelo Cerri
2013-08-29 14:36 ` [PATCH v2 06/10] crypto: nx - fix limits to sg lists for AES-XCBC Marcelo Cerri
2013-08-29 14:36 ` [PATCH v2 07/10] crypto: nx - fix limits to sg lists for AES-CCM Marcelo Cerri
2013-08-29 14:36 ` [PATCH v2 08/10] crypto: nx - fix XCBC for zero length messages Marcelo Cerri
2013-08-29 14:36 ` [PATCH v2 09/10] crypto: nx - fix GCM " Marcelo Cerri
2013-08-29 14:36 ` Marcelo Cerri [this message]
2013-09-02 10:35 ` [PATCH v2 00/10] Series of fixes for NX driver Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1377787000-4966-11-git-send-email-mhcerri@linux.vnet.ibm.com \
--to=mhcerri@linux.vnet.ibm.com \
--cc=benh@kernel.crashing.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).