I found the esp32 datasheet (at https://www.espressif.com/sites/default ... ual_en.pdf ) - which makes for interesting reading.
I managed to get the 'genuine' random number generator working easily but - as I need SHA256 function for a project - then tried to get that working by writing to registers / memory (it looks straightforward!)
This failed - always returning 0.
So then - trawling through the espressif includes found mbedtls/sha256.h - which does exactly what's needed (other SHA schemes are also available!)
I wrote a simple program to test - and all seems well. It can probably be made into a component too. Here it does a very simple SHA256 calculation (4 bytes) - and I checked the result against https://xorbin.com/tools/sha256-hash-calculator (which doesn't need quotes)
Note that you can amend the mbedTLS config by using idf.py menuconfig (it's under component config).
SHA256_Update takes an array of bytes of any length and can also be called multiple times before calling SHA256_Finish.
I don't check the result bytes returned (0 is success)
There are a host of other 'tools' in the mbedTLS folder (sha512, RSA etc) which look similar to use....
Martin
esp32 Hardware SHA256 function
-
- Valued Contributor
- Posts: 1024
- http://meble-kuchenne.info.pl
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 107 times
- Been thanked: 532 times
-
- Valued Contributor
- Posts: 1207
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 293 times
- Been thanked: 424 times
Re: esp32 Hardware SHA256 function
Hi Martin
Although I've no need for that functionality just yet, it's always interesting to read your "how to" posts.
Regards
Although I've no need for that functionality just yet, it's always interesting to read your "how to" posts.
Regards