mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-20 10:52:33 +01:00
unit: Add test fo wsc_parse_m7
This commit is contained in:
parent
a113cba4f2
commit
82b007f7b5
@ -1551,6 +1551,64 @@ static void wsc_test_build_m6_encrypted_settings(const void *data)
|
|||||||
l_free(out);
|
l_free(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const unsigned char eap_wsc_m7[] = {
|
||||||
|
0x01, 0x00, 0x00, 0x86, 0x02, 0xaa, 0x00, 0x86, 0xfe, 0x00, 0x37, 0x2a,
|
||||||
|
0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x10, 0x4a, 0x00, 0x01, 0x10, 0x10,
|
||||||
|
0x22, 0x00, 0x01, 0x0b, 0x10, 0x39, 0x00, 0x10, 0x67, 0xa5, 0x53, 0x61,
|
||||||
|
0xee, 0x72, 0xc2, 0x21, 0x48, 0x78, 0xc5, 0x70, 0x89, 0x9f, 0xf2, 0xa0,
|
||||||
|
0x10, 0x18, 0x00, 0x40, 0x4e, 0x3a, 0x4c, 0xf0, 0x88, 0x17, 0x69, 0x89,
|
||||||
|
0xe1, 0x48, 0xd4, 0xc1, 0x0b, 0x96, 0xe8, 0xfd, 0x1e, 0x9b, 0xf4, 0xc0,
|
||||||
|
0x74, 0xcc, 0xa2, 0xeb, 0x87, 0x58, 0xc9, 0x42, 0xd1, 0xf3, 0x89, 0xe2,
|
||||||
|
0x27, 0x13, 0xfe, 0x40, 0x10, 0x45, 0x51, 0xfd, 0xc2, 0x1f, 0xe6, 0x60,
|
||||||
|
0x84, 0xc2, 0x8f, 0x9d, 0x43, 0xbc, 0x03, 0xf3, 0x0a, 0x64, 0x8f, 0x18,
|
||||||
|
0xe9, 0x96, 0x0f, 0x9e, 0xeb, 0x52, 0x73, 0x70, 0x10, 0x49, 0x00, 0x06,
|
||||||
|
0x00, 0x37, 0x2a, 0x00, 0x01, 0x20, 0x10, 0x05, 0x00, 0x08, 0x05, 0x05,
|
||||||
|
0x2f, 0x5f, 0x3c, 0x42, 0xf8, 0xa6,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct m7_data {
|
||||||
|
struct wsc_m7 expected;
|
||||||
|
const uint8_t *expected_encrypted;
|
||||||
|
size_t expected_encrypted_size;
|
||||||
|
const void *pdu;
|
||||||
|
unsigned int len;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct m7_data m7_data_1 = {
|
||||||
|
.pdu = eap_wsc_m7 + 18,
|
||||||
|
.len = sizeof(eap_wsc_m7) - 18,
|
||||||
|
.expected = {
|
||||||
|
.version2 = true,
|
||||||
|
.registrar_nonce = { 0x67, 0xa5, 0x53, 0x61, 0xee, 0x72, 0xc2,
|
||||||
|
0x21, 0x48, 0x78, 0xc5, 0x70, 0x89,
|
||||||
|
0x9f, 0xf2, 0xa0 },
|
||||||
|
.authenticator = { 0x05, 0x05, 0x2f, 0x5f, 0x3c, 0x42,
|
||||||
|
0xf8, 0xa6 },
|
||||||
|
},
|
||||||
|
.expected_encrypted = eap_wsc_m7 + 52,
|
||||||
|
.expected_encrypted_size = 64,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void wsc_test_parse_m7(const void *data)
|
||||||
|
{
|
||||||
|
const struct m7_data *test = data;
|
||||||
|
struct wsc_m7 m7;
|
||||||
|
const struct wsc_m7 *expected = &test->expected;
|
||||||
|
struct iovec encrypted;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
r = wsc_parse_m7(test->pdu, test->len, &m7, &encrypted);
|
||||||
|
assert(r == 0);
|
||||||
|
|
||||||
|
assert(expected->version2 == m7.version2);
|
||||||
|
assert(!memcmp(expected->registrar_nonce, m7.registrar_nonce, 16));
|
||||||
|
assert(!memcmp(expected->authenticator, m7.authenticator, 8));
|
||||||
|
|
||||||
|
assert(test->expected_encrypted_size == encrypted.iov_len);
|
||||||
|
assert(!memcmp(test->expected_encrypted,
|
||||||
|
encrypted.iov_base, encrypted.iov_len));
|
||||||
|
}
|
||||||
|
|
||||||
static const uint8_t eap_identity_req[] = {
|
static const uint8_t eap_identity_req[] = {
|
||||||
0x01, 0x00, 0x00, 0x05, 0x01, 0x00, 0x00, 0x05, 0x01
|
0x01, 0x00, 0x00, 0x05, 0x01, 0x00, 0x00, 0x05, 0x01
|
||||||
};
|
};
|
||||||
@ -1787,6 +1845,8 @@ int main(int argc, char *argv[])
|
|||||||
wsc_test_build_m6_encrypted_settings,
|
wsc_test_build_m6_encrypted_settings,
|
||||||
&m6_encrypted_settings_data_1);
|
&m6_encrypted_settings_data_1);
|
||||||
|
|
||||||
|
l_test_add("/wsc/parse/m7 1", wsc_test_parse_m7, &m7_data_1);
|
||||||
|
|
||||||
l_test_add("/wsc/handshake/PBC Handshake Test",
|
l_test_add("/wsc/handshake/PBC Handshake Test",
|
||||||
wsc_test_pbc_handshake, NULL);
|
wsc_test_pbc_handshake, NULL);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user