mirror of
				https://git.kernel.org/pub/scm/network/wireless/iwd.git
				synced 2025-10-30 20:37:26 +01:00 
			
		
		
		
	unit: Add M3 parser unit test
This commit is contained in:
		
							parent
							
								
									b6e7b7a4d6
								
							
						
					
					
						commit
						951eb26ec0
					
				| @ -1019,6 +1019,65 @@ static void wsc_test_build_m2(const void *data) | ||||
| 	l_free(out); | ||||
| } | ||||
| 
 | ||||
| static const unsigned char eap_wsc_m3[] = { | ||||
| 	0x01, 0x00, 0x00, 0x8a, 0x02, 0xa8, 0x00, 0x8a, 0xfe, 0x00, 0x37, 0x2a, | ||||
| 	0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x10, 0x4a, 0x00, 0x01, 0x10, 0x10, | ||||
| 	0x22, 0x00, 0x01, 0x07, 0x10, 0x39, 0x00, 0x10, 0x67, 0xa5, 0x53, 0x61, | ||||
| 	0xee, 0x72, 0xc2, 0x21, 0x48, 0x78, 0xc5, 0x70, 0x89, 0x9f, 0xf2, 0xa0, | ||||
| 	0x10, 0x14, 0x00, 0x20, 0x70, 0x9b, 0x9a, 0x2d, 0x26, 0x98, 0x0d, 0x46, | ||||
| 	0x8e, 0x1c, 0xb8, 0x8a, 0xbf, 0xcb, 0x83, 0xb9, 0x65, 0xba, 0x0b, 0xd1, | ||||
| 	0x20, 0xd9, 0x36, 0x9e, 0xc3, 0xc7, 0xb8, 0x9b, 0xe9, 0x0a, 0xa5, 0x50, | ||||
| 	0x10, 0x15, 0x00, 0x20, 0xfd, 0x5f, 0xfa, 0xb0, 0xa1, 0x4b, 0x78, 0xf9, | ||||
| 	0xa4, 0x9c, 0x84, 0x72, 0x2b, 0x08, 0x2e, 0x73, 0x73, 0x4e, 0xfb, 0x4d, | ||||
| 	0xbf, 0x93, 0x08, 0xa9, 0x56, 0xa5, 0x52, 0x89, 0x4c, 0x74, 0x44, 0x8f, | ||||
| 	0x10, 0x49, 0x00, 0x06, 0x00, 0x37, 0x2a, 0x00, 0x01, 0x20, 0x10, 0x05, | ||||
| 	0x00, 0x08, 0xaf, 0x03, 0x0e, 0x95, 0xd6, 0xe6, 0x72, 0xaf, | ||||
| }; | ||||
| 
 | ||||
| struct m3_data { | ||||
| 	struct wsc_m3 expected; | ||||
| 	const void *pdu; | ||||
| 	unsigned int len; | ||||
| }; | ||||
| 
 | ||||
| static const struct m3_data m3_data_1 = { | ||||
| 	.pdu = eap_wsc_m3 + 18, | ||||
| 	.len = sizeof(eap_wsc_m3) - 18, | ||||
| 	.expected = { | ||||
| 		.version2 = true, | ||||
| 		.registrar_nonce = { 0x67, 0xa5, 0x53, 0x61, 0xee, 0x72, 0xc2, | ||||
| 					0x21, 0x48, 0x78, 0xc5, 0x70, 0x89, | ||||
| 					0x9f, 0xf2, 0xa0 }, | ||||
| 		.e_hash1 = { 0x70, 0x9b, 0x9a, 0x2d, 0x26, 0x98, 0x0d, 0x46, | ||||
| 			0x8e, 0x1c, 0xb8, 0x8a, 0xbf, 0xcb, 0x83, 0xb9, 0x65, | ||||
| 			0xba, 0x0b, 0xd1, 0x20, 0xd9, 0x36, 0x9e, 0xc3, 0xc7, | ||||
| 			0xb8, 0x9b, 0xe9, 0x0a, 0xa5, 0x50 }, | ||||
| 		.e_hash2 = { 0xfd, 0x5f, 0xfa, 0xb0, 0xa1, 0x4b, 0x78, 0xf9, | ||||
| 			0xa4, 0x9c, 0x84, 0x72, 0x2b, 0x08, 0x2e, 0x73, 0x73, | ||||
| 			0x4e, 0xfb, 0x4d, 0xbf, 0x93, 0x08, 0xa9, 0x56, 0xa5, | ||||
| 			0x52, 0x89, 0x4c, 0x74, 0x44, 0x8f }, | ||||
| 		.authenticator = { 0xaf, 0x03, 0x0e, 0x95, 0xd6, 0xe6, | ||||
| 					0x72, 0xaf }, | ||||
| 	}, | ||||
| }; | ||||
| 
 | ||||
| static void wsc_test_parse_m3(const void *data) | ||||
| { | ||||
| 	const struct m3_data *test = data; | ||||
| 	struct wsc_m3 m3; | ||||
| 	const struct wsc_m3 *expected = &test->expected; | ||||
| 	int r; | ||||
| 
 | ||||
| 	r = wsc_parse_m3(test->pdu, test->len, &m3); | ||||
| 	assert(r == 0); | ||||
| 
 | ||||
| 	assert(expected->version2 == m3.version2); | ||||
| 	assert(!memcmp(expected->registrar_nonce, m3.registrar_nonce, 16)); | ||||
| 	assert(!memcmp(expected->e_hash1, m3.e_hash1, 32)); | ||||
| 	assert(!memcmp(expected->e_hash2, m3.e_hash2, 32)); | ||||
| 	assert(!memcmp(expected->authenticator, m3.authenticator, 8)); | ||||
| } | ||||
| 
 | ||||
| int main(int argc, char *argv[]) | ||||
| { | ||||
| 	l_test_init(&argc, &argv); | ||||
| @ -1058,5 +1117,7 @@ int main(int argc, char *argv[]) | ||||
| 
 | ||||
| 	l_test_add("/wsc/build/m2 1", wsc_test_build_m2, &m2_data_1); | ||||
| 
 | ||||
| 	l_test_add("/wsc/parse/m3 1", wsc_test_parse_m3, &m3_data_1); | ||||
| 
 | ||||
| 	return l_test_run(); | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Denis Kenzior
						Denis Kenzior