crypto: nx - fix SHA-2 for chunks bigger than block size
authorMarcelo Cerri <mhcerri@linux.vnet.ibm.com>
Thu, 29 Aug 2013 14:36:40 +0000 (11:36 -0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 2 Sep 2013 10:32:56 +0000 (20:32 +1000)
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>
drivers/crypto/nx/nx-sha256.c
drivers/crypto/nx/nx-sha512.c

index 6547a7104bf64f96b4e0fe6c9a58e7114b3884e9..da0b24a7633f0c55626d6c9ecefe8211c7ef7817 100644 (file)
@@ -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);
index 236e6afeab1067701cd75e07bfdcf00fe41baef0..4ae5b0f221d5306fa96c47b423cf143b0454504e 100644 (file)
@@ -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);
This page took 0.033983 seconds and 5 git commands to generate.