aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2015-01-05 14:15:23 (GMT)
committerJouni Malinen <j@w1.fi>2015-01-05 14:15:23 (GMT)
commit6c33962dd1932c0ecef42b8a0ab4c0cde8c4cb4a (patch)
treed8fbb7b9e4958473f0c473c934438354b547c05d /src
parent304d40e904612726506570e6ab12a5381e130b8b (diff)
downloadhostap-6c33962dd1932c0ecef42b8a0ab4c0cde8c4cb4a.zip
hostap-6c33962dd1932c0ecef42b8a0ab4c0cde8c4cb4a.tar.gz
hostap-6c33962dd1932c0ecef42b8a0ab4c0cde8c4cb4a.tar.bz2
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>
Diffstat (limited to 'src')
-rw-r--r--src/crypto/crypto_module_tests.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/crypto/crypto_module_tests.c b/src/crypto/crypto_module_tests.c
index baac7fc..0c6a171 100644
--- a/src/crypto/crypto_module_tests.c
+++ b/src/crypto/crypto_module_tests.c
@@ -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;