[PATCH] crypto/fsl: fsl_hash: Fix dcache issue in caam_hash_finish

Rasmus Villemoes rasmus.villemoes at prevas.dk
Wed May 11 15:55:03 CEST 2022


On 11/05/2022 10.53, Gaurav Jain wrote:
> HW accelerated hash operations are giving incorrect hash output.
> so add flush and invalidate for input/output hash buffers.
> 
> Fixes: 94e3c8c4fd (crypto/fsl - Add progressive hashing support using hardware acceleration.)

AFAICT, it takes somewhat more to fix that commit; the progressive
hashing is entirely broken.

It doesn't actually do anything progressive, it just stashes the
address/length pairs it is given, but doesn't feed the contents of those
buffers to the hardware, folding it into the hash state. So the caller
must not touch the buffers it passes until the finalization. I.e. I
think this won't work:

  char buf[SOMETHING];

  update_buffer(buf);
  hash_update(buf, len);
  update_buffer_again(buf);
  hash_update(buf, len);

And this pattern can be found in e.g. drivers/dfu/dfu.c which seems to
repeatedly pass the same address (dfu->i_buf_start) to ->hash_update.

Am I reading the code wrong?

Rasmus


More information about the U-Boot mailing list