From 6bb31ac5b453d9cad0ddf8873fcfe4099d0dd1f8 Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Mon, 18 May 2015 13:31:42 +0200 Subject: [PATCH] unit: WPA+TKIP EAPOL-Key frame tests. --- unit/test-eapol.c | 283 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 283 insertions(+) diff --git a/unit/test-eapol.c b/unit/test-eapol.c index f5f5394f..5fb7b56f 100644 --- a/unit/test-eapol.c +++ b/unit/test-eapol.c @@ -32,6 +32,7 @@ #include "src/sha1.h" #include "src/eapol.h" #include "src/crypto.h" +#include "src/ie.h" struct eapol_key_data { const unsigned char *frame; @@ -596,6 +597,276 @@ static struct eapol_key_data eapol_key_test_12 = { .key_data_len = 0, }; +/* WPA frame, 1 of 4. For parameters see eapol_wpa_handshake_test */ +static const unsigned char eapol_key_data_13[] = { + 0x02, 0x03, 0x00, 0x5f, 0xfe, 0x00, 0x89, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x66, 0xbe, 0x99, 0x48, 0x44, 0xe0, 0xf5, + 0x40, 0x78, 0x13, 0x91, 0x37, 0x6f, 0x47, 0x99, 0x56, 0xa3, 0xec, 0x36, + 0x32, 0xe4, 0x12, 0x13, 0x64, 0xec, 0x7e, 0x75, 0x37, 0xef, 0xf6, 0x2a, + 0xc5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00 +}; + +static struct eapol_key_data eapol_key_test_13 = { + .frame = eapol_key_data_13, + .frame_len = sizeof(eapol_key_data_13), + .protocol_version = EAPOL_PROTOCOL_VERSION_2004, + .packet_len = 95, + .descriptor_type = EAPOL_DESCRIPTOR_TYPE_WPA, + .key_descriptor_version = EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_MD5_ARC4, + .key_type = true, + .wpa_key_id = 0, + .install = false, + .key_ack = true, + .key_mic = false, + .secure = false, + .error = false, + .request = false, + .encrypted_key_data = false, + .smk_message = false, + .key_length = 32, + .key_replay_counter = 1, + .key_nonce = { 0x66, 0xbe, 0x99, 0x48, 0x44, 0xe0, 0xf5, 0x40, + 0x78, 0x13, 0x91, 0x37, 0x6f, 0x47, 0x99, 0x56, + 0xa3, 0xec, 0x36, 0x32, 0xe4, 0x12, 0x13, 0x64, + 0xec, 0x7e, 0x75, 0x37, 0xef, 0xf6, 0x2a, 0xc5 }, + .eapol_key_iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + .key_rsc = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + .key_mic_data = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + .key_data_len = 0, +}; + +/* WPA frame, 2 of 4. For parameters see eapol_wpa_handshake_test */ +static const unsigned char eapol_key_data_14[] = { + 0x02, 0x03, 0x00, 0x77, 0xfe, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x3b, 0x7f, 0x85, 0x0a, 0x03, 0x9c, 0xa4, + 0x71, 0x42, 0x9d, 0x0f, 0xc3, 0xce, 0x9f, 0xff, 0x48, 0xdb, 0x89, 0x2e, + 0xf7, 0xa7, 0xff, 0x80, 0xf6, 0x22, 0xc4, 0x6e, 0x32, 0x97, 0x05, 0xc3, + 0x7d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe6, 0x82, + 0x94, 0xdc, 0x88, 0x07, 0x18, 0xa7, 0xd3, 0x08, 0xfa, 0xb4, 0x39, 0x95, + 0x36, 0x00, 0x18, 0xdd, 0x16, 0x00, 0x50, 0xf2, 0x01, 0x01, 0x00, 0x00, + 0x50, 0xf2, 0x02, 0x01, 0x00, 0x00, 0x50, 0xf2, 0x02, 0x01, 0x00, 0x00, + 0x50, 0xf2, 0x02 +}; + +static struct eapol_key_data eapol_key_test_14 = { + .frame = eapol_key_data_14, + .frame_len = sizeof(eapol_key_data_14), + .protocol_version = EAPOL_PROTOCOL_VERSION_2004, + .packet_len = 119, + .descriptor_type = EAPOL_DESCRIPTOR_TYPE_WPA, + .key_descriptor_version = EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_MD5_ARC4, + .key_type = true, + .wpa_key_id = 0, + .install = false, + .key_ack = false, + .key_mic = true, + .secure = false, + .error = false, + .request = false, + .encrypted_key_data = false, + .smk_message = false, + .key_length = 0, + .key_replay_counter = 1, + .key_nonce = { 0x3b, 0x7f, 0x85, 0x0a, 0x03, 0x9c, 0xa4, 0x71, + 0x42, 0x9d, 0x0f, 0xc3, 0xce, 0x9f, 0xff, 0x48, + 0xdb, 0x89, 0x2e, 0xf7, 0xa7, 0xff, 0x80, 0xf6, + 0x22, 0xc4, 0x6e, 0x32, 0x97, 0x05, 0xc3, 0x7d }, + .eapol_key_iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + .key_rsc = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + .key_mic_data = { 0x01, 0xe6, 0x82, 0x94, 0xdc, 0x88, 0x07, 0x18, + 0xa7, 0xd3, 0x08, 0xfa, 0xb4, 0x39, 0x95, 0x36 }, + .key_data_len = 24, +}; + +/* WPA frame, 3 of 4. For parameters see eapol_wpa_handshake_test */ +static const unsigned char eapol_key_data_15[] = { + 0x02, 0x03, 0x00, 0x77, 0xfe, 0x01, 0xc9, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x66, 0xbe, 0x99, 0x48, 0x44, 0xe0, 0xf5, + 0x40, 0x78, 0x13, 0x91, 0x37, 0x6f, 0x47, 0x99, 0x56, 0xa3, 0xec, 0x36, + 0x32, 0xe4, 0x12, 0x13, 0x64, 0xec, 0x7e, 0x75, 0x37, 0xef, 0xf6, 0x2a, + 0xc5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0xc2, 0x97, + 0xf6, 0xc1, 0x93, 0x72, 0x19, 0x3e, 0x40, 0xd9, 0xc8, 0xb9, 0xaa, 0x7c, + 0x94, 0x00, 0x18, 0xdd, 0x16, 0x00, 0x50, 0xf2, 0x01, 0x01, 0x00, 0x00, + 0x50, 0xf2, 0x02, 0x01, 0x00, 0x00, 0x50, 0xf2, 0x02, 0x01, 0x00, 0x00, + 0x50, 0xf2, 0x02 +}; + +static struct eapol_key_data eapol_key_test_15 = { + .frame = eapol_key_data_15, + .frame_len = sizeof(eapol_key_data_15), + .protocol_version = EAPOL_PROTOCOL_VERSION_2004, + .packet_len = 119, + .descriptor_type = EAPOL_DESCRIPTOR_TYPE_WPA, + .key_descriptor_version = EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_MD5_ARC4, + .key_type = true, + .wpa_key_id = 0, + .install = true, + .key_ack = true, + .key_mic = true, + .secure = false, + .error = false, + .request = false, + .encrypted_key_data = false, + .smk_message = false, + .key_length = 32, + .key_replay_counter = 2, + .key_nonce = { 0x66, 0xbe, 0x99, 0x48, 0x44, 0xe0, 0xf5, 0x40, + 0x78, 0x13, 0x91, 0x37, 0x6f, 0x47, 0x99, 0x56, + 0xa3, 0xec, 0x36, 0x32, 0xe4, 0x12, 0x13, 0x64, + 0xec, 0x7e, 0x75, 0x37, 0xef, 0xf6, 0x2a, 0xc5 }, + .eapol_key_iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + .key_rsc = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + .key_mic_data = { 0x96, 0xc2, 0x97, 0xf6, 0xc1, 0x93, 0x72, 0x19, + 0x3e, 0x40, 0xd9, 0xc8, 0xb9, 0xaa, 0x7c, 0x94 }, + .key_data_len = 24, +}; + +/* WPA frame, 4 of 4. For parameters see eapol_wpa_handshake_test */ +static const unsigned char eapol_key_data_16[] = { + 0x02, 0x03, 0x00, 0x5f, 0xfe, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x65, 0xf3, + 0x33, 0xa3, 0x5b, 0x4f, 0xda, 0xc3, 0x66, 0xb3, 0x1a, 0x43, 0xb5, 0x31, + 0x95, 0x00, 0x00 +}; + +static struct eapol_key_data eapol_key_test_16 = { + .frame = eapol_key_data_16, + .frame_len = sizeof(eapol_key_data_16), + .protocol_version = EAPOL_PROTOCOL_VERSION_2004, + .packet_len = 95, + .descriptor_type = EAPOL_DESCRIPTOR_TYPE_WPA, + .key_descriptor_version = EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_MD5_ARC4, + .key_type = true, + .wpa_key_id = 0, + .install = false, + .key_ack = false, + .key_mic = true, + .secure = false, + .error = false, + .request = false, + .encrypted_key_data = false, + .smk_message = false, + .key_length = 0, + .key_replay_counter = 2, + .key_nonce = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + .eapol_key_iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + .key_rsc = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + .key_mic_data = { 0xe0, 0x65, 0xf3, 0x33, 0xa3, 0x5b, 0x4f, 0xda, + 0xc3, 0x66, 0xb3, 0x1a, 0x43, 0xb5, 0x31, 0x95 }, + .key_data_len = 0, +}; + +/* WPA frame, 1 of 2. For parameters see eapol_wpa_handshake_test */ +static const unsigned char eapol_key_data_17[] = { + 0x02, 0x03, 0x00, 0x7f, 0xfe, 0x03, 0xa1, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0xc3, 0xa7, 0xe0, 0x14, 0x10, 0xea, 0xe6, + 0xe5, 0xfb, 0x79, 0xfc, 0xf5, 0xe5, 0x55, 0x08, 0x44, 0xd9, 0xbd, 0xd2, + 0x80, 0x5d, 0x81, 0x1c, 0x0a, 0x9c, 0x48, 0x0a, 0xe9, 0x86, 0xca, 0x87, + 0xa1, 0xd9, 0xbd, 0xd2, 0x80, 0x5d, 0x81, 0x1c, 0x0a, 0x9c, 0x48, 0x0a, + 0xe9, 0x86, 0xca, 0x87, 0xa2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb, 0x78, 0xf8, + 0xf3, 0xff, 0x1f, 0xec, 0x97, 0x98, 0x67, 0xe8, 0x25, 0x0a, 0xf2, 0x9d, + 0x61, 0x00, 0x20, 0x9f, 0x46, 0x72, 0x04, 0x83, 0xd7, 0xf6, 0xa3, 0x5b, + 0xbd, 0xa6, 0x80, 0x32, 0xe0, 0x44, 0x92, 0x5e, 0x90, 0xe5, 0x7f, 0xd8, + 0x5d, 0xfc, 0xd0, 0xdb, 0xcd, 0x7f, 0xf7, 0x48, 0xdf, 0x33, 0x75 +}; + +static struct eapol_key_data eapol_key_test_17 = { + .frame = eapol_key_data_17, + .frame_len = sizeof(eapol_key_data_17), + .protocol_version = EAPOL_PROTOCOL_VERSION_2004, + .packet_len = 127, + .descriptor_type = EAPOL_DESCRIPTOR_TYPE_WPA, + .key_descriptor_version = EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_MD5_ARC4, + .key_type = false, + .wpa_key_id = 2, + .install = false, + .key_ack = true, + .key_mic = true, + .secure = true, + .error = false, + .request = false, + .encrypted_key_data = false, + .smk_message = false, + .key_length = 32, + .key_replay_counter = 3, + .key_nonce = { 0xc3, 0xa7, 0xe0, 0x14, 0x10, 0xea, 0xe6, 0xe5, + 0xfb, 0x79, 0xfc, 0xf5, 0xe5, 0x55, 0x08, 0x44, + 0xd9, 0xbd, 0xd2, 0x80, 0x5d, 0x81, 0x1c, 0x0a, + 0x9c, 0x48, 0x0a, 0xe9, 0x86, 0xca, 0x87, 0xa1 }, + .eapol_key_iv = { 0xd9, 0xbd, 0xd2, 0x80, 0x5d, 0x81, 0x1c, 0x0a, + 0x9c, 0x48, 0x0a, 0xe9, 0x86, 0xca, 0x87, 0xa2 }, + .key_rsc = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + .key_mic_data = { 0xfb, 0x78, 0xf8, 0xf3, 0xff, 0x1f, 0xec, 0x97, + 0x98, 0x67, 0xe8, 0x25, 0x0a, 0xf2, 0x9d, 0x61 }, + .key_data_len = 32, +}; + +/* WPA frame, 2 of 2. For parameters see eapol_wpa_handshake_test */ +static const unsigned char eapol_key_data_18[] = { + 0x02, 0x03, 0x00, 0x5f, 0xfe, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x5e, 0x72, + 0xe6, 0x84, 0xc4, 0xd0, 0xa5, 0x56, 0x9e, 0x2d, 0x0c, 0x75, 0x2c, 0x45, + 0x2a, 0x00, 0x00 +}; + +static struct eapol_key_data eapol_key_test_18 = { + .frame = eapol_key_data_18, + .frame_len = sizeof(eapol_key_data_18), + .protocol_version = EAPOL_PROTOCOL_VERSION_2004, + .packet_len = 95, + .descriptor_type = EAPOL_DESCRIPTOR_TYPE_WPA, + .key_descriptor_version = EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_MD5_ARC4, + .key_type = false, + .wpa_key_id = 0, + .install = false, + .key_ack = false, + .key_mic = true, + .secure = true, + .error = false, + .request = false, + .encrypted_key_data = false, + .smk_message = false, + .key_length = 0, + .key_replay_counter = 3, + .key_nonce = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + .eapol_key_iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + .key_rsc = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + .key_mic_data = { 0x36, 0x5e, 0x72, 0xe6, 0x84, 0xc4, 0xd0, 0xa5, + 0x56, 0x9e, 0x2d, 0x0c, 0x75, 0x2c, 0x45, 0x2a }, + .key_data_len = 0, +}; + static void eapol_key_test(const void *data) { const struct eapol_key_data *test = data; @@ -1198,6 +1469,18 @@ int main(int argc, char *argv[]) eapol_key_test, &eapol_key_test_11); l_test_add("/EAPoL Key/Key Frame 12", eapol_key_test, &eapol_key_test_12); + l_test_add("/EAPoL Key/Key Frame 13", + eapol_key_test, &eapol_key_test_13); + l_test_add("/EAPoL Key/Key Frame 14", + eapol_key_test, &eapol_key_test_14); + l_test_add("/EAPoL Key/Key Frame 15", + eapol_key_test, &eapol_key_test_15); + l_test_add("/EAPoL Key/Key Frame 16", + eapol_key_test, &eapol_key_test_16); + l_test_add("/EAPoL Key/Key Frame 17", + eapol_key_test, &eapol_key_test_17); + l_test_add("/EAPoL Key/Key Frame 18", + eapol_key_test, &eapol_key_test_18); l_test_add("/EAPoL Key/MIC Test 1", eapol_key_mic_test, &eapol_key_mic_test_1);