]>
git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_ext_password.py
1 # External password storage
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
9 logger
= logging
.getLogger()
12 from utils
import skip_with_fips
13 from wpasupplicant
import WpaSupplicant
14 from test_ap_hs20
import hs20_ap_params
15 from test_ap_hs20
import interworking_select
16 from test_ap_hs20
import interworking_connect
19 def test_ext_password_psk(dev
, apdev
):
20 """External password storage for PSK"""
21 params
= hostapd
.wpa2_params(ssid
="ext-pw-psk", passphrase
="12345678")
22 hostapd
.add_ap(apdev
[0], params
)
23 dev
[0].request("SET ext_password_backend test:psk1=12345678")
24 dev
[0].connect("ext-pw-psk", raw_psk
="ext:psk1", scan_freq
="2412")
26 def test_ext_password_psk_not_found(dev
, apdev
):
27 """External password storage for PSK and PSK not found"""
28 params
= hostapd
.wpa2_params(ssid
="ext-pw-psk", passphrase
="12345678")
29 hostapd
.add_ap(apdev
[0], params
)
30 dev
[0].request("SET ext_password_backend test:psk1=12345678")
31 dev
[0].connect("ext-pw-psk", raw_psk
="ext:psk2", scan_freq
="2412",
33 dev
[1].request("SET ext_password_backend test:psk1=1234567")
34 dev
[1].connect("ext-pw-psk", raw_psk
="ext:psk1", scan_freq
="2412",
36 dev
[2].request("SET ext_password_backend test:psk1=1234567890123456789012345678901234567890123456789012345678901234567890")
37 dev
[2].connect("ext-pw-psk", raw_psk
="ext:psk1", scan_freq
="2412",
39 wpas
= WpaSupplicant(global_iface
='/tmp/wpas-wlan5')
40 wpas
.interface_add("wlan5")
41 wpas
.request("SET ext_password_backend test:psk1=123456789012345678901234567890123456789012345678901234567890123q")
42 wpas
.connect("ext-pw-psk", raw_psk
="ext:psk1", scan_freq
="2412",
45 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=1)
47 raise Exception("Unexpected association")
48 ev
= dev
[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=0.1)
50 raise Exception("Unexpected association")
51 ev
= dev
[2].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=0.1)
53 raise Exception("Unexpected association")
54 ev
= wpas
.wait_event(["CTRL-EVENT-CONNECTED"], timeout
=0.1)
56 raise Exception("Unexpected association")
58 def test_ext_password_eap(dev
, apdev
):
59 """External password storage for EAP password"""
60 params
= hostapd
.wpa2_eap_params(ssid
="ext-pw-eap")
61 hostapd
.add_ap(apdev
[0], params
)
62 dev
[0].request("SET ext_password_backend test:pw0=hello|pw1=password|pw2=secret")
63 dev
[0].connect("ext-pw-eap", key_mgmt
="WPA-EAP", eap
="PEAP",
64 identity
="user", password_hex
="ext:pw1",
65 ca_cert
="auth_serv/ca.pem", phase2
="auth=MSCHAPV2",
68 def test_ext_password_interworking(dev
, apdev
):
69 """External password storage for Interworking network selection"""
70 skip_with_fips(dev
[0])
71 bssid
= apdev
[0]['bssid']
72 params
= hs20_ap_params()
73 hostapd
.add_ap(apdev
[0], params
)
76 dev
[0].request("SET ext_password_backend test:pw1=password")
77 id = dev
[0].add_cred_values({'realm': "example.com",
78 'username': "hs20-test"})
79 dev
[0].set_cred(id, "password", "ext:pw1")
80 interworking_select(dev
[0], bssid
, freq
="2412")
81 interworking_connect(dev
[0], bssid
, "TTLS")