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.
7 from remotehost import remote_compatible
12 def test_wep_open_auth(dev, apdev):
13 """WEP Open System authentication"""
14 hapd = hostapd.add_ap(apdev[0],
16 "wep_key0": '"hello"' })
17 dev[0].flush_scan_cache()
18 dev[0].connect("wep-open", key_mgmt="NONE", wep_key0='"hello"',
20 hwsim_utils.test_connectivity(dev[0], hapd)
21 if "[WEP]" not in dev[0].request("SCAN_RESULTS"):
22 raise Exception("WEP flag not indicated in scan results")
24 bss = dev[0].get_bss(apdev[0]['bssid'])
25 if 'flags' not in bss:
26 raise Exception("Could not get BSS flags from BSS table")
27 if "[WEP]" not in bss['flags']:
28 raise Exception("Unexpected BSS flags: " + bss['flags'])
31 def test_wep_shared_key_auth(dev, apdev):
32 """WEP Shared Key authentication"""
33 hapd = hostapd.add_ap(apdev[0],
34 { "ssid": "wep-shared-key",
35 "wep_key0": '"hello12345678"',
37 dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
38 wep_key0='"hello12345678"',
40 hwsim_utils.test_connectivity(dev[0], hapd)
41 dev[1].connect("wep-shared-key", key_mgmt="NONE", auth_alg="OPEN SHARED",
42 wep_key0='"hello12345678"',
46 def test_wep_shared_key_auth_not_allowed(dev, apdev):
47 """WEP Shared Key authentication not allowed"""
48 hostapd.add_ap(apdev[0],
49 { "ssid": "wep-shared-key",
50 "wep_key0": '"hello12345678"',
52 dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
53 wep_key0='"hello12345678"',
54 scan_freq="2412", wait_connect=False)
55 ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
57 raise Exception("Unexpected association")
59 def test_wep_shared_key_auth_multi_key(dev, apdev):
60 """WEP Shared Key authentication with multiple keys"""
61 hapd = hostapd.add_ap(apdev[0],
62 { "ssid": "wep-shared-key",
63 "wep_key0": '"hello12345678"',
64 "wep_key1": '"other12345678"',
66 dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
67 wep_key0='"hello12345678"',
69 dev[1].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
70 wep_key0='"hello12345678"',
71 wep_key1='"other12345678"',
74 id = dev[2].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
75 wep_key0='"hello12345678"',
76 wep_key1='"other12345678"',
79 hwsim_utils.test_connectivity(dev[0], hapd)
80 hwsim_utils.test_connectivity(dev[1], hapd)
81 hwsim_utils.test_connectivity(dev[2], hapd)
83 dev[2].set_network(id, "wep_tx_keyidx", "1")
84 dev[2].request("REASSOCIATE")
85 dev[2].wait_connected(timeout=10, error="Reassociation timed out")
86 hwsim_utils.test_connectivity(dev[2], hapd)