Skip to main content
JMene.1
Associate II
October 31, 2025
Solved

STM32L552 HASH Peripheral final digest with a multiple of 512 bits message

  • October 31, 2025
  • 1 reply
  • 174 views

I try to understand in details the way the Hash peripheral works on the STM32L552. I need to make the HASH SHA-256 with 224 blocks of 512 bits. The Hash works perfectly until the block 223. Then I enter 16 values in the FIFO (in my code below I have a loop for 15 because I entered previously another value). Then I launch the final digest. I expect the automatic digest of block 224 and the automatic padding in a block 225 to the final hash value. But I always have the wrong value in the final step. Any idea about what I'm missing?

JMene1_0-1761940069386.png

 

Best answer by JMene.1

I reply to my own problem. I did not have the same result on the STM32 and the Hashlib from python because I made a mistake about the endianness of the padding. The hash processor is little endian and the position of the '1' for the padding was placed as big endian in my experiment. Once I corrected the endianness, all the calculations are correct.

1 reply

JMene.1
JMene.1AuthorBest answer
Associate II
November 18, 2025

I reply to my own problem. I did not have the same result on the STM32 and the Hashlib from python because I made a mistake about the endianness of the padding. The hash processor is little endian and the position of the '1' for the padding was placed as big endian in my experiment. Once I corrected the endianness, all the calculations are correct.