]>
Commit | Line | Data |
---|---|---|
da102662 JM |
1 | # WEP tests |
2 | # Copyright (c) 2014, Jouni Malinen <j@w1.fi> | |
3 | # | |
4 | # This software may be distributed under the terms of the BSD license. | |
5 | # See README for more details. | |
6 | ||
9fd6804d | 7 | from remotehost import remote_compatible |
da102662 JM |
8 | import hostapd |
9 | import hwsim_utils | |
10 | ||
9fd6804d | 11 | @remote_compatible |
da102662 JM |
12 | def test_wep_open_auth(dev, apdev): |
13 | """WEP Open System authentication""" | |
8b8a1864 | 14 | hapd = hostapd.add_ap(apdev[0], |
a8375c94 JM |
15 | { "ssid": "wep-open", |
16 | "wep_key0": '"hello"' }) | |
1ca6d13d | 17 | dev[0].flush_scan_cache() |
da102662 JM |
18 | dev[0].connect("wep-open", key_mgmt="NONE", wep_key0='"hello"', |
19 | scan_freq="2412") | |
a8375c94 | 20 | hwsim_utils.test_connectivity(dev[0], hapd) |
91bc6c36 JM |
21 | if "[WEP]" not in dev[0].request("SCAN_RESULTS"): |
22 | raise Exception("WEP flag not indicated in scan results") | |
da102662 | 23 | |
d463c556 JM |
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']) | |
29 | ||
9fd6804d | 30 | @remote_compatible |
da102662 JM |
31 | def test_wep_shared_key_auth(dev, apdev): |
32 | """WEP Shared Key authentication""" | |
8b8a1864 | 33 | hapd = hostapd.add_ap(apdev[0], |
a8375c94 JM |
34 | { "ssid": "wep-shared-key", |
35 | "wep_key0": '"hello12345678"', | |
36 | "auth_algs": "2" }) | |
da102662 JM |
37 | dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED", |
38 | wep_key0='"hello12345678"', | |
39 | scan_freq="2412") | |
a8375c94 | 40 | hwsim_utils.test_connectivity(dev[0], hapd) |
da102662 JM |
41 | dev[1].connect("wep-shared-key", key_mgmt="NONE", auth_alg="OPEN SHARED", |
42 | wep_key0='"hello12345678"', | |
43 | scan_freq="2412") | |
44 | ||
9fd6804d | 45 | @remote_compatible |
da102662 JM |
46 | def test_wep_shared_key_auth_not_allowed(dev, apdev): |
47 | """WEP Shared Key authentication not allowed""" | |
8b8a1864 | 48 | hostapd.add_ap(apdev[0], |
da102662 JM |
49 | { "ssid": "wep-shared-key", |
50 | "wep_key0": '"hello12345678"', | |
51 | "auth_algs": "1" }) | |
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) | |
56 | if ev is not None: | |
57 | raise Exception("Unexpected association") | |
168d4b09 JM |
58 | |
59 | def test_wep_shared_key_auth_multi_key(dev, apdev): | |
60 | """WEP Shared Key authentication with multiple keys""" | |
8b8a1864 | 61 | hapd = hostapd.add_ap(apdev[0], |
168d4b09 JM |
62 | { "ssid": "wep-shared-key", |
63 | "wep_key0": '"hello12345678"', | |
64 | "wep_key1": '"other12345678"', | |
65 | "auth_algs": "2" }) | |
66 | dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED", | |
67 | wep_key0='"hello12345678"', | |
68 | scan_freq="2412") | |
69 | dev[1].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED", | |
70 | wep_key0='"hello12345678"', | |
71 | wep_key1='"other12345678"', | |
72 | wep_tx_keyidx="1", | |
73 | scan_freq="2412") | |
74 | id = dev[2].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED", | |
75 | wep_key0='"hello12345678"', | |
76 | wep_key1='"other12345678"', | |
77 | wep_tx_keyidx="0", | |
78 | scan_freq="2412") | |
79 | hwsim_utils.test_connectivity(dev[0], hapd) | |
80 | hwsim_utils.test_connectivity(dev[1], hapd) | |
81 | hwsim_utils.test_connectivity(dev[2], hapd) | |
82 | ||
83 | dev[2].set_network(id, "wep_tx_keyidx", "1") | |
84 | dev[2].request("REASSOCIATE") | |
5f35a5e2 | 85 | dev[2].wait_connected(timeout=10, error="Reassociation timed out") |
168d4b09 | 86 | hwsim_utils.test_connectivity(dev[2], hapd) |