SHA256 computation hangs on STM32L562 discovery board.
Hi, I hope the day is going well for everyone.
We've been working to validate SHA256 computations on the HASH unit of the board named in the question. In the process we have noted what appears to be a reproducible problem with the unit.
In short it appears as if submitting a block of data on which to compute a SHA256 checksum hangs if the block of data is an even multiple of 32 bits, the word size of register in the HASH unit.
The simplistic way to reproduce the problem is to request a hash of the following string:
abcdefghijkl
Followed by a request to compute the hash of the following string:
abcdefgh
The checksum computed from the first string is correct but the request to compute the second string hangs or gives a completely erroneous value.
We have reproduced this behavior using both the HAL_HASHEx_SHA256_Start function which uses polling mode as well as with the HAL_HASHEx_SHA256_Start_DMA function in DMA mode.
In addition to hanging on the second request in polling mode, the computation will sometimes generate a completely erroneous checksum which is notable for having long runs of null bytes in the checksum which would certainly not be expected.
In DMA mode the computation of the second digest always hangs which seems to indicate that the HASH unit is not generating a completion interrupt.
We have run multiple test vectors which give the correct checksums, a fact that seems to suggest we are using the HAL library correctly. In the case of the polling function, there doesn't seem to be much to get wrong since it simply requires calling the function with an initialized context, an input buffer and size plus an output buffer.
We have other evidence that suggests the regression occurs on various inputs when an even word size but less then a complete block size is submitted to the HASH unit.
Any reflections would be of interested.
Dr. Greg
