cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H5 HASH peripheral chunk sizes

PieterG
Associate III

I'm trying to use the STM32H563 HASH peripheral to speed up sha256 calculations.

The examples all use HAL_HASH_Start() to write the entire message at once.

However, I'd like to feed chunks of data to the peripheral. The OEMiROT mbedtls sha256_alt driver uses the same approach:

STM32CubeH5/Projects/NUCLEO-H563ZI/Applications/ROT/OEMiROT_Boot/Src/sha256_alt.c

However, I notice that this driver accumulates data in a buffer, then feeds the data chunk by chunk.
The first chunk is 68 bytes in size, subsequent chunks are 64 bytes.

My questions are:

-do we really have to feed data in chunks? Reading the reference manual, it seems that data can be fed one 32bit word at a time?

-why would the first chunk be 68 bytes instead of 64? Is this perhaps an optimalisation causing each feed (including the very first one) to start the intermediate digest calculation (because each first word of a new block will trigger the calculation)? Or is there more to it?

1 ACCEPTED SOLUTION

Accepted Solutions
PieterG
Associate III

I have tested without chunking, and as expected the HASH peripheral still works.

As long as we feed a multiple of 4 bytes of course.

 

Because the data can be written directly, memcpy is avoided. So I prefer not to accumulate data in 64 (68) byte chunks.

View solution in original post

1 REPLY 1
PieterG
Associate III

I have tested without chunking, and as expected the HASH peripheral still works.

As long as we feed a multiple of 4 bytes of course.

 

Because the data can be written directly, memcpy is avoided. So I prefer not to accumulate data in 64 (68) byte chunks.