Test hmacsha512 with keys larger than the block size
This commit is contained in:
parent
e333e55209
commit
a721543b58
@ -6,18 +6,45 @@
|
||||
unsigned char key[32] = "Jefe";
|
||||
unsigned char c[] = "what do ya want for nothing?";
|
||||
|
||||
unsigned char a[32];
|
||||
/* Hacker manifesto */
|
||||
unsigned char key2[175] = "Another one got caught today, it's all over the papers. \"Teenager Arrested in Computer Crime Scandal\", \"Hacker Arrested after Bank Tampering\"... Damn kids. They're all alike.";
|
||||
|
||||
unsigned char a[crypto_auth_BYTES];
|
||||
unsigned char a2[crypto_auth_hmacsha512_BYTES];
|
||||
|
||||
int main(void)
|
||||
{
|
||||
crypto_auth_hmacsha512_state st;
|
||||
int i;
|
||||
|
||||
crypto_auth(a, c, sizeof c - 1U, key);
|
||||
for (i = 0; i < 32; ++i) {
|
||||
for (i = 0; i < sizeof a; ++i) {
|
||||
printf(",0x%02x", (unsigned int)a[i]);
|
||||
if (i % 8 == 7)
|
||||
printf("\n");
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
crypto_auth_hmacsha512_init(&st, key, sizeof key);
|
||||
crypto_auth_hmacsha512_update(&st, c, 1U);
|
||||
crypto_auth_hmacsha512_update(&st, c, sizeof c - 2U);
|
||||
crypto_auth_hmacsha512_final(&st, a2);
|
||||
for (i = 0; i < sizeof a2; ++i) {
|
||||
printf(",0x%02x", (unsigned int)a2[i]);
|
||||
if (i % 8 == 7)
|
||||
printf("\n");
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
crypto_auth_hmacsha512_init(&st, key2, sizeof key2);
|
||||
crypto_auth_hmacsha512_update(&st, c, 1U);
|
||||
crypto_auth_hmacsha512_update(&st, c, sizeof c - 2U);
|
||||
crypto_auth_hmacsha512_final(&st, a2);
|
||||
for (i = 0; i < sizeof a2; ++i) {
|
||||
printf(",0x%02x", (unsigned int)a2[i]);
|
||||
if (i % 8 == 7)
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
assert(crypto_auth_bytes() > 0U);
|
||||
assert(crypto_auth_keybytes() > 0U);
|
||||
|
@ -2,3 +2,21 @@
|
||||
,0xe3,0x95,0xfb,0xe7,0x3b,0x56,0xe0,0xa3
|
||||
,0x87,0xbd,0x64,0x22,0x2e,0x83,0x1f,0xd6
|
||||
,0x10,0x27,0x0c,0xd7,0xea,0x25,0x05,0x54
|
||||
|
||||
,0x7b,0x9d,0x83,0x38,0xeb,0x1e,0x3d,0xdd
|
||||
,0xba,0x8a,0x9a,0x35,0x08,0xd0,0x34,0xa1
|
||||
,0xec,0xbe,0x75,0x11,0x37,0xfa,0x1b,0xcb
|
||||
,0xa0,0xf9,0x2a,0x3e,0x6d,0xfc,0x79,0x80
|
||||
,0xb8,0x81,0xa8,0x64,0x5f,0x92,0x67,0x22
|
||||
,0x74,0x37,0x96,0x4b,0xf3,0x07,0x0b,0xe2
|
||||
,0xb3,0x36,0xb3,0xa3,0x20,0xf8,0x25,0xce
|
||||
,0xc9,0x87,0x2d,0xb2,0x50,0x4b,0xf3,0x6d
|
||||
|
||||
,0xfc,0x04,0xa0,0x33,0x1d,0xc3,0x1a,0x3b
|
||||
,0x6d,0x0e,0xdc,0x94,0xf4,0x6d,0x4c,0xd6
|
||||
,0x5d,0x2a,0x3b,0x94,0x92,0x9d,0xa8,0xc7
|
||||
,0x98,0xd2,0x75,0x9e,0x85,0xe3,0x3a,0x73
|
||||
,0x25,0x9e,0xd4,0x46,0xe0,0x10,0x43,0xe8
|
||||
,0x35,0x61,0x03,0x4e,0x5c,0xa4,0xbd,0x61
|
||||
,0x9f,0x8c,0x06,0xeb,0x93,0x6c,0x90,0x78
|
||||
,0xde,0x04,0x72,0x7c,0xfe,0x39,0x62,0xd1
|
||||
|
Loading…
Reference in New Issue
Block a user