mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-01-20 01:14:07 +01:00
unit: Add test for wsc_parse_m8
This commit is contained in:
parent
addba697da
commit
a2b740f161
@ -1625,6 +1625,71 @@ static void wsc_test_build_m7(const void *data)
|
||||
l_free(out);
|
||||
}
|
||||
|
||||
static const unsigned char eap_wsc_m8[] = {
|
||||
0x01, 0x00, 0x00, 0xcc, 0x01, 0xab, 0x00, 0xcc, 0xfe, 0x00, 0x37, 0x2a,
|
||||
0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x10, 0x4a, 0x00, 0x01, 0x10, 0x10,
|
||||
0x22, 0x00, 0x01, 0x0c, 0x10, 0x1a, 0x00, 0x10, 0x19, 0x8d, 0x0d, 0x25,
|
||||
0x91, 0x2c, 0x37, 0x1c, 0xeb, 0x07, 0x89, 0x33, 0xe1, 0x25, 0xd7, 0x43,
|
||||
0x10, 0x18, 0x00, 0x90, 0x7e, 0x2f, 0x4a, 0xae, 0x60, 0x1e, 0x54, 0x75,
|
||||
0x3b, 0x6e, 0xfc, 0x0a, 0x84, 0xdb, 0xae, 0x62, 0x74, 0xf4, 0xe5, 0xe0,
|
||||
0xf2, 0xc5, 0xf1, 0x78, 0xc0, 0x76, 0x4d, 0xc4, 0x08, 0x6d, 0xd5, 0xb7,
|
||||
0xa2, 0x74, 0x18, 0x26, 0xee, 0x01, 0xe4, 0x3d, 0x5f, 0x44, 0xca, 0x93,
|
||||
0xad, 0x07, 0xc7, 0xa5, 0xcf, 0xf1, 0xb9, 0xb9, 0x68, 0xf1, 0x15, 0xa9,
|
||||
0xbc, 0x66, 0x7f, 0x03, 0xa1, 0x84, 0x80, 0x78, 0x71, 0x13, 0x09, 0xaa,
|
||||
0x74, 0x60, 0xa2, 0x0f, 0x49, 0x4a, 0x8b, 0x8f, 0xd9, 0xab, 0x07, 0x5f,
|
||||
0x79, 0xc1, 0xb2, 0x22, 0x16, 0xc7, 0x05, 0xf8, 0xe8, 0x3e, 0x46, 0x26,
|
||||
0x9a, 0xc5, 0x01, 0xfe, 0xa2, 0x15, 0x1c, 0xbe, 0x97, 0x87, 0xc8, 0x83,
|
||||
0xb9, 0xf2, 0x89, 0x82, 0xb8, 0xe0, 0x46, 0x08, 0xb1, 0xbd, 0x1d, 0xe8,
|
||||
0x9f, 0x1d, 0x50, 0xbd, 0x79, 0x2c, 0xa7, 0xf7, 0xe7, 0x34, 0xf4, 0x7c,
|
||||
0x28, 0xa4, 0x9a, 0x42, 0x6e, 0x94, 0x88, 0x78, 0x28, 0xfd, 0xea, 0xdf,
|
||||
0x13, 0x5c, 0x66, 0x79, 0x10, 0x05, 0x00, 0x08, 0xba, 0x2b, 0xfc, 0x68,
|
||||
0x49, 0x8e, 0x88, 0xfa,
|
||||
};
|
||||
|
||||
struct m8_data {
|
||||
struct wsc_m8 expected;
|
||||
const uint8_t *expected_encrypted;
|
||||
size_t expected_encrypted_size;
|
||||
const void *pdu;
|
||||
unsigned int len;
|
||||
};
|
||||
|
||||
static const struct m8_data m8_data_1 = {
|
||||
.pdu = eap_wsc_m8 + 18,
|
||||
.len = sizeof(eap_wsc_m8) - 18,
|
||||
.expected = {
|
||||
.version2 = false,
|
||||
.enrollee_nonce = { 0x19, 0x8d, 0x0d, 0x25, 0x91, 0x2c, 0x37,
|
||||
0x1c, 0xeb, 0x07, 0x89, 0x33, 0xe1,
|
||||
0x25, 0xd7, 0x43 },
|
||||
.authenticator = { 0xba, 0x2b, 0xfc, 0x68, 0x49, 0x8e,
|
||||
0x88, 0xfa },
|
||||
|
||||
},
|
||||
.expected_encrypted = eap_wsc_m8 + 52,
|
||||
.expected_encrypted_size = 144,
|
||||
};
|
||||
|
||||
static void wsc_test_parse_m8(const void *data)
|
||||
{
|
||||
const struct m8_data *test = data;
|
||||
struct wsc_m8 m8;
|
||||
const struct wsc_m8 *expected = &test->expected;
|
||||
struct iovec encrypted;
|
||||
int r;
|
||||
|
||||
r = wsc_parse_m8(test->pdu, test->len, &m8, &encrypted);
|
||||
assert(r == 0);
|
||||
|
||||
assert(expected->version2 == m8.version2);
|
||||
assert(!memcmp(expected->enrollee_nonce, m8.enrollee_nonce, 16));
|
||||
assert(!memcmp(expected->authenticator, m8.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[] = {
|
||||
0x01, 0x00, 0x00, 0x05, 0x01, 0x00, 0x00, 0x05, 0x01
|
||||
};
|
||||
@ -1831,6 +1896,8 @@ int main(int argc, char *argv[])
|
||||
l_test_add("/wsc/parse/m7 1", wsc_test_parse_m7, &m7_data_1);
|
||||
l_test_add("/wsc/build/m7 1", wsc_test_build_m7, &m7_data_1);
|
||||
|
||||
l_test_add("/wsc/parse/m8 1", wsc_test_parse_m8, &m8_data_1);
|
||||
|
||||
l_test_add("/wsc/handshake/PBC Handshake Test",
|
||||
wsc_test_pbc_handshake, NULL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user