cancel
Showing results for 
Search instead for 
Did you mean: 

SHA 256 result from stm32H750VB does not match the result from the internet

nanotronicsnss
Associate II

Hi,

I have used STM32H750VB IC and have done SHA256 conversion of a given data using an inbuilt function

HAL_HASHEx_SHA256_Start(&hhash,(uint8_t*)'A',sizeof('A'),(uint8_t*)aSHA256Digest,200);

HAL_HASHEx_SHA256_Finish(&hhash,(uint8_t*)aSHA256Digest,200);

where

A is the secret key for sha 256

uint8_t aSHA256Digest[32];

the output obtained from serial monitor is

:

0xE0 0x3D 0x13 0xB9 0xF8 0xEE 0xE3 0xF1 0xFF 0x94 0x5E 0x8F 0x0A 0x20 0x75 0x6B 0x1A 0x02 0x6C 0xAC 0x50 0x79 0xC4 0x09 0xE6 0x46 0x8F 0x5C 0x40 0xCD 0x35 0x09 

The output from internet is :( https://www.freeformatter.com/hmac-generator.html#ad-output)

ff333794c5afd126a4e75aef1a35595a846e9e1d4053017d78d7aa3d8373182a

which do not match. Can anyone suggest me a solution?

3 REPLIES 3
TDK
Guru

Doesn't look like HAL_HASHEx_SHA256_Finish should be called in polling mode. See instructions at the top of the HAL file.

https://github.com/STMicroelectronics/STM32CubeH7/blob/3d3ffbe6e15fc7e4d8a4d275e9fb3a334e31c8a3/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_hash_ex.c

I don't see any examples using HAL_HASHEx_SHA256_* functions.

If you feel a post has answered your question, please click "Accept as Solution".

This is not valid C code (uint8_t*)'A'

Equivalent to (uint8_t *)65, what have you got at address 65 ?

You want (uint8_t *)"A"

Try this, better chance of functioning as expect

HAL_HASHEx_SHA256_Start(&hhash,(uint8_t*)"A",1,(uint8_t*)aSHA256Digest,200);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Piranha
Chief II

Doesn't the secret key hint to anything? HMAC-SHA256 is not the same thing as SHA256.

https://www.freeformatter.com/message-digest.html