2 # Copyright (c) 2014, Jouni Malinen <j@w1.fi>
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
8 logger = logging.getLogger()
11 from remotehost import remote_compatible
16 def test_wep_open_auth(dev, apdev):
17 """WEP Open System authentication"""
18 hapd = hostapd.add_ap(apdev[0],
20 "wep_key0": '"hello"' })
21 dev[0].flush_scan_cache()
22 dev[0].connect("wep-open", key_mgmt="NONE", wep_key0='"hello"',
24 hwsim_utils.test_connectivity(dev[0], hapd)
25 if "[WEP]" not in dev[0].request("SCAN_RESULTS"):
26 raise Exception("WEP flag not indicated in scan results")
28 bss = dev[0].get_bss(apdev[0]['bssid'])
29 if 'flags' not in bss:
30 raise Exception("Could not get BSS flags from BSS table")
31 if "[WEP]" not in bss['flags']:
32 raise Exception("Unexpected BSS flags: " + bss['flags'])
35 def test_wep_shared_key_auth(dev, apdev):
36 """WEP Shared Key authentication"""
37 hapd = hostapd.add_ap(apdev[0],
38 { "ssid": "wep-shared-key",
39 "wep_key0": '"hello12345678"',
41 dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
42 wep_key0='"hello12345678"',
44 hwsim_utils.test_connectivity(dev[0], hapd)
45 dev[1].connect("wep-shared-key", key_mgmt="NONE", auth_alg="OPEN SHARED",
46 wep_key0='"hello12345678"',
50 def test_wep_shared_key_auth_not_allowed(dev, apdev):
51 """WEP Shared Key authentication not allowed"""
52 hostapd.add_ap(apdev[0],
53 { "ssid": "wep-shared-key",
54 "wep_key0": '"hello12345678"',
56 dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
57 wep_key0='"hello12345678"',
58 scan_freq="2412", wait_connect=False)
59 ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
61 raise Exception("Unexpected association")
63 def test_wep_shared_key_auth_multi_key(dev, apdev):
64 """WEP Shared Key authentication with multiple keys"""
65 hapd = hostapd.add_ap(apdev[0],
66 { "ssid": "wep-shared-key",
67 "wep_key0": '"hello12345678"',
68 "wep_key1": '"other12345678"',
70 dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
71 wep_key0='"hello12345678"',
73 dev[1].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
74 wep_key0='"hello12345678"',
75 wep_key1='"other12345678"',
78 id = dev[2].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
79 wep_key0='"hello12345678"',
80 wep_key1='"other12345678"',
83 hwsim_utils.test_connectivity(dev[0], hapd)
84 hwsim_utils.test_connectivity(dev[1], hapd)
85 hwsim_utils.test_connectivity(dev[2], hapd)
87 dev[2].set_network(id, "wep_tx_keyidx", "1")
88 dev[2].request("REASSOCIATE")
89 dev[2].wait_connected(timeout=10, error="Reassociation timed out")
90 hwsim_utils.test_connectivity(dev[2], hapd)
92 def test_wep_ht_vht(dev, apdev):
94 dev[0].flush_scan_cache()
97 params = { "ssid": "test-vht40-wep",
103 "ht_capab": "[HT40+]",
105 "vht_oper_chwidth": "0",
106 "vht_oper_centr_freq_seg0_idx": "0",
107 "wep_key0": '"hello"' }
108 hapd = hostapd.add_ap(apdev[0], params)
109 dev[0].connect("test-vht40-wep", scan_freq="5180", key_mgmt="NONE",
111 hwsim_utils.test_connectivity(dev[0], hapd)
112 status = hapd.get_status()
113 logger.info("hostapd STATUS: " + str(status))
114 if status["ieee80211n"] != "0":
115 raise Exception("Unexpected STATUS ieee80211n value")
116 if status["ieee80211ac"] != "0":
117 raise Exception("Unexpected STATUS ieee80211ac value")
118 if status["secondary_channel"] != "0":
119 raise Exception("Unexpected STATUS secondary_channel value")
121 dev[0].request("DISCONNECT")
123 hapd.request("DISABLE")
124 subprocess.call(['iw', 'reg', 'set', '00'])
125 dev[0].flush_scan_cache()