mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-25 08:02:38 +01:00
unit: Add test for M1 parser
This commit is contained in:
parent
f7338c45c5
commit
2a4398847c
132
unit/test-wsc.c
132
unit/test-wsc.c
@ -404,6 +404,136 @@ static void wsc_test_uuid_from_addr(const void *data)
|
|||||||
assert(!memcmp(test->expected_uuid, uuid, 16));
|
assert(!memcmp(test->expected_uuid, uuid, 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const unsigned char eap_wsc_m1[] = {
|
||||||
|
0x01, 0x00, 0x01, 0x78, 0x02, 0x01, 0x01, 0x78, 0xfe, 0x00, 0x37, 0x2a,
|
||||||
|
0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x10, 0x4a, 0x00, 0x01, 0x10, 0x10,
|
||||||
|
0x22, 0x00, 0x01, 0x04, 0x10, 0x47, 0x00, 0x10, 0x79, 0x0c, 0x1f, 0x80,
|
||||||
|
0x4f, 0x2b, 0x52, 0xb7, 0xbe, 0x30, 0xc0, 0xe9, 0x72, 0x92, 0x08, 0x8d,
|
||||||
|
0x10, 0x20, 0x00, 0x06, 0xa0, 0xa8, 0xcd, 0x1c, 0x7e, 0xc9, 0x10, 0x1a,
|
||||||
|
0x00, 0x10, 0xab, 0x84, 0x41, 0x2f, 0xe7, 0xc3, 0xc9, 0xc9, 0xd7, 0xf4,
|
||||||
|
0xe8, 0xc1, 0x4f, 0x49, 0x2b, 0x79, 0x10, 0x32, 0x00, 0xc0, 0xb2, 0xfc,
|
||||||
|
0xd6, 0x4f, 0xf6, 0x71, 0x5a, 0x33, 0x84, 0x60, 0x4a, 0xe8, 0x2c, 0x1e,
|
||||||
|
0x55, 0x4a, 0xdb, 0xd5, 0x18, 0x17, 0x91, 0xa6, 0xf5, 0x70, 0xcd, 0x23,
|
||||||
|
0xd7, 0x12, 0x6e, 0x4c, 0xaf, 0x27, 0x9a, 0x4e, 0xf5, 0x37, 0xea, 0x8f,
|
||||||
|
0x03, 0xc9, 0x0e, 0x79, 0xc5, 0x8d, 0x37, 0xf8, 0xfb, 0x11, 0xa1, 0x39,
|
||||||
|
0x19, 0x9b, 0x5a, 0x3a, 0x66, 0x36, 0x6d, 0xfb, 0xae, 0xed, 0xfc, 0xa5,
|
||||||
|
0x90, 0xcb, 0xb3, 0xe1, 0xd5, 0x92, 0x2e, 0xe9, 0x99, 0xbd, 0x0b, 0x93,
|
||||||
|
0x82, 0x57, 0xe1, 0xbd, 0x70, 0x17, 0xa7, 0x78, 0x7a, 0x0a, 0xff, 0x42,
|
||||||
|
0x06, 0x95, 0x2c, 0x0b, 0x6c, 0x1a, 0x6b, 0x2f, 0x6b, 0xed, 0x42, 0xa5,
|
||||||
|
0x60, 0x8a, 0xb0, 0xb5, 0x79, 0x1b, 0xa9, 0xe6, 0x15, 0x17, 0xa3, 0x6c,
|
||||||
|
0xe9, 0x84, 0xb3, 0x77, 0x48, 0x9b, 0x7a, 0x4d, 0x04, 0xf6, 0xb8, 0x27,
|
||||||
|
0xe5, 0x0c, 0xcb, 0x76, 0xfc, 0x3c, 0x65, 0x49, 0xd7, 0x28, 0x06, 0x8d,
|
||||||
|
0x99, 0x18, 0x0f, 0xa7, 0x35, 0xb2, 0x9d, 0x15, 0x35, 0x51, 0xea, 0x83,
|
||||||
|
0xb6, 0x4d, 0x14, 0xb0, 0x21, 0xa4, 0x82, 0x1f, 0xb8, 0x73, 0x2b, 0x15,
|
||||||
|
0x1d, 0x48, 0x99, 0x9f, 0x32, 0x2c, 0xe1, 0xe1, 0xab, 0x66, 0x3f, 0xb4,
|
||||||
|
0x40, 0x79, 0xe8, 0x96, 0xe1, 0x9d, 0x54, 0x8b, 0xb6, 0x7f, 0x1a, 0x5b,
|
||||||
|
0x5f, 0x09, 0x9f, 0x40, 0xa7, 0x8b, 0xc8, 0xf6, 0x27, 0x80, 0x10, 0x04,
|
||||||
|
0x00, 0x02, 0x00, 0x23, 0x10, 0x10, 0x00, 0x02, 0x00, 0x0d, 0x10, 0x0d,
|
||||||
|
0x00, 0x01, 0x01, 0x10, 0x08, 0x00, 0x02, 0x21, 0x48, 0x10, 0x44, 0x00,
|
||||||
|
0x01, 0x01, 0x10, 0x21, 0x00, 0x01, 0x20, 0x10, 0x23, 0x00, 0x01, 0x20,
|
||||||
|
0x10, 0x24, 0x00, 0x01, 0x20, 0x10, 0x42, 0x00, 0x01, 0x20, 0x10, 0x54,
|
||||||
|
0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x11,
|
||||||
|
0x00, 0x01, 0x20, 0x10, 0x3c, 0x00, 0x01, 0x02, 0x10, 0x02, 0x00, 0x02,
|
||||||
|
0x00, 0x00, 0x10, 0x12, 0x00, 0x02, 0x00, 0x04, 0x10, 0x09, 0x00, 0x02,
|
||||||
|
0x00, 0x00, 0x10, 0x2d, 0x00, 0x04, 0x80, 0x00, 0x00, 0x00, 0x10, 0x49,
|
||||||
|
0x00, 0x06, 0x00, 0x37, 0x2a, 0x00, 0x01, 0x20,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct m1_data {
|
||||||
|
struct wsc_m1 expected;
|
||||||
|
const void *pdu;
|
||||||
|
unsigned int len;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct m1_data m1_data_1 = {
|
||||||
|
.pdu = eap_wsc_m1 + 18,
|
||||||
|
.len = sizeof(eap_wsc_m1) - 18,
|
||||||
|
.expected = {
|
||||||
|
.version2 = true,
|
||||||
|
.uuid_e = { 0x79, 0x0c, 0x1f, 0x80, 0x4f, 0x2b, 0x52, 0xb7,
|
||||||
|
0xbe, 0x30, 0xc0, 0xe9, 0x72, 0x92, 0x08, 0x8d },
|
||||||
|
.addr = { 0xa0, 0xa8, 0xcd, 0x1c, 0x7e, 0xc9 },
|
||||||
|
.enrollee_nonce = { 0xab, 0x84, 0x41, 0x2f, 0xe7, 0xc3, 0xc9,
|
||||||
|
0xc9, 0xd7, 0xf4, 0xe8, 0xc1, 0x4f,
|
||||||
|
0x49, 0x2b, 0x79 },
|
||||||
|
.public_key = { }, /* Tested elsewhere */
|
||||||
|
.auth_type_flags =
|
||||||
|
WSC_AUTHENTICATION_TYPE_WPA2_PERSONAL |
|
||||||
|
WSC_AUTHENTICATION_TYPE_WPA_PERSONAL |
|
||||||
|
WSC_AUTHENTICATION_TYPE_OPEN,
|
||||||
|
.encryption_type_flags = WSC_ENCRYPTION_TYPE_AES_TKIP |
|
||||||
|
WSC_ENCRYPTION_TYPE_NONE,
|
||||||
|
.connection_type_flags = WSC_CONNECTION_TYPE_ESS,
|
||||||
|
.config_methods = WSC_CONFIGURATION_METHOD_VIRTUAL_DISPLAY_PIN |
|
||||||
|
WSC_CONFIGURATION_METHOD_KEYPAD |
|
||||||
|
WSC_CONFIGURATION_METHOD_DISPLAY |
|
||||||
|
WSC_CONFIGURATION_METHOD_NFC_INTERFACE,
|
||||||
|
.config_state = WSC_CONFIG_STATE_NOT_CONFIGURED,
|
||||||
|
.manufacturer = " ",
|
||||||
|
.model_name = " ",
|
||||||
|
.model_number = " ",
|
||||||
|
.serial_number = " ",
|
||||||
|
.primary_device_type = {
|
||||||
|
.category = 0,
|
||||||
|
.oui = { 0x00, 0x00, 0x00 },
|
||||||
|
.oui_type = 0x00,
|
||||||
|
.subcategory = 0, },
|
||||||
|
.device_name = " ",
|
||||||
|
.rf_bands = WSC_RF_BAND_5_0_GHZ,
|
||||||
|
.association_state = WSC_ASSOCIATION_STATE_NOT_ASSOCIATED,
|
||||||
|
.device_password_id = WSC_DEVICE_PASSWORD_ID_PUSH_BUTTON,
|
||||||
|
.configuration_error = WSC_CONFIGURATION_ERROR_NO_ERROR,
|
||||||
|
.os_version = 0,
|
||||||
|
.request_to_enroll = false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static void wsc_test_parse_m1(const void *data)
|
||||||
|
{
|
||||||
|
const struct m1_data *test = data;
|
||||||
|
struct wsc_m1 m1;
|
||||||
|
const struct wsc_m1 *expected = &test->expected;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
r = wsc_parse_m1(test->pdu, test->len, &m1);
|
||||||
|
assert(r == 0);
|
||||||
|
|
||||||
|
assert(expected->version2 == m1.version2);
|
||||||
|
assert(!memcmp(expected->uuid_e, m1.uuid_e, 16));
|
||||||
|
assert(!memcmp(expected->addr, m1.addr, 6));
|
||||||
|
assert(!memcmp(expected->enrollee_nonce, m1.enrollee_nonce, 16));
|
||||||
|
|
||||||
|
/* Skip public_key testing */
|
||||||
|
|
||||||
|
assert(expected->auth_type_flags == m1.auth_type_flags);
|
||||||
|
assert(expected->encryption_type_flags == m1.encryption_type_flags);
|
||||||
|
assert(expected->connection_type_flags == m1.connection_type_flags);
|
||||||
|
assert(expected->config_methods == m1.config_methods);
|
||||||
|
assert(expected->config_state == m1.config_state);
|
||||||
|
|
||||||
|
assert(!strcmp(expected->manufacturer, m1.manufacturer));
|
||||||
|
assert(!strcmp(expected->model_name, m1.model_name));
|
||||||
|
assert(!strcmp(expected->model_number, m1.model_number));
|
||||||
|
assert(!strcmp(expected->serial_number, m1.serial_number));
|
||||||
|
|
||||||
|
assert(expected->primary_device_type.category ==
|
||||||
|
m1.primary_device_type.category);
|
||||||
|
assert(!memcmp(expected->primary_device_type.oui,
|
||||||
|
m1.primary_device_type.oui, 3));
|
||||||
|
assert(expected->primary_device_type.oui_type ==
|
||||||
|
m1.primary_device_type.oui_type);
|
||||||
|
assert(expected->primary_device_type.subcategory ==
|
||||||
|
m1.primary_device_type.subcategory);
|
||||||
|
|
||||||
|
assert(!strcmp(expected->device_name, m1.device_name));
|
||||||
|
assert(expected->rf_bands == m1.rf_bands);
|
||||||
|
assert(expected->association_state == m1.association_state);
|
||||||
|
assert(expected->device_password_id == m1.device_password_id);
|
||||||
|
assert(expected->configuration_error == m1.configuration_error);
|
||||||
|
assert(expected->os_version == m1.os_version);
|
||||||
|
assert(expected->request_to_enroll == m1.request_to_enroll);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
l_test_init(&argc, &argv);
|
l_test_init(&argc, &argv);
|
||||||
@ -425,5 +555,7 @@ int main(int argc, char *argv[])
|
|||||||
l_test_add("/wsc/gen_uuid/1", wsc_test_uuid_from_addr,
|
l_test_add("/wsc/gen_uuid/1", wsc_test_uuid_from_addr,
|
||||||
&uuid_from_addr_data_1);
|
&uuid_from_addr_data_1);
|
||||||
|
|
||||||
|
l_test_add("/wsc/parse/m1 1", wsc_test_parse_m1, &m1_data_1);
|
||||||
|
|
||||||
return l_test_run();
|
return l_test_run();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user