#include #include #include "../block.h" #include "../eax.h" void test1(void) { uint8_t key[] = {0x23, 0x39, 0x52, 0xDE, 0xE4, 0xD5, 0xED, 0x5F, 0x9B, 0x9C, 0x6D, 0x6F, 0xF8, 0x0F, 0xF4, 0x78}; uint8_t nonce[] = {0x62, 0xEC, 0x67, 0xF9, 0xC3, 0xA4, 0xA4, 0x07, 0xFC, 0xB2, 0xA8, 0xC4, 0x90, 0x31, 0xA8, 0xB3}; aes128_eax_init(key, nonce); uint8_t *msg = NULL; uint8_t header[] = {0x6B, 0xFB, 0x91, 0x4F, 0xD0, 0x7E, 0xAE, 0x6B}; uint8_t cyphertext[] = {0xE0, 0x37, 0x83, 0x0E, 0x83, 0x89, 0xF2, 0x7B, 0x02, 0x5A, 0x2D, 0x65, 0x27, 0xE7, 0x9D, 0x01}; uint8_t ct_undertest[sizeof(cyphertext)]; aes128_eax(ct_undertest, header, sizeof(header), msg, 0, 16); printf("%s", block_eq(cyphertext, ct_undertest) ? "." : "F"); } void test2(void) { uint8_t key[] = {0x91, 0x94, 0x5D, 0x3F, 0x4D, 0xCB, 0xEE, 0x0B, 0xF4, 0x5E, 0xF5, 0x22, 0x55, 0xF0, 0x95, 0xA4}; uint8_t nonce[] = {0xBE, 0xCA, 0xF0, 0x43, 0xB0, 0xA2, 0x3D, 0x84, 0x31, 0x94, 0xBA, 0x97, 0x2C, 0x66, 0xDE, 0xBD}; aes128_eax_init(key, nonce); uint8_t msg[] = {0xF7, 0xFB}; uint8_t header[] = {0xFA, 0x3B, 0xFD, 0x48, 0x06, 0xEB, 0x53, 0xFA}; uint8_t ciphertext[] = {0x19, 0xDD, 0x5C, 0x4C, 0x93, 0x31, 0x04, 0x9D, 0x0B, 0xDA, 0xB0, 0x27, 0x74, 0x08, 0xF6, 0x79, 0x67, 0xE5}; uint8_t ct_undertest[sizeof(ciphertext)]; aes128_eax(ct_undertest, header, sizeof(header), msg, sizeof(msg), 16); /* printf("%s", block_eq(ciphertext, ct_undertest) ? "." : "F"); */ /* printf("REAL: "); */ /* for (int i = 0; i < sizeof(ciphertext); i++) { */ /* if (!(i % 4)) { */ /* printf(" "); */ /* } */ /* printf("%.2x", ciphertext[i]); */ /* } */ /* printf("\n"); */ /* for (int i = 0; i < sizeof(ct_undertest); i++) { */ /* if (!(i % 4)) { */ /* printf(" "); */ /* } */ /* printf("%.2x", ct_undertest[i]); */ /* } */ /* printf("\n"); */ } int main(void) { printf("Testing AES128-EAX: "); /* Test vectors from Appendix G of EAX paper */ //test1(); test2(); printf("\n"); }