]>
git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_wep.py
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
14 from utils
import clear_regdom
17 def test_wep_open_auth(dev
, apdev
):
18 """WEP Open System authentication"""
19 hapd
= hostapd
.add_ap(apdev
[0],
21 "wep_key0": '"hello"'})
22 dev
[0].flush_scan_cache()
23 dev
[0].connect("wep-open", key_mgmt
="NONE", wep_key0
='"hello"',
25 hwsim_utils
.test_connectivity(dev
[0], hapd
)
26 if "[WEP]" not in dev
[0].request("SCAN_RESULTS"):
27 raise Exception("WEP flag not indicated in scan results")
29 bss
= dev
[0].get_bss(apdev
[0]['bssid'])
30 if 'flags' not in bss
:
31 raise Exception("Could not get BSS flags from BSS table")
32 if "[WEP]" not in bss
['flags']:
33 raise Exception("Unexpected BSS flags: " + bss
['flags'])
36 def test_wep_shared_key_auth(dev
, apdev
):
37 """WEP Shared Key authentication"""
38 hapd
= hostapd
.add_ap(apdev
[0],
39 {"ssid": "wep-shared-key",
40 "wep_key0": '"hello12345678"',
42 dev
[0].connect("wep-shared-key", key_mgmt
="NONE", auth_alg
="SHARED",
43 wep_key0
='"hello12345678"',
45 hwsim_utils
.test_connectivity(dev
[0], hapd
)
46 dev
[1].connect("wep-shared-key", key_mgmt
="NONE", auth_alg
="OPEN SHARED",
47 wep_key0
='"hello12345678"',
51 def test_wep_shared_key_auth_not_allowed(dev
, apdev
):
52 """WEP Shared Key authentication not allowed"""
53 hostapd
.add_ap(apdev
[0],
54 {"ssid": "wep-shared-key",
55 "wep_key0": '"hello12345678"',
57 dev
[0].connect("wep-shared-key", key_mgmt
="NONE", auth_alg
="SHARED",
58 wep_key0
='"hello12345678"',
59 scan_freq
="2412", wait_connect
=False)
60 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=1)
62 raise Exception("Unexpected association")
64 def test_wep_shared_key_auth_multi_key(dev
, apdev
):
65 """WEP Shared Key authentication with multiple keys"""
66 hapd
= hostapd
.add_ap(apdev
[0],
67 {"ssid": "wep-shared-key",
68 "wep_key0": '"hello12345678"',
69 "wep_key1": '"other12345678"',
71 dev
[0].connect("wep-shared-key", key_mgmt
="NONE", auth_alg
="SHARED",
72 wep_key0
='"hello12345678"',
74 dev
[1].connect("wep-shared-key", key_mgmt
="NONE", auth_alg
="SHARED",
75 wep_key0
='"hello12345678"',
76 wep_key1
='"other12345678"',
79 id = dev
[2].connect("wep-shared-key", key_mgmt
="NONE", auth_alg
="SHARED",
80 wep_key0
='"hello12345678"',
81 wep_key1
='"other12345678"',
84 hwsim_utils
.test_connectivity(dev
[0], hapd
)
85 hwsim_utils
.test_connectivity(dev
[1], hapd
)
86 hwsim_utils
.test_connectivity(dev
[2], hapd
)
88 dev
[2].set_network(id, "wep_tx_keyidx", "1")
89 dev
[2].request("REASSOCIATE")
90 dev
[2].wait_connected(timeout
=10, error
="Reassociation timed out")
91 hwsim_utils
.test_connectivity(dev
[2], hapd
)
93 def test_wep_ht_vht(dev
, apdev
):
95 dev
[0].flush_scan_cache()
98 params
= {"ssid": "test-vht40-wep",
104 "ht_capab": "[HT40+]",
106 "vht_oper_chwidth": "0",
107 "vht_oper_centr_freq_seg0_idx": "0",
108 "wep_key0": '"hello"'}
109 hapd
= hostapd
.add_ap(apdev
[0], params
)
110 dev
[0].connect("test-vht40-wep", scan_freq
="5180", key_mgmt
="NONE",
112 hwsim_utils
.test_connectivity(dev
[0], hapd
)
113 status
= hapd
.get_status()
114 logger
.info("hostapd STATUS: " + str(status
))
115 if status
["ieee80211n"] != "0":
116 raise Exception("Unexpected STATUS ieee80211n value")
117 if status
["ieee80211ac"] != "0":
118 raise Exception("Unexpected STATUS ieee80211ac value")
119 if status
["secondary_channel"] != "0":
120 raise Exception("Unexpected STATUS secondary_channel value")
122 dev
[0].request("DISCONNECT")
123 clear_regdom(hapd
, dev
)
125 def test_wep_ifdown(dev
, apdev
):
126 """AP with WEP and external ifconfig down"""
127 hapd
= hostapd
.add_ap(apdev
[0],
129 "wep_key0": '"hello"'})
130 dev
[0].flush_scan_cache()
131 id = dev
[0].connect("wep-open", key_mgmt
="NONE", wep_key0
='"hello"',
133 hwsim_utils
.test_connectivity(dev
[0], hapd
)
134 dev
[0].request("DISCONNECT")
135 dev
[0].wait_disconnected()
137 hapd
.cmd_execute(['ip', 'link', 'set', 'dev', apdev
[0]['ifname'], 'down'])
138 ev
= hapd
.wait_event(["INTERFACE-DISABLED"], timeout
=10)
140 raise Exception("No INTERFACE-DISABLED event")
141 hapd
.cmd_execute(['ip', 'link', 'set', 'dev', apdev
[0]['ifname'], 'up'])
142 ev
= hapd
.wait_event(["INTERFACE-ENABLED"], timeout
=10)
144 raise Exception("No INTERFACE-ENABLED event")
145 dev
[0].select_network(id, freq
=2412)
146 dev
[0].wait_connected()
147 hwsim_utils
.test_connectivity(dev
[0], hapd
)