hmaC - HMAC for C
includes hash functions
This is a pure C implementation of HMAC and related hash functions to be used in embedded applications or environments that are not containing such hash functions, ssl libraries etc.
But Why?
Well, in these days encryption is important and de-facto standard when it comes to communications. But embedded industry follows a bit behind than servers. So in order to identify messages HMAC is being used. (eg: HTTP Authorization header)
Let's say you wanted your coffee machine to tweet you when your coffee is ready, you use ESP8266 but cannot use Twitter REST api directly because it requires you to HMAC-MD5 your keys with your data and send it. So you put a gateway (eg: Amazon Lambda) to add these to message. Say no more to this. Communicate directly with the host, reduced latency, complexity for your app :)
First we allocate target with pre-defined MD5HashSize constant
then passing data to function which in result writes to the bytes array.
We use btoa to get hex digest (hexadecimal string) of our hash.
Since our hash is binary (0-255) we can use this function to send it as HTTP header in our application for example.
First we allocate target with pre-defined SHA1HashSize constant
then passing data to function which in result writes to the bytes array.
Also there is atob function which takes hex string and returns binary representation (void*).