Skip to content

Commit

Permalink
crypto: nx - fix SHA-2 for chunks bigger than block size
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Marcelo Cerri authored and Herbert Xu committed Sep 2, 2013
1 parent dec0ed6 commit 069fa04
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/crypto/nx/nx-sha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/crypto/nx/nx-sha512.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 069fa04

Please sign in to comment.