crypto: stm32 - Save and restore between each request
authorHerbert Xu <herbert@gondor.apana.org.au>
Sat, 11 Mar 2023 09:09:25 +0000 (17:09 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 17 Mar 2023 03:16:44 +0000 (11:16 +0800)
commite6af5c0c4d32a27e04a56f29aad587e03ff427f1
tree2c72d727fa67b443ad31062ba39f75e925d35e99
parent9fa4298a95ec42cb63dc5aaf2a8656bb23adf280
crypto: stm32 - Save and restore between each request

The Crypto API hashing paradigm requires the hardware state to
be exported between *each* request because multiple unrelated
hashes may be processed concurrently.

The stm32 hardware is capable of producing the hardware hashing
state but it was only doing it in the export function.  This is
not only broken for export as you can't export a kernel pointer
and reimport it, but it also means that concurrent hashing was
fundamentally broken.

Fix this by moving the saving and restoring of hardware hash
state between each and every hashing request.

Fixes: 8a1012d3f2ab ("crypto: stm32 - Support for STM32 HASH module")
Reported-by: Li kunyu <kunyu@nfschina.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/stm32/stm32-hash.c