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.
10 def test_wep_open_auth(dev, apdev):
11 """WEP Open System authentication"""
12 hapd = hostapd.add_ap(apdev[0]['ifname'],
14 "wep_key0": '"hello"' })
15 dev[0].flush_scan_cache()
16 dev[0].connect("wep-open", key_mgmt="NONE", wep_key0='"hello"',
18 hwsim_utils.test_connectivity(dev[0], hapd)
19 if "[WEP]" not in dev[0].request("SCAN_RESULTS"):
20 raise Exception("WEP flag not indicated in scan results")
22 bss = dev[0].get_bss(apdev[0]['bssid'])
23 if 'flags' not in bss:
24 raise Exception("Could not get BSS flags from BSS table")
25 if "[WEP]" not in bss['flags']:
26 raise Exception("Unexpected BSS flags: " + bss['flags'])
28 def test_wep_shared_key_auth(dev, apdev):
29 """WEP Shared Key authentication"""
30 hapd = hostapd.add_ap(apdev[0]['ifname'],
31 { "ssid": "wep-shared-key",
32 "wep_key0": '"hello12345678"',
34 dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
35 wep_key0='"hello12345678"',
37 hwsim_utils.test_connectivity(dev[0], hapd)
38 dev[1].connect("wep-shared-key", key_mgmt="NONE", auth_alg="OPEN SHARED",
39 wep_key0='"hello12345678"',
42 def test_wep_shared_key_auth_not_allowed(dev, apdev):
43 """WEP Shared Key authentication not allowed"""
44 hostapd.add_ap(apdev[0]['ifname'],
45 { "ssid": "wep-shared-key",
46 "wep_key0": '"hello12345678"',
48 dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
49 wep_key0='"hello12345678"',
50 scan_freq="2412", wait_connect=False)
51 ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
53 raise Exception("Unexpected association")
55 def test_wep_shared_key_auth_multi_key(dev, apdev):
56 """WEP Shared Key authentication with multiple keys"""
57 hapd = hostapd.add_ap(apdev[0]['ifname'],
58 { "ssid": "wep-shared-key",
59 "wep_key0": '"hello12345678"',
60 "wep_key1": '"other12345678"',
62 dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
63 wep_key0='"hello12345678"',
65 dev[1].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
66 wep_key0='"hello12345678"',
67 wep_key1='"other12345678"',
70 id = dev[2].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
71 wep_key0='"hello12345678"',
72 wep_key1='"other12345678"',
75 hwsim_utils.test_connectivity(dev[0], hapd)
76 hwsim_utils.test_connectivity(dev[1], hapd)
77 hwsim_utils.test_connectivity(dev[2], hapd)
79 dev[2].set_network(id, "wep_tx_keyidx", "1")
80 dev[2].request("REASSOCIATE")
81 dev[2].wait_connected(timeout=10, error="Reassociation timed out")
82 hwsim_utils.test_connectivity(dev[2], hapd)