Commit 1148a9654b5a69611d33e14719251c6ec20f5f2c

Authored by Thara Gopinath
Committed by Herbert Xu
1 parent 8cbc344821

crypto: qce - Fix SHA result buffer corruption issues

Partial hash was being copied into the final result buffer without the
entire message block processed. Depending on how the end user processes
this result buffer, errors vary from result buffer corruption to result
buffer poisoing. Fix this issue by ensuring that only the final hash value
is copied into the result buffer.

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

drivers/crypto/qce/sha.c
... ... @@ -48,7 +48,7 @@
48 48 dma_unmap_sg(qce->dev, &rctx->result_sg, 1, DMA_FROM_DEVICE);
49 49  
50 50 memcpy(rctx->digest, result->auth_iv, digestsize);
51   - if (req->result)
  51 + if (req->result && rctx->last_blk)
52 52 memcpy(req->result, result->auth_iv, digestsize);
53 53  
54 54 rctx->byte_count[0] = cpu_to_be32(result->auth_byte_count[0]);