]>
Commit | Line | Data |
---|---|---|
302b7a1b JM |
1 | #!/usr/bin/python |
2 | # | |
3 | # WPS tests | |
4 | # Copyright (c) 2013, Jouni Malinen <j@w1.fi> | |
5 | # | |
6 | # This software may be distributed under the terms of the BSD license. | |
7 | # See README for more details. | |
8 | ||
9 | import time | |
10 | import subprocess | |
11 | import logging | |
c9aa4308 | 12 | logger = logging.getLogger() |
302b7a1b JM |
13 | |
14 | import hwsim_utils | |
15 | import hostapd | |
16 | ||
ae3ad328 | 17 | def test_ap_wps_init(dev, apdev): |
302b7a1b JM |
18 | """Initial AP configuration with first WPS Enrollee""" |
19 | ssid = "test-wps" | |
ae3ad328 | 20 | hostapd.add_ap(apdev[0]['ifname'], |
302b7a1b | 21 | { "ssid": ssid, "eap_server": "1", "wps_state": "1" }) |
ae3ad328 | 22 | hapd = hostapd.Hostapd(apdev[0]['ifname']) |
302b7a1b JM |
23 | logger.info("WPS provisioning step") |
24 | hapd.request("WPS_PBC") | |
6dacb8e9 | 25 | dev[0].request("SET ignore_old_scan_res 1") |
302b7a1b JM |
26 | dev[0].dump_monitor() |
27 | dev[0].request("WPS_PBC") | |
853b49a0 | 28 | ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30) |
302b7a1b JM |
29 | if ev is None: |
30 | raise Exception("Association with the AP timed out") | |
31 | status = dev[0].get_status() | |
ae3ad328 | 32 | if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']: |
302b7a1b JM |
33 | raise Exception("Not fully connected") |
34 | if status['ssid'] != ssid: | |
35 | raise Exception("Unexpected SSID") | |
36 | if status['pairwise_cipher'] != 'CCMP': | |
37 | raise Exception("Unexpected encryption configuration") | |
38 | if status['key_mgmt'] != 'WPA2-PSK': | |
39 | raise Exception("Unexpected key_mgmt") | |
40 | ||
ae3ad328 | 41 | def test_ap_wps_conf(dev, apdev): |
302b7a1b JM |
42 | """WPS PBC provisioning with configured AP""" |
43 | ssid = "test-wps-conf" | |
ae3ad328 | 44 | hostapd.add_ap(apdev[0]['ifname'], |
302b7a1b JM |
45 | { "ssid": ssid, "eap_server": "1", "wps_state": "2", |
46 | "wpa_passphrase": "12345678", "wpa": "2", | |
47 | "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) | |
ae3ad328 | 48 | hapd = hostapd.Hostapd(apdev[0]['ifname']) |
302b7a1b JM |
49 | logger.info("WPS provisioning step") |
50 | hapd.request("WPS_PBC") | |
51 | dev[0].dump_monitor() | |
52 | dev[0].request("WPS_PBC") | |
7e3f110b | 53 | ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30) |
302b7a1b JM |
54 | if ev is None: |
55 | raise Exception("Association with the AP timed out") | |
56 | status = dev[0].get_status() | |
ae3ad328 | 57 | if status['wpa_state'] != 'COMPLETED': |
302b7a1b | 58 | raise Exception("Not fully connected") |
ae3ad328 JM |
59 | if status['bssid'] != apdev[0]['bssid']: |
60 | raise Exception("Unexpected BSSID") | |
302b7a1b JM |
61 | if status['ssid'] != ssid: |
62 | raise Exception("Unexpected SSID") | |
63 | if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP': | |
64 | raise Exception("Unexpected encryption configuration") | |
65 | if status['key_mgmt'] != 'WPA2-PSK': | |
66 | raise Exception("Unexpected key_mgmt") | |
67 | ||
04e62788 JM |
68 | def test_ap_wps_twice(dev, apdev): |
69 | """WPS provisioning with twice to change passphrase""" | |
70 | ssid = "test-wps-twice" | |
71 | params = { "ssid": ssid, "eap_server": "1", "wps_state": "2", | |
72 | "wpa_passphrase": "12345678", "wpa": "2", | |
73 | "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" } | |
74 | hostapd.add_ap(apdev[0]['ifname'], params) | |
75 | hapd = hostapd.Hostapd(apdev[0]['ifname']) | |
76 | logger.info("WPS provisioning step") | |
77 | hapd.request("WPS_PBC") | |
78 | dev[0].request("SET ignore_old_scan_res 1") | |
79 | dev[0].dump_monitor() | |
80 | dev[0].request("WPS_PBC") | |
81 | ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30) | |
82 | if ev is None: | |
83 | raise Exception("Association with the AP timed out") | |
84 | dev[0].request("DISCONNECT") | |
85 | ||
86 | logger.info("Restart AP with different passphrase and re-run WPS") | |
87 | hapd_global = hostapd.HostapdGlobal() | |
88 | hapd_global.remove(apdev[0]['ifname']) | |
89 | params['wpa_passphrase'] = 'another passphrase' | |
90 | hostapd.add_ap(apdev[0]['ifname'], params) | |
91 | hapd = hostapd.Hostapd(apdev[0]['ifname']) | |
92 | logger.info("WPS provisioning step") | |
93 | hapd.request("WPS_PBC") | |
94 | dev[0].dump_monitor() | |
95 | dev[0].request("WPS_PBC") | |
96 | ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30) | |
97 | if ev is None: | |
98 | raise Exception("Association with the AP timed out") | |
99 | networks = dev[0].list_networks() | |
100 | if len(networks) > 1: | |
101 | raise Exception("Unexpected duplicated network block present") | |
102 | ||
ae3ad328 | 103 | def test_ap_wps_conf_pin(dev, apdev): |
302b7a1b JM |
104 | """WPS PIN provisioning with configured AP""" |
105 | ssid = "test-wps-conf-pin" | |
ae3ad328 | 106 | hostapd.add_ap(apdev[0]['ifname'], |
302b7a1b JM |
107 | { "ssid": ssid, "eap_server": "1", "wps_state": "2", |
108 | "wpa_passphrase": "12345678", "wpa": "2", | |
109 | "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) | |
ae3ad328 | 110 | hapd = hostapd.Hostapd(apdev[0]['ifname']) |
302b7a1b JM |
111 | logger.info("WPS provisioning step") |
112 | pin = dev[0].wps_read_pin() | |
113 | hapd.request("WPS_PIN any " + pin) | |
6dacb8e9 | 114 | dev[0].request("SET ignore_old_scan_res 1") |
302b7a1b JM |
115 | dev[0].dump_monitor() |
116 | dev[0].request("WPS_PIN any " + pin) | |
7e3f110b | 117 | ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30) |
302b7a1b JM |
118 | if ev is None: |
119 | raise Exception("Association with the AP timed out") | |
120 | status = dev[0].get_status() | |
ae3ad328 | 121 | if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']: |
302b7a1b JM |
122 | raise Exception("Not fully connected") |
123 | if status['ssid'] != ssid: | |
124 | raise Exception("Unexpected SSID") | |
125 | if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP': | |
126 | raise Exception("Unexpected encryption configuration") | |
127 | if status['key_mgmt'] != 'WPA2-PSK': | |
128 | raise Exception("Unexpected key_mgmt") | |
129 | ||
ae3ad328 | 130 | def test_ap_wps_reg_connect(dev, apdev): |
302b7a1b | 131 | """WPS registrar using AP PIN to connect""" |
803edd1c | 132 | ssid = "test-wps-reg-ap-pin" |
302b7a1b | 133 | appin = "12345670" |
ae3ad328 | 134 | hostapd.add_ap(apdev[0]['ifname'], |
302b7a1b JM |
135 | { "ssid": ssid, "eap_server": "1", "wps_state": "2", |
136 | "wpa_passphrase": "12345678", "wpa": "2", | |
137 | "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", | |
138 | "ap_pin": appin}) | |
139 | logger.info("WPS provisioning step") | |
803edd1c | 140 | dev[0].request("SET ignore_old_scan_res 1") |
302b7a1b | 141 | dev[0].dump_monitor() |
6edaee9c | 142 | dev[0].wps_reg(apdev[0]['bssid'], appin) |
302b7a1b | 143 | status = dev[0].get_status() |
ae3ad328 | 144 | if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']: |
302b7a1b JM |
145 | raise Exception("Not fully connected") |
146 | if status['ssid'] != ssid: | |
147 | raise Exception("Unexpected SSID") | |
148 | if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP': | |
149 | raise Exception("Unexpected encryption configuration") | |
150 | if status['key_mgmt'] != 'WPA2-PSK': | |
151 | raise Exception("Unexpected key_mgmt") | |
152 | ||
ae3ad328 | 153 | def test_ap_wps_reg_config(dev, apdev): |
302b7a1b JM |
154 | """WPS registrar configuring and AP using AP PIN""" |
155 | ssid = "test-wps-init-ap-pin" | |
156 | appin = "12345670" | |
ae3ad328 | 157 | hostapd.add_ap(apdev[0]['ifname'], |
302b7a1b JM |
158 | { "ssid": ssid, "eap_server": "1", "wps_state": "2", |
159 | "ap_pin": appin}) | |
160 | logger.info("WPS configuration step") | |
803edd1c | 161 | dev[0].request("SET ignore_old_scan_res 1") |
302b7a1b JM |
162 | dev[0].dump_monitor() |
163 | new_ssid = "wps-new-ssid" | |
164 | new_passphrase = "1234567890" | |
6edaee9c JM |
165 | dev[0].wps_reg(apdev[0]['bssid'], appin, new_ssid, "WPA2PSK", "CCMP", |
166 | new_passphrase) | |
302b7a1b | 167 | status = dev[0].get_status() |
ae3ad328 | 168 | if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']: |
302b7a1b JM |
169 | raise Exception("Not fully connected") |
170 | if status['ssid'] != new_ssid: | |
171 | raise Exception("Unexpected SSID") | |
172 | if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP': | |
173 | raise Exception("Unexpected encryption configuration") | |
174 | if status['key_mgmt'] != 'WPA2-PSK': | |
175 | raise Exception("Unexpected key_mgmt") | |
176 | ||
6645ff50 JM |
177 | def test_ap_wps_setup_locked(dev, apdev): |
178 | """WPS registrar locking up AP setup on AP PIN failures""" | |
179 | ssid = "test-wps-incorrect-ap-pin" | |
180 | appin = "12345670" | |
181 | hostapd.add_ap(apdev[0]['ifname'], | |
182 | { "ssid": ssid, "eap_server": "1", "wps_state": "2", | |
183 | "wpa_passphrase": "12345678", "wpa": "2", | |
184 | "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", | |
185 | "ap_pin": appin}) | |
186 | dev[0].request("SET ignore_old_scan_res 1") | |
187 | new_ssid = "wps-new-ssid-test" | |
188 | new_passphrase = "1234567890" | |
189 | ||
190 | ap_setup_locked=False | |
191 | for pin in ["55554444", "1234", "12345678", "00000000", "11111111"]: | |
192 | dev[0].dump_monitor() | |
193 | logger.info("Try incorrect AP PIN - attempt " + pin) | |
194 | dev[0].wps_reg(apdev[0]['bssid'], pin, new_ssid, "WPA2PSK", | |
195 | "CCMP", new_passphrase, no_wait=True) | |
196 | ev = dev[0].wait_event(["WPS-FAIL", "CTRL-EVENT-CONNECTED"]) | |
197 | if ev is None: | |
198 | raise Exception("Timeout on receiving WPS operation failure event") | |
199 | if "CTRL-EVENT-CONNECTED" in ev: | |
200 | raise Exception("Unexpected connection") | |
201 | if "config_error=15" in ev: | |
202 | logger.info("AP Setup Locked") | |
203 | ap_setup_locked=True | |
204 | elif "config_error=18" not in ev: | |
205 | raise Exception("config_error=18 not reported") | |
206 | ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"]) | |
207 | if ev is None: | |
208 | raise Exception("Timeout on disconnection event") | |
209 | time.sleep(0.1) | |
210 | if not ap_setup_locked: | |
211 | raise Exception("AP setup was not locked") | |
212 | ||
213 | time.sleep(0.5) | |
214 | dev[0].dump_monitor() | |
215 | logger.info("WPS provisioning step") | |
216 | pin = dev[0].wps_read_pin() | |
217 | hapd = hostapd.Hostapd(apdev[0]['ifname']) | |
218 | hapd.request("WPS_PIN any " + pin) | |
219 | dev[0].request("WPS_PIN any " + pin) | |
220 | ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=30) | |
221 | if ev is None: | |
222 | raise Exception("WPS success was not reported") | |
223 | ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30) | |
224 | if ev is None: | |
225 | raise Exception("Association with the AP timed out") | |
226 | ||
ae3ad328 | 227 | def test_ap_wps_pbc_overlap_2ap(dev, apdev): |
302b7a1b | 228 | """WPS PBC session overlap with two active APs""" |
ae3ad328 | 229 | hostapd.add_ap(apdev[0]['ifname'], |
302b7a1b JM |
230 | { "ssid": "wps1", "eap_server": "1", "wps_state": "2", |
231 | "wpa_passphrase": "12345678", "wpa": "2", | |
232 | "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", | |
233 | "wps_independent": "1"}) | |
ae3ad328 | 234 | hostapd.add_ap(apdev[1]['ifname'], |
302b7a1b JM |
235 | { "ssid": "wps2", "eap_server": "1", "wps_state": "2", |
236 | "wpa_passphrase": "123456789", "wpa": "2", | |
237 | "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", | |
238 | "wps_independent": "1"}) | |
ae3ad328 | 239 | hapd = hostapd.Hostapd(apdev[0]['ifname']) |
302b7a1b | 240 | hapd.request("WPS_PBC") |
ae3ad328 | 241 | hapd2 = hostapd.Hostapd(apdev[1]['ifname']) |
302b7a1b JM |
242 | hapd2.request("WPS_PBC") |
243 | logger.info("WPS provisioning step") | |
244 | dev[0].dump_monitor() | |
245 | dev[0].request("WPS_PBC") | |
246 | ev = dev[0].wait_event(["WPS-OVERLAP-DETECTED"], timeout=15) | |
247 | if ev is None: | |
248 | raise Exception("PBC session overlap not detected") | |
249 | ||
ae3ad328 | 250 | def test_ap_wps_pbc_overlap_2sta(dev, apdev): |
302b7a1b JM |
251 | """WPS PBC session overlap with two active STAs""" |
252 | ssid = "test-wps-pbc-overlap" | |
ae3ad328 | 253 | hostapd.add_ap(apdev[0]['ifname'], |
302b7a1b JM |
254 | { "ssid": ssid, "eap_server": "1", "wps_state": "2", |
255 | "wpa_passphrase": "12345678", "wpa": "2", | |
256 | "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"}) | |
ae3ad328 | 257 | hapd = hostapd.Hostapd(apdev[0]['ifname']) |
302b7a1b JM |
258 | logger.info("WPS provisioning step") |
259 | hapd.request("WPS_PBC") | |
803edd1c | 260 | dev[0].request("SET ignore_old_scan_res 1") |
803edd1c | 261 | dev[1].request("SET ignore_old_scan_res 1") |
302b7a1b JM |
262 | dev[0].dump_monitor() |
263 | dev[1].dump_monitor() | |
264 | dev[0].request("WPS_PBC") | |
265 | dev[1].request("WPS_PBC") | |
266 | ev = dev[0].wait_event(["WPS-M2D"], timeout=15) | |
267 | if ev is None: | |
268 | raise Exception("PBC session overlap not detected (dev0)") | |
269 | if "config_error=12" not in ev: | |
270 | raise Exception("PBC session overlap not correctly reported (dev0)") | |
271 | ev = dev[1].wait_event(["WPS-M2D"], timeout=15) | |
272 | if ev is None: | |
273 | raise Exception("PBC session overlap not detected (dev1)") | |
274 | if "config_error=12" not in ev: | |
275 | raise Exception("PBC session overlap not correctly reported (dev1)") | |
6edaee9c JM |
276 | |
277 | def test_ap_wps_er_add_enrollee(dev, apdev): | |
278 | """WPS ER configuring AP and adding a new enrollee using PIN""" | |
279 | ssid = "wps-er-add-enrollee" | |
280 | ap_pin = "12345670" | |
281 | ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" | |
282 | hostapd.add_ap(apdev[0]['ifname'], | |
283 | { "ssid": ssid, "eap_server": "1", "wps_state": "1", | |
284 | "device_name": "Wireless AP", "manufacturer": "Company", | |
285 | "model_name": "WAP", "model_number": "123", | |
286 | "serial_number": "12345", "device_type": "6-0050F204-1", | |
287 | "os_version": "01020300", | |
288 | "config_methods": "label push_button", | |
289 | "ap_pin": ap_pin, "uuid": ap_uuid, "upnp_iface": "lo"}) | |
290 | logger.info("WPS configuration step") | |
291 | new_passphrase = "1234567890" | |
292 | dev[0].dump_monitor() | |
293 | dev[0].request("SET ignore_old_scan_res 1") | |
294 | dev[0].wps_reg(apdev[0]['bssid'], ap_pin, ssid, "WPA2PSK", "CCMP", | |
295 | new_passphrase) | |
296 | status = dev[0].get_status() | |
297 | if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']: | |
298 | raise Exception("Not fully connected") | |
299 | if status['ssid'] != ssid: | |
300 | raise Exception("Unexpected SSID") | |
301 | if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP': | |
302 | raise Exception("Unexpected encryption configuration") | |
303 | if status['key_mgmt'] != 'WPA2-PSK': | |
304 | raise Exception("Unexpected key_mgmt") | |
305 | ||
306 | logger.info("Start ER") | |
307 | dev[0].request("WPS_ER_START ifname=lo") | |
308 | ev = dev[0].wait_event(["WPS-ER-AP-ADD"], timeout=15) | |
309 | if ev is None: | |
310 | raise Exception("AP discovery timed out") | |
311 | if ap_uuid not in ev: | |
312 | raise Exception("Expected AP UUID not found") | |
313 | ||
314 | logger.info("Learn AP configuration through UPnP") | |
315 | dev[0].dump_monitor() | |
316 | dev[0].request("WPS_ER_LEARN " + ap_uuid + " " + ap_pin) | |
317 | ev = dev[0].wait_event(["WPS-ER-AP-SETTINGS"], timeout=15) | |
318 | if ev is None: | |
319 | raise Exception("AP learn timed out") | |
320 | if ap_uuid not in ev: | |
321 | raise Exception("Expected AP UUID not in settings") | |
322 | if "ssid=" + ssid not in ev: | |
323 | raise Exception("Expected SSID not in settings") | |
324 | if "key=" + new_passphrase not in ev: | |
325 | raise Exception("Expected passphrase not in settings") | |
326 | ||
327 | logger.info("Add Enrollee using ER") | |
328 | pin = dev[1].wps_read_pin() | |
329 | dev[0].dump_monitor() | |
330 | dev[0].request("WPS_ER_PIN any " + pin + " " + dev[1].p2p_interface_addr()) | |
331 | dev[1].request("SET ignore_old_scan_res 1") | |
332 | dev[1].dump_monitor() | |
333 | dev[1].request("WPS_PIN any " + pin) | |
846be889 | 334 | ev = dev[1].wait_event(["WPS-SUCCESS"], timeout=30) |
6edaee9c JM |
335 | if ev is None: |
336 | raise Exception("Enrollee did not report success") | |
337 | ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15) | |
338 | if ev is None: | |
339 | raise Exception("Association with the AP timed out") | |
340 | ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=15) | |
341 | if ev is None: | |
342 | raise Exception("WPS ER did not report success") | |
343 | hwsim_utils.test_connectivity_sta(dev[0], dev[1]) | |
344 | ||
345 | def test_ap_wps_er_add_enrollee_pbc(dev, apdev): | |
346 | """WPS ER connected to AP and adding a new enrollee using PBC""" | |
347 | ssid = "wps-er-add-enrollee-pbc" | |
348 | ap_pin = "12345670" | |
349 | ap_uuid = "27ea801a-9e5c-4e73-bd82-f89cbcd10d7e" | |
350 | hostapd.add_ap(apdev[0]['ifname'], | |
351 | { "ssid": ssid, "eap_server": "1", "wps_state": "2", | |
352 | "wpa_passphrase": "12345678", "wpa": "2", | |
353 | "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", | |
354 | "device_name": "Wireless AP", "manufacturer": "Company", | |
355 | "model_name": "WAP", "model_number": "123", | |
356 | "serial_number": "12345", "device_type": "6-0050F204-1", | |
357 | "os_version": "01020300", | |
358 | "config_methods": "label push_button", | |
359 | "ap_pin": ap_pin, "uuid": ap_uuid, "upnp_iface": "lo"}) | |
360 | logger.info("Learn AP configuration") | |
361 | dev[0].dump_monitor() | |
362 | dev[0].request("SET ignore_old_scan_res 1") | |
363 | dev[0].wps_reg(apdev[0]['bssid'], ap_pin) | |
364 | status = dev[0].get_status() | |
365 | if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']: | |
366 | raise Exception("Not fully connected") | |
367 | ||
368 | logger.info("Start ER") | |
369 | dev[0].request("WPS_ER_START ifname=lo") | |
370 | ev = dev[0].wait_event(["WPS-ER-AP-ADD"], timeout=15) | |
371 | if ev is None: | |
372 | raise Exception("AP discovery timed out") | |
373 | if ap_uuid not in ev: | |
374 | raise Exception("Expected AP UUID not found") | |
375 | ||
376 | logger.info("Use learned network configuration on ER") | |
377 | dev[0].request("WPS_ER_SET_CONFIG " + ap_uuid + " 0") | |
378 | ||
379 | logger.info("Add Enrollee using ER and PBC") | |
380 | dev[0].dump_monitor() | |
381 | enrollee = dev[1].p2p_interface_addr() | |
382 | dev[1].request("SET ignore_old_scan_res 1") | |
383 | dev[1].dump_monitor() | |
384 | dev[1].request("WPS_PBC") | |
385 | ||
386 | ev = dev[0].wait_event(["WPS-ER-ENROLLEE-ADD"], timeout=15) | |
387 | if ev is None: | |
388 | raise Exception("Enrollee discovery timed out") | |
389 | if enrollee not in ev: | |
390 | raise Exception("Expected Enrollee not found") | |
391 | dev[0].request("WPS_ER_PBC " + enrollee) | |
392 | ||
393 | ev = dev[1].wait_event(["WPS-SUCCESS"], timeout=15) | |
394 | if ev is None: | |
395 | raise Exception("Enrollee did not report success") | |
396 | ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15) | |
397 | if ev is None: | |
398 | raise Exception("Association with the AP timed out") | |
399 | ev = dev[0].wait_event(["WPS-SUCCESS"], timeout=15) | |
400 | if ev is None: | |
401 | raise Exception("WPS ER did not report success") | |
402 | hwsim_utils.test_connectivity_sta(dev[0], dev[1]) | |
bff3ac5b JM |
403 | |
404 | def test_ap_wps_fragmentation(dev, apdev): | |
405 | """WPS with fragmentation in EAP-WSC and mixed mode WPA+WPA2""" | |
406 | ssid = "test-wps-fragmentation" | |
407 | hostapd.add_ap(apdev[0]['ifname'], | |
408 | { "ssid": ssid, "eap_server": "1", "wps_state": "2", | |
409 | "wpa_passphrase": "12345678", "wpa": "3", | |
410 | "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", | |
411 | "wpa_pairwise": "TKIP", | |
412 | "fragment_size": "50" }) | |
413 | hapd = hostapd.Hostapd(apdev[0]['ifname']) | |
414 | logger.info("WPS provisioning step") | |
415 | hapd.request("WPS_PBC") | |
416 | dev[0].request("SET ignore_old_scan_res 1") | |
417 | dev[0].dump_monitor() | |
418 | dev[0].request("SET wps_fragment_size 50") | |
419 | dev[0].request("WPS_PBC") | |
420 | ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30) | |
421 | if ev is None: | |
422 | raise Exception("Association with the AP timed out") | |
423 | status = dev[0].get_status() | |
424 | if status['wpa_state'] != 'COMPLETED': | |
425 | raise Exception("Not fully connected") | |
426 | if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'TKIP': | |
427 | raise Exception("Unexpected encryption configuration") | |
428 | if status['key_mgmt'] != 'WPA2-PSK': | |
429 | raise Exception("Unexpected key_mgmt") | |
10ea6848 JM |
430 | |
431 | def test_ap_wps_new_version_sta(dev, apdev): | |
432 | """WPS compatibility with new version number on the station""" | |
433 | ssid = "test-wps-ver" | |
434 | hostapd.add_ap(apdev[0]['ifname'], | |
435 | { "ssid": ssid, "eap_server": "1", "wps_state": "2", | |
436 | "wpa_passphrase": "12345678", "wpa": "2", | |
437 | "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" }) | |
438 | hapd = hostapd.Hostapd(apdev[0]['ifname']) | |
439 | logger.info("WPS provisioning step") | |
440 | hapd.request("WPS_PBC") | |
441 | dev[0].request("SET ignore_old_scan_res 1") | |
442 | dev[0].dump_monitor() | |
443 | dev[0].request("SET wps_version_number 0x43") | |
444 | dev[0].request("WPS_PBC") | |
445 | ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30) | |
446 | if ev is None: | |
447 | raise Exception("Association with the AP timed out") | |
448 | ||
449 | def test_ap_wps_new_version_ap(dev, apdev): | |
450 | """WPS compatibility with new version number on the AP""" | |
451 | ssid = "test-wps-ver" | |
452 | hostapd.add_ap(apdev[0]['ifname'], | |
453 | { "ssid": ssid, "eap_server": "1", "wps_state": "2", | |
454 | "wpa_passphrase": "12345678", "wpa": "2", | |
455 | "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP" }) | |
456 | hapd = hostapd.Hostapd(apdev[0]['ifname']) | |
457 | logger.info("WPS provisioning step") | |
458 | if "FAIL" in hapd.request("SET wps_version_number 0x43"): | |
459 | raise Exception("Failed to enable test functionality") | |
460 | hapd.request("WPS_PBC") | |
461 | dev[0].request("SET ignore_old_scan_res 1") | |
462 | dev[0].dump_monitor() | |
463 | dev[0].request("WPS_PBC") | |
464 | ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30) | |
465 | hapd.request("SET wps_version_number 0x20") | |
466 | if ev is None: | |
467 | raise Exception("Association with the AP timed out") |