aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIuliana Prodan <iuliana.prodan@nxp.com>2019-03-22 08:12:30 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2019-03-28 01:54:32 -0400
commitb4e9e931e9bb2f5b302ce66640832f5a3e57e8c4 (patch)
tree6c209289547a11d9d16692235aec3fc0540af91d
parentdac0bde43b0b3685390b68c9058bee36d4d5c747 (diff)
crypto: caam - fix copy of next buffer for xcbc and cmac
Fix a side effect of adding xcbc support, when the next_buffer is not copied. The issue occurs, when there is stored from previous state a blocksize buffer and received, a less than blocksize, from user. In this case, the nents for req->src is 0, and the next_buffer is not copied. An example is: { .tap = { 17, 15, 8 }, .psize = 40, .np = 3, .ksize = 16, } Fixes: 12b8567f6fa4 ("crypto: caam - add support for xcbc(aes)") Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com> Reviewed-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--drivers/crypto/caam/caamhash.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
index b1eadc6652b5..7205d9f4029e 100644
--- a/drivers/crypto/caam/caamhash.c
+++ b/drivers/crypto/caam/caamhash.c
@@ -865,19 +865,18 @@ static int ahash_update_ctx(struct ahash_request *req)
865 if (ret) 865 if (ret)
866 goto unmap_ctx; 866 goto unmap_ctx;
867 867
868 if (mapped_nents) { 868 if (mapped_nents)
869 sg_to_sec4_sg_last(req->src, mapped_nents, 869 sg_to_sec4_sg_last(req->src, mapped_nents,
870 edesc->sec4_sg + sec4_sg_src_index, 870 edesc->sec4_sg + sec4_sg_src_index,
871 0); 871 0);
872 if (*next_buflen) 872 else
873 scatterwalk_map_and_copy(next_buf, req->src,
874 to_hash - *buflen,
875 *next_buflen, 0);
876 } else {
877 sg_to_sec4_set_last(edesc->sec4_sg + sec4_sg_src_index - 873 sg_to_sec4_set_last(edesc->sec4_sg + sec4_sg_src_index -
878 1); 874 1);
879 }
880 875
876 if (*next_buflen)
877 scatterwalk_map_and_copy(next_buf, req->src,
878 to_hash - *buflen,
879 *next_buflen, 0);
881 desc = edesc->hw_desc; 880 desc = edesc->hw_desc;
882 881
883 edesc->sec4_sg_dma = dma_map_single(jrdev, edesc->sec4_sg, 882 edesc->sec4_sg_dma = dma_map_single(jrdev, edesc->sec4_sg,