tests: Additional OMAC1-AES module test coverage

This verifies couple of corner cases with short vector entries in the
OMAC1-AES implementation.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2015-01-05 16:15:23 +02:00
parent 304d40e904
commit 6c33962dd1

View file

@ -208,7 +208,14 @@ static struct omac1_test_vector omac1_test_vectors[] =
static int test_omac1_vector(struct omac1_test_vector *tv, unsigned int i)
{
u8 result[24];
u8 key[] = {
0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
};
u8 msg[] = { 0x12, 0x34, 0x56 };
u8 result[24], result2[24];
const u8 *addr[3];
size_t len[3];
if (omac1_aes_128(tv->k, tv->msg, tv->msg_len, result) ||
os_memcmp(result, tv->tag, 16) != 0) {
@ -217,8 +224,6 @@ static int test_omac1_vector(struct omac1_test_vector *tv, unsigned int i)
}
if (tv->msg_len > 1) {
const u8 *addr[2];
size_t len[2];
addr[0] = tv->msg;
len[0] = 1;
@ -232,6 +237,34 @@ static int test_omac1_vector(struct omac1_test_vector *tv, unsigned int i)
i);
return 1;
}
addr[0] = tv->msg;
len[0] = tv->msg_len - 2;
addr[1] = tv->msg + tv->msg_len - 2;
len[1] = 1;
addr[2] = tv->msg + tv->msg_len - 1;
len[2] = 1;
if (omac1_aes_128_vector(tv->k, 3, addr, len, result) ||
os_memcmp(result, tv->tag, 16) != 0) {
wpa_printf(MSG_ERROR,
"OMAC1-AES-128(vector2) test vector %u failed",
i);
return 1;
}
}
addr[0] = &msg[0];
len[0] = 1;
addr[1] = &msg[1];
len[1] = 1;
addr[2] = &msg[2];
len[2] = 1;
if (omac1_aes_128(key, msg, sizeof(msg), result) ||
omac1_aes_128_vector(key, 3, addr, len, result2) ||
os_memcmp(result, result2, 16) != 0) {
wpa_printf(MSG_ERROR, "OMAC1-AES-128 short test mismatch");
return 1;
}
return 0;