From 33de4f2d7a48f80bbde82b99aef4298e647bfc87 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 7 Jan 2014 20:44:41 +0200 Subject: [PATCH] tests: External password storage Signed-hostap: Jouni Malinen --- tests/hwsim/test_ext_password.py | 46 ++++++++++++++++++++++++++++++++ tests/hwsim/wpasupplicant.py | 4 ++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tests/hwsim/test_ext_password.py diff --git a/tests/hwsim/test_ext_password.py b/tests/hwsim/test_ext_password.py new file mode 100644 index 000000000..56481e18a --- /dev/null +++ b/tests/hwsim/test_ext_password.py @@ -0,0 +1,46 @@ +#!/usr/bin/python +# +# External password storage +# Copyright (c) 2014, Jouni Malinen +# +# This software may be distributed under the terms of the BSD license. +# See README for more details. + +import logging +logger = logging.getLogger() + +import hostapd +from test_ap_hs20 import hs20_ap_params +from test_ap_hs20 import interworking_select +from test_ap_hs20 import interworking_connect + +def test_ext_password_psk(dev, apdev): + """External password storage for PSK""" + params = hostapd.wpa2_params(ssid="ext-pw-psk", passphrase="12345678") + hostapd.add_ap(apdev[0]['ifname'], params) + dev[0].request("SET ext_password_backend test:psk1=12345678") + dev[0].connect("ext-pw-psk", raw_psk="ext:psk1", scan_freq="2412") + +def test_ext_password_eap(dev, apdev): + """External password storage for EAP password""" + params = hostapd.wpa2_eap_params(ssid="ext-pw-eap") + hostapd.add_ap(apdev[0]['ifname'], params) + dev[0].request("SET ext_password_backend test:pw0=hello|pw1=password|pw2=secret") + dev[0].connect("ext-pw-eap", key_mgmt="WPA-EAP", eap="PEAP", + identity="user", password_hex="ext:pw1", + ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2", + scan_freq="2412") + +def test_ext_password_interworking(dev, apdev): + """External password storage for Interworking network selection""" + bssid = apdev[0]['bssid'] + params = hs20_ap_params() + hostapd.add_ap(apdev[0]['ifname'], params) + + dev[0].hs20_enable() + dev[0].request("SET ext_password_backend test:pw1=password") + id = dev[0].add_cred_values({ 'realm': "example.com", + 'username': "hs20-test" }) + dev[0].set_cred(id, "password", "ext:pw1") + interworking_select(dev[0], bssid, freq="2412") + interworking_connect(dev[0], bssid, "TTLS") diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index c33041e72..6e7fdf746 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -571,7 +571,7 @@ class WpaSupplicant: eapol_flags=None, fragment_size=None, wait_connect=True, only_add_network=False, ca_cert2=None, client_cert2=None, private_key2=None, - scan_ssid=None): + scan_ssid=None, raw_psk=None): logger.info("Connect STA " + self.ifname + " to AP") id = self.add_network() if ssid: @@ -580,6 +580,8 @@ class WpaSupplicant: self.set_network(id, "ssid", ssid2) if psk: self.set_network_quoted(id, "psk", psk) + if raw_psk: + self.set_network(id, "psk", raw_psk) if proto: self.set_network(id, "proto", proto) if key_mgmt: