Skip to content

Commit b4e9e93

Browse files
iuliana-prodanherbertx
authored andcommitted
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: 12b8567 ("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>
1 parent dac0bde commit b4e9e93

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

drivers/crypto/caam/caamhash.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -865,19 +865,18 @@ static int ahash_update_ctx(struct ahash_request *req)
865865
if (ret)
866866
goto unmap_ctx;
867867

868-
if (mapped_nents) {
868+
if (mapped_nents)
869869
sg_to_sec4_sg_last(req->src, mapped_nents,
870870
edesc->sec4_sg + sec4_sg_src_index,
871871
0);
872-
if (*next_buflen)
873-
scatterwalk_map_and_copy(next_buf, req->src,
874-
to_hash - *buflen,
875-
*next_buflen, 0);
876-
} else {
872+
else
877873
sg_to_sec4_set_last(edesc->sec4_sg + sec4_sg_src_index -
878874
1);
879-
}
880875

876+
if (*next_buflen)
877+
scatterwalk_map_and_copy(next_buf, req->src,
878+
to_hash - *buflen,
879+
*next_buflen, 0);
881880
desc = edesc->hw_desc;
882881

883882
edesc->sec4_sg_dma = dma_map_single(jrdev, edesc->sec4_sg,

0 commit comments

Comments
 (0)