I am calculating a HMAC-SHA-256 with your library (latest version cloned) as follows (snippet):
#include <Crypto.h>
byte calculated_HMAC[32];
// "Jefe"
byte testvector_2_key[4] = {74, 101, 102, 101};
SHA256HMAC hmac_for_check(testvector_2_key, 4);
hmac_for_check.doUpdate("what do ya want for nothing?");
hmac_for_check.doFinal(calculated_HMAC);
int i;
for (i = 0; i < 32; i++) {
Serial.print("HMAC is:");
Serial.println(calculated_HMAC[i], HEX);
}
Which then gives:
HMAC in hex is:89
HMAC in hex is:A1
HMAC in hex is:B9
HMAC in hex is:C1
HMAC in hex is:26
HMAC in hex is:E4
HMAC in hex is:CB
HMAC in hex is:FE
HMAC in hex is:0
HMAC in hex is:11
HMAC in hex is:B6
HMAC in hex is:9C
HMAC in hex is:87
HMAC in hex is:E2
HMAC in hex is:39
HMAC in hex is:50
HMAC in hex is:30
HMAC in hex is:96
HMAC in hex is:77
HMAC in hex is:9C
HMAC in hex is:47
HMAC in hex is:FB
HMAC in hex is:88
HMAC in hex is:9
HMAC in hex is:77
HMAC in hex is:3C
HMAC in hex is:A9
HMAC in hex is:1A
HMAC in hex is:FE
HMAC in hex is:63
HMAC in hex is:28
HMAC in hex is:80
According to rfc4231 section 4.3. Test Case 2 it should give instead:
Hello!
I am calculating a HMAC-SHA-256 with your library (latest version cloned) as follows (snippet):
Which then gives:
According to rfc4231 section 4.3. Test Case 2 it should give instead:
When I use my python code or on online Tool, e.g., HMAC generator it gives the HMAC-SHA-256 as in the rfc.
This observation makes me conclude that your library does not calculate HMAC-SHA-256 correctly.
Could you please have a look at it?
Thanks a lot, paško