1 /*
2  * PASN initiator fuzzer
3  * Copyright (c) 2022, Jouni Malinen <j@w1.fi>
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #include "utils/includes.h"
10 
11 #include "utils/common.h"
12 #include "common/defs.h"
13 #include "common/wpa_common.h"
14 #include "common/sae.h"
15 #include "common/ieee802_11_defs.h"
16 #include "crypto/sha384.h"
17 #include "pasn/pasn_common.h"
18 #include "../fuzzer-common.h"
19 
20 
pasn_send_mgmt(void * ctx,const u8 * data,size_t data_len,int noack,unsigned int freq,unsigned int wait)21 static int pasn_send_mgmt(void *ctx, const u8 *data, size_t data_len,
22 			  int noack, unsigned int freq, unsigned int wait)
23 {
24 	return 0;
25 }
26 
27 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)28 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
29 {
30 	struct pasn_data pasn;
31 	struct wpa_pasn_params_data pasn_data;
32 	u8 own_addr[ETH_ALEN], bssid[ETH_ALEN];
33 
34 	wpa_fuzzer_set_debug_level();
35 
36 	if (os_program_init())
37 		return 0;
38 
39 	os_memset(&pasn, 0, sizeof(pasn));
40 	pasn.send_mgmt = pasn_send_mgmt;
41 	hwaddr_aton("02:00:00:00:00:00", own_addr);
42 	hwaddr_aton("02:00:00:00:03:00", bssid);
43 	if (wpas_pasn_start(&pasn, own_addr, bssid, bssid, WPA_KEY_MGMT_PASN,
44 			    WPA_CIPHER_CCMP, 19, 2412, NULL, 0, NULL, 0,
45 			    NULL) < 0) {
46 		wpa_printf(MSG_ERROR, "wpas_pasn_start failed");
47 		goto fail;
48 	}
49 
50 	wpa_pasn_auth_rx(&pasn, data, size, &pasn_data);
51 
52 fail:
53 	wpa_pasn_reset(&pasn);
54 	os_program_deinit();
55 
56 	return 0;
57 }
58