Skip to content

Commit 069fa04

Browse files
Marcelo Cerriherbertx
authored andcommitted
crypto: nx - fix SHA-2 for chunks bigger than block size
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>
1 parent dec0ed6 commit 069fa04

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/crypto/nx/nx-sha256.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static int nx_sha256_update(struct shash_desc *desc, const u8 *data,
129129
NX_CPB_FDM(csbcpb) |= NX_FDM_CONTINUATION;
130130

131131
total -= to_process;
132-
data += to_process;
132+
data += to_process - sctx->count;
133133
sctx->count = 0;
134134
in_sg = nx_ctx->in_sg;
135135
} while (leftover >= SHA256_BLOCK_SIZE);

‎drivers/crypto/nx/nx-sha512.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static int nx_sha512_update(struct shash_desc *desc, const u8 *data,
131131
NX_CPB_FDM(csbcpb) |= NX_FDM_CONTINUATION;
132132

133133
total -= to_process;
134-
data += to_process;
134+
data += to_process - sctx->count[0];
135135
sctx->count[0] = 0;
136136
in_sg = nx_ctx->in_sg;
137137
} while (leftover >= SHA512_BLOCK_SIZE);

0 commit comments

Comments
 (0)