unit/test-eapol: igtk test with mfp enabled

This is the first version of the test
This commit is contained in:
Rahul Rahul 2016-12-02 09:18:52 -06:00 committed by Denis Kenzior
parent c78d6fda26
commit 71932acd2d
1 changed files with 259 additions and 0 deletions

View File

@ -1373,6 +1373,190 @@ static struct eapol_key_data eapol_key_test_28 = {
.key_data_len = 0,
};
/* WPA frame, 1 of 4. For parameters see eapol_sm_test_igtk */
static const unsigned char eapol_key_data_29[] = {
0x02, 0x03, 0x00, 0x5f, 0x02, 0x00, 0x89, 0x00, 0x20, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x30, 0x37, 0x86,
0x8d, 0x6c, 0xd2, 0x38, 0xb2, 0xfe, 0xb4, 0x5b, 0xd3, 0xc6,
0x4b, 0xa1, 0x3e, 0x26, 0xd9, 0xa4, 0x89, 0x8b, 0x43, 0xf6,
0x66, 0x51, 0x26, 0x99, 0x5e, 0x62, 0xce, 0x8e, 0x9d, 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_29 = {
.frame = eapol_key_data_29,
.frame_len = sizeof(eapol_key_data_29),
.protocol_version = EAPOL_PROTOCOL_VERSION_2004,
.packet_len = 95,
.descriptor_type = EAPOL_DESCRIPTOR_TYPE_80211,
.key_descriptor_version = EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_MD5_ARC4,
.key_type = true,
.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 = { 0x30, 0x37, 0x86, 0x8d, 0x6c, 0xd2, 0x38, 0xb2, 0xfe,
0xb4, 0x5b, 0xd3, 0xc6, 0x4b, 0xa1, 0x3e, 0x26, 0xd9,
0xa4, 0x89, 0x8b, 0x43, 0xf6, 0x66, 0x51, 0x26, 0x99,
0x5e, 0x62, 0xce, 0x8e, 0x9d},
.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_sm_test_igtk */
static const unsigned char eapol_key_data_30[] = {
0x01, 0x03, 0x00, 0x7b, 0x02, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x3e, 0x5e, 0xb7, 0x47, 0x91, 0xf4, 0x2a,
0x39, 0x3a, 0x6a, 0xbc, 0xeb, 0x9c, 0x25, 0x27, 0x0f, 0x61, 0xb4, 0x24,
0x8c, 0xf2, 0x97, 0xdf, 0x22, 0xef, 0x67, 0x15, 0x87, 0xad, 0x22, 0xc3,
0xd8, 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, 0x92, 0x76, 0xec,
0x87, 0x1e, 0x42, 0x7a, 0x66, 0x3f, 0x45, 0xb2, 0x7f, 0x7c, 0xd7, 0xe3,
0xb9, 0x00, 0x1c, 0x30, 0x1a, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x02, 0x01,
0x00, 0x00, 0x0f, 0xac, 0x02, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x02, 0x80,
0x00, 0x00, 0x00, 0x00, 0x0f, 0xac, 0x06,
};
static struct eapol_key_data eapol_key_test_30 = {
.frame = eapol_key_data_30,
.frame_len = sizeof(eapol_key_data_30),
.protocol_version = EAPOL_PROTOCOL_VERSION_2001,
.packet_len = 123,
.descriptor_type = EAPOL_DESCRIPTOR_TYPE_80211,
.key_descriptor_version = EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_MD5_ARC4,
.key_type = true,
.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 = { 0x3e, 0x5e, 0xb7, 0x47, 0x91, 0xf4, 0x2a, 0x39, 0x3a,
0x6a, 0xbc, 0xeb, 0x9c, 0x25, 0x27, 0x0f, 0x61, 0xb4,
0x24, 0x8c, 0xf2, 0x97, 0xdf, 0x22, 0xef, 0x67, 0x15,
0x87, 0xad, 0x22, 0xc3, 0xd8 },
.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 = { 0x92, 0x76, 0xec, 0x87, 0x1e, 0x42, 0x7a, 0x66, 0x3f,
0x45, 0xb2, 0x7f, 0x7c, 0xd7, 0xe3, 0xb9 },
.key_data_len = 28,
};
/* WPA frame, 3 of 4. For parameters see eapol_sm_test_igtk */
static const unsigned char eapol_key_data_31[] = {
0x02, 0x03, 0x00, 0xd3, 0x02, 0x13, 0xc9, 0x00, 0x20, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02, 0x30, 0x37, 0x86, 0x8d, 0x6c,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0xc4, 0x36, 0xea, 0x2f, 0x1d, 0xda, 0x31, 0xa1,
};
static struct eapol_key_data eapol_key_test_31 = {
.frame = eapol_key_data_31,
.frame_len = sizeof(eapol_key_data_31),
.protocol_version = EAPOL_PROTOCOL_VERSION_2004,
.packet_len = 211,
.descriptor_type = EAPOL_DESCRIPTOR_TYPE_80211,
.key_descriptor_version = EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_MD5_ARC4,
.key_type = true,
.install = true,
.key_ack = true,
.key_mic = true,
.secure = true,
.error = false,
.request = false,
.encrypted_key_data = true,
.smk_message = false,
.key_length = 32,
.key_replay_counter = 2,
.key_nonce = { 0x30, 0x37, 0x86, 0x8d, 0x6c, 0xd2, 0x38, 0xb2, 0xfe,
0xb4, 0x5b, 0xd3, 0xc6, 0x4b, 0xa1, 0x3e, 0x26, 0xd9,
0xa4, 0x89, 0x8b, 0x43, 0xf6, 0x66, 0x51, 0x26, 0x99,
0x5e, 0x62, 0xce, 0x8e, 0x9d },
.eapol_key_iv = { 0x92, 0xcf, 0x64, 0xa6, 0xf5, 0xea, 0x95, 0xf7, 0xf9,
0xeb, 0x6a, 0x54, 0x8a, 0x85, 0x6c, 0x1c},
.key_rsc = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
.key_mic_data = { 0x1f, 0x80, 0xb3, 0x14, 0x1f, 0xfa, 0x11, 0x47, 0xcd,
0x6d, 0xd0, 0x20, 0x7e, 0x9e, 0x68, 0x65 },
.key_data_len = 116,
};
/* WPA frame, 4 of 4. For parameters see eapol_sm_test_igtk */
static const unsigned char eapol_key_data_32[] = {
0x01, 0x03, 0x00, 0x5f, 0x02, 0x03, 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, 0x66, 0x2c, 0x07,
0x9b, 0x73, 0xb6, 0x94, 0xb9, 0x4b, 0x7f, 0xa1, 0x99, 0x2f, 0x7a, 0x92,
0xe2, 0x00, 0x00
};
static struct eapol_key_data eapol_key_test_32 = {
.frame = eapol_key_data_32,
.frame_len = sizeof(eapol_key_data_32),
.protocol_version = EAPOL_PROTOCOL_VERSION_2001,
.packet_len = 95,
.descriptor_type = EAPOL_DESCRIPTOR_TYPE_80211,
.key_descriptor_version = EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_MD5_ARC4,
.key_type = true,
.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 = 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 = { 0x66, 0x2c, 0x07, 0x9b, 0x73, 0xb6, 0x94, 0xb9,
0x4b, 0x7f, 0xa1, 0x99, 0x2f, 0x7a, 0x92, 0xe2 },
.key_data_len = 0,
};
static void eapol_key_test(const void *data)
{
const struct eapol_key_data *test = data;
@ -1971,6 +2155,70 @@ static void eapol_sm_test_ptk(const void *data)
eapol_exit();
}
static void eapol_sm_test_igtk(const void *data)
{
const unsigned char psk[] = {
0xbf, 0x9a, 0xa3, 0x15, 0x53, 0x00, 0x12, 0x5e,
0x7a, 0x5e, 0xbb, 0x2a, 0x54, 0x9f, 0x8c, 0xd4,
0xed, 0xab, 0x8e, 0xe1, 0x2e, 0x94, 0xbf, 0xc2,
0x4b, 0x33, 0x57, 0xad, 0x04, 0x96, 0x65, 0xd9 };
const unsigned char ap_rsne[] = {
0x30, 0x1a, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x02, 0x01, 0x00,
0x00, 0x0f, 0xac, 0x02, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x02,
0x80, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xac, 0x06 };
static uint8_t ap_address[] = { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 };
static uint8_t sta_address[] = { 0x02, 0x00, 0x00, 0x00, 0x01, 0x00 };
bool r;
struct handshake_state *hs;
struct eapol_sm *sm;
eapol_init();
snonce = eapol_key_test_30.key_nonce;
__handshake_set_get_nonce_func(test_nonce);
aa = ap_address;
spa = sta_address;
verify_step2_called = false;
expected_step2_frame = eapol_key_data_30;
expected_step2_frame_size = sizeof(eapol_key_data_30);
verify_step4_called = false;
expected_step4_frame = eapol_key_data_32;
expected_step4_frame_size = sizeof(eapol_key_data_32);
hs = handshake_state_new(1);
sm = eapol_sm_new(hs);
eapol_register(sm);
/* key_data_29 uses 2004 while key_data_30 uses 2001, so force 2001 */
eapol_sm_set_protocol_version(sm, EAPOL_PROTOCOL_VERSION_2001);
handshake_state_set_pmk(hs, psk);
handshake_state_set_authenticator_address(hs, aa);
handshake_state_set_supplicant_address(hs, spa);
r = handshake_state_set_own_rsn(hs,
eapol_key_data_30 + sizeof(struct eapol_key));
assert(r);
handshake_state_set_ap_rsn(hs, ap_rsne);
eapol_start(sm);
__eapol_set_tx_packet_func(verify_step2);
__eapol_rx_packet(1, aa, eapol_key_data_29,
sizeof(eapol_key_data_29));
assert(verify_step2_called);
__eapol_set_tx_packet_func(verify_step4);
__eapol_rx_packet(1, aa, eapol_key_data_31,
sizeof(eapol_key_data_31));
assert(verify_step4_called);
eapol_sm_free(sm);
handshake_state_free(hs);
eapol_exit();
}
static void eapol_sm_test_wpa2_ptk_gtk(const void *data)
{
const unsigned char psk[] = {
@ -2914,6 +3162,14 @@ int main(int argc, char *argv[])
eapol_key_test, &eapol_key_test_27);
l_test_add("/EAPoL Key/Key Frame 28",
eapol_key_test, &eapol_key_test_28);
l_test_add("/EAPoL Key/Key Frame 29",
eapol_key_test, &eapol_key_test_29);
l_test_add("/EAPoL Key/Key Frame 30",
eapol_key_test, &eapol_key_test_30);
l_test_add("/EAPoL Key/Key Frame 31",
eapol_key_test, &eapol_key_test_31);
l_test_add("/EAPoL Key/Key Frame 32",
eapol_key_test, &eapol_key_test_32);
l_test_add("/EAPoL Key/MIC Test 1",
eapol_key_mic_test, &eapol_key_mic_test_1);
@ -2934,6 +3190,9 @@ int main(int argc, char *argv[])
l_test_add("EAPoL/WPA2 PTK State Machine", &eapol_sm_test_ptk, NULL);
l_test_add("EAPoL IGTK & 4-Way Handshake",
&eapol_sm_test_igtk, NULL);
l_test_add("EAPoL/WPA2 PTK & GTK State Machine",
&eapol_sm_test_wpa2_ptk_gtk, NULL);