2 #define TEST_NAME "auth"
5 /* "Test Case 2" from RFC 4231 */
6 static unsigned char key
[32] = "Jefe";
7 static unsigned char c
[] = "what do ya want for nothing?";
10 static unsigned char key2
[] = "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.";
12 static unsigned char a
[crypto_auth_BYTES
];
13 static unsigned char a2
[crypto_auth_hmacsha512_BYTES
];
17 crypto_auth_hmacsha512_state st
;
20 assert(crypto_auth_hmacsha512_statebytes() ==
21 sizeof(crypto_auth_hmacsha512_state
));
22 crypto_auth(a
, c
, sizeof c
- 1U, key
);
23 for (i
= 0; i
< sizeof a
; ++i
) {
24 printf(",0x%02x", (unsigned int)a
[i
]);
30 crypto_auth_hmacsha512_init(&st
, key
, sizeof key
);
31 crypto_auth_hmacsha512_update(&st
, c
, 1U);
32 crypto_auth_hmacsha512_update(&st
, c
, sizeof c
- 2U);
33 crypto_auth_hmacsha512_final(&st
, a2
);
34 for (i
= 0; i
< sizeof a2
; ++i
) {
35 printf(",0x%02x", (unsigned int)a2
[i
]);
41 crypto_auth_hmacsha512_init(&st
, key2
, sizeof key2
);
42 crypto_auth_hmacsha512_update(&st
, c
, 1U);
43 crypto_auth_hmacsha512_update(&st
, c
, sizeof c
- 2U);
44 crypto_auth_hmacsha512_final(&st
, a2
);
45 for (i
= 0; i
< sizeof a2
; ++i
) {
46 printf(",0x%02x", (unsigned int)a2
[i
]);
51 assert(crypto_auth_bytes() > 0U);
52 assert(crypto_auth_keybytes() > 0U);
53 assert(strcmp(crypto_auth_primitive(), "hmacsha512256") == 0);
54 assert(crypto_auth_hmacsha256_bytes() > 0U);
55 assert(crypto_auth_hmacsha256_keybytes() > 0U);
56 assert(crypto_auth_hmacsha512_bytes() > 0U);
57 assert(crypto_auth_hmacsha512_keybytes() > 0U);
58 assert(crypto_auth_hmacsha512256_bytes() == crypto_auth_bytes());
59 assert(crypto_auth_hmacsha512256_keybytes() == crypto_auth_keybytes());
60 assert(crypto_auth_hmacsha512256_statebytes() >=
61 crypto_auth_hmacsha512256_keybytes());
62 assert(crypto_auth_hmacsha256_statebytes() ==
63 sizeof(crypto_auth_hmacsha256_state
));
64 assert(crypto_auth_hmacsha512_statebytes() ==
65 sizeof(crypto_auth_hmacsha512_state
));