/src/hostap/tests/fuzzing/pasn-init/pasn-init.c
Line | Count | Source (jump to first uncovered line) |
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 | | |
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 | 2.69k | { |
24 | 2.69k | return 0; |
25 | 2.69k | } |
26 | | |
27 | | |
28 | | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
29 | 2.69k | { |
30 | 2.69k | struct pasn_data pasn; |
31 | 2.69k | struct wpa_pasn_params_data pasn_data; |
32 | 2.69k | u8 own_addr[ETH_ALEN], bssid[ETH_ALEN]; |
33 | | |
34 | 2.69k | wpa_fuzzer_set_debug_level(); |
35 | | |
36 | 2.69k | if (os_program_init()) |
37 | 0 | return 0; |
38 | | |
39 | 2.69k | os_memset(&pasn, 0, sizeof(pasn)); |
40 | 2.69k | pasn.send_mgmt = pasn_send_mgmt; |
41 | 2.69k | hwaddr_aton("02:00:00:00:00:00", own_addr); |
42 | 2.69k | hwaddr_aton("02:00:00:00:03:00", bssid); |
43 | 2.69k | if (wpas_pasn_start(&pasn, own_addr, bssid, bssid, WPA_KEY_MGMT_PASN, |
44 | 2.69k | WPA_CIPHER_CCMP, 19, 2412, NULL, 0, NULL, 0, |
45 | 2.69k | NULL) < 0) { |
46 | 0 | wpa_printf(MSG_ERROR, "wpas_pasn_start failed"); |
47 | 0 | goto fail; |
48 | 0 | } |
49 | | |
50 | 2.69k | wpa_pasn_auth_rx(&pasn, data, size, &pasn_data); |
51 | | |
52 | 2.69k | fail: |
53 | 2.69k | wpa_pasn_reset(&pasn); |
54 | 2.69k | os_program_deinit(); |
55 | | |
56 | 2.69k | return 0; |
57 | 2.69k | } |