[Linux-stm32] [v7 PATCH 8/8] crypto: stm32 - Save and restore between each request
Thomas BOURGOIN
thomas.bourgoin at foss.st.com
Mon Mar 27 08:33:10 UTC 2023
Hi Herbert,
I'm working on the patch for STM32MP13.
On Sat, Mar 11, 2023 at 10:09 AM Herbert Xu<herbert at gondor.apana.org.au> wrote:
> 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 at nfschina.com>
> Signed-off-by: Herbert Xu<herbert at gondor.apana.org.au>
> ---
>
> drivers/crypto/stm32/stm32-hash.c | 164 ++++++++++++--------------------------
> 1 file changed, 56 insertions(+), 108 deletions(-)
>
> diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c
> index f898ec62b459..17183f631bb4 100644
> --- a/drivers/crypto/stm32/stm32-hash.c
> +++ b/drivers/crypto/stm32/stm32-hash.c
> @@ -135,7 +135,7 @@ struct stm32_hash_state {
> u8 buffer[HASH_BUFLEN] __aligned(4);
>
> /* hash state */
> - u32 *hw_context;
> + u32 hw_context[3 + HASH_CSR_REGISTER_NUMBER];
> };
The version of HASH implemented in the STM32MP13 provides new algorithms (SHA512, SHA3, ...).
Because of that, the constant HASH_CSR_REGISTER_NUMBER increases (from 54 to 103).
Hence, the size of stm32_hash_state is equal to 688 which is bigger than HASH_MAX_STATESIZE(=512)
and the driver fails to register the algorithms.
Is there any reasons why HASH_MAX_STATESIZE is set to 512 ?
I only see it used to define static arrays, so maybe it could be set to 1024.
BR
Thomas Bourgoin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://st-md-mailman.stormreply.com/pipermail/linux-stm32/attachments/20230327/526997f0/attachment.html>
More information about the Linux-stm32
mailing list