]>
Commit | Line | Data |
---|---|---|
1 | # WPA2-Personal tests | |
2 | # Copyright (c) 2014, Qualcomm Atheros, Inc. | |
3 | # | |
4 | # This software may be distributed under the terms of the BSD license. | |
5 | # See README for more details. | |
6 | ||
7 | import logging | |
8 | logger = logging.getLogger() | |
9 | ||
10 | import hostapd | |
11 | ||
12 | def test_ap_wpa2_psk(dev, apdev): | |
13 | """WPA2-PSK AP with PSK instead of passphrase""" | |
14 | ssid = "test-wpa2-psk" | |
15 | passphrase = 'qwertyuiop' | |
16 | psk = '602e323e077bc63bd80307ef4745b754b0ae0a925c2638ecd13a794b9527b9e6' | |
17 | params = hostapd.wpa2_params(ssid=ssid) | |
18 | params['wpa_psk'] = psk | |
19 | hostapd.add_ap(apdev[0]['ifname'], params) | |
20 | dev[0].connect(ssid, raw_psk=psk, scan_freq="2412") | |
21 | dev[1].connect(ssid, psk=passphrase, scan_freq="2412") | |
22 | ||
23 | def test_ap_wpa2_psk_file(dev, apdev): | |
24 | """WPA2-PSK AP with PSK from a file""" | |
25 | ssid = "test-wpa2-psk" | |
26 | passphrase = 'qwertyuiop' | |
27 | psk = '602e323e077bc63bd80307ef4745b754b0ae0a925c2638ecd13a794b9527b9e6' | |
28 | params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) | |
29 | params['wpa_psk_file'] = 'hostapd.wpa_psk' | |
30 | hostapd.add_ap(apdev[0]['ifname'], params) | |
31 | dev[1].connect(ssid, psk="very secret", scan_freq="2412", wait_connect=False) | |
32 | dev[2].connect(ssid, raw_psk=psk, scan_freq="2412") | |
33 | dev[2].request("REMOVE_NETWORK all") | |
34 | dev[0].connect(ssid, psk="very secret", scan_freq="2412") | |
35 | dev[0].request("REMOVE_NETWORK all") | |
36 | dev[2].connect(ssid, psk="another passphrase for all STAs", scan_freq="2412") | |
37 | dev[0].connect(ssid, psk="another passphrase for all STAs", scan_freq="2412") | |
38 | ev = dev[1].wait_event(["WPA: 4-Way Handshake failed"], timeout=10) | |
39 | if ev is None: | |
40 | raise Exception("Timed out while waiting for failure report") | |
41 | dev[1].request("REMOVE_NETWORK all") |