2020-10-20 12:00 AM
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?
2020-10-20 04:23 PM
Doesn't look like HAL_HASHEx_SHA256_Finish should be called in polling mode. See instructions at the top of the HAL file.
I don't see any examples using HAL_HASHEx_SHA256_* functions.
2020-10-20 04:39 PM
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);
2020-10-31 10:25 AM
Doesn't the secret key hint to anything? HMAC-SHA256 is not the same thing as SHA256.