2013-05-24 15:05:40 +02:00
|
|
|
# Fast BSS Transition tests
|
2014-05-17 09:44:41 +02:00
|
|
|
# Copyright (c) 2013-2014, Jouni Malinen <j@w1.fi>
|
2013-05-24 15:05:40 +02:00
|
|
|
#
|
|
|
|
# This software may be distributed under the terms of the BSD license.
|
|
|
|
# See README for more details.
|
|
|
|
|
|
|
|
import time
|
|
|
|
import subprocess
|
|
|
|
import logging
|
2013-10-31 11:46:42 +01:00
|
|
|
logger = logging.getLogger()
|
2013-05-24 15:05:40 +02:00
|
|
|
|
|
|
|
import hwsim_utils
|
|
|
|
import hostapd
|
|
|
|
from wlantest import Wlantest
|
2014-04-05 22:56:03 +02:00
|
|
|
from test_ap_psk import check_mib
|
2013-05-24 15:05:40 +02:00
|
|
|
|
|
|
|
def ft_base_rsn():
|
|
|
|
params = { "wpa": "2",
|
|
|
|
"wpa_key_mgmt": "FT-PSK",
|
|
|
|
"rsn_pairwise": "CCMP" }
|
|
|
|
return params
|
|
|
|
|
|
|
|
def ft_base_mixed():
|
|
|
|
params = { "wpa": "3",
|
|
|
|
"wpa_key_mgmt": "WPA-PSK FT-PSK",
|
|
|
|
"wpa_pairwise": "TKIP",
|
|
|
|
"rsn_pairwise": "CCMP" }
|
|
|
|
return params
|
|
|
|
|
|
|
|
def ft_params(rsn=True, ssid=None, passphrase=None):
|
|
|
|
if rsn:
|
|
|
|
params = ft_base_rsn()
|
|
|
|
else:
|
|
|
|
params = ft_base_mixed()
|
|
|
|
if ssid:
|
|
|
|
params["ssid"] = ssid
|
|
|
|
if passphrase:
|
|
|
|
params["wpa_passphrase"] = passphrase
|
|
|
|
|
|
|
|
params["mobility_domain"] = "a1b2"
|
|
|
|
params["r0_key_lifetime"] = "10000"
|
|
|
|
params["pmk_r1_push"] = "1"
|
|
|
|
params["reassociation_deadline"] = "1000"
|
|
|
|
return params
|
|
|
|
|
|
|
|
def ft_params1(rsn=True, ssid=None, passphrase=None):
|
|
|
|
params = ft_params(rsn, ssid, passphrase)
|
|
|
|
params['nas_identifier'] = "nas1.w1.fi"
|
|
|
|
params['r1_key_holder'] = "000102030405"
|
|
|
|
params['r0kh'] = [ "02:00:00:00:03:00 nas1.w1.fi 100102030405060708090a0b0c0d0e0f",
|
|
|
|
"02:00:00:00:04:00 nas2.w1.fi 300102030405060708090a0b0c0d0e0f" ]
|
|
|
|
params['r1kh'] = "02:00:00:00:04:00 00:01:02:03:04:06 200102030405060708090a0b0c0d0e0f"
|
|
|
|
return params
|
|
|
|
|
|
|
|
def ft_params2(rsn=True, ssid=None, passphrase=None):
|
|
|
|
params = ft_params(rsn, ssid, passphrase)
|
|
|
|
params['nas_identifier'] = "nas2.w1.fi"
|
|
|
|
params['r1_key_holder'] = "000102030406"
|
|
|
|
params['r0kh'] = [ "02:00:00:00:03:00 nas1.w1.fi 200102030405060708090a0b0c0d0e0f",
|
|
|
|
"02:00:00:00:04:00 nas2.w1.fi 000102030405060708090a0b0c0d0e0f" ]
|
|
|
|
params['r1kh'] = "02:00:00:00:03:00 00:01:02:03:04:05 300102030405060708090a0b0c0d0e0f"
|
|
|
|
return params
|
|
|
|
|
2014-03-23 18:23:16 +01:00
|
|
|
def ft_params1_r0kh_mismatch(rsn=True, ssid=None, passphrase=None):
|
|
|
|
params = ft_params(rsn, ssid, passphrase)
|
|
|
|
params['nas_identifier'] = "nas1.w1.fi"
|
|
|
|
params['r1_key_holder'] = "000102030405"
|
|
|
|
params['r0kh'] = [ "02:00:00:00:03:00 nas1.w1.fi 100102030405060708090a0b0c0d0e0f",
|
|
|
|
"12:00:00:00:04:00 nas2.w1.fi 300102030405060708090a0b0c0d0e0f" ]
|
|
|
|
params['r1kh'] = "12:00:00:00:04:00 10:01:02:03:04:06 200102030405060708090a0b0c0d0e0f"
|
|
|
|
return params
|
|
|
|
|
|
|
|
def ft_params2_incorrect_rrb_key(rsn=True, ssid=None, passphrase=None):
|
|
|
|
params = ft_params(rsn, ssid, passphrase)
|
|
|
|
params['nas_identifier'] = "nas2.w1.fi"
|
|
|
|
params['r1_key_holder'] = "000102030406"
|
|
|
|
params['r0kh'] = [ "02:00:00:00:03:00 nas1.w1.fi 200102030405060708090a0b0c0d0ef1",
|
|
|
|
"02:00:00:00:04:00 nas2.w1.fi 000102030405060708090a0b0c0d0ef2" ]
|
|
|
|
params['r1kh'] = "02:00:00:00:03:00 00:01:02:03:04:05 300102030405060708090a0b0c0d0ef3"
|
|
|
|
return params
|
|
|
|
|
|
|
|
def ft_params2_r0kh_mismatch(rsn=True, ssid=None, passphrase=None):
|
|
|
|
params = ft_params(rsn, ssid, passphrase)
|
|
|
|
params['nas_identifier'] = "nas2.w1.fi"
|
|
|
|
params['r1_key_holder'] = "000102030406"
|
|
|
|
params['r0kh'] = [ "12:00:00:00:03:00 nas1.w1.fi 200102030405060708090a0b0c0d0e0f",
|
|
|
|
"02:00:00:00:04:00 nas2.w1.fi 000102030405060708090a0b0c0d0e0f" ]
|
|
|
|
params['r1kh'] = "12:00:00:00:03:00 10:01:02:03:04:05 300102030405060708090a0b0c0d0e0f"
|
|
|
|
return params
|
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
def run_roams(dev, apdev, hapd0, hapd1, ssid, passphrase, over_ds=False, sae=False, eap=False, fail_test=False, roams=1):
|
2013-05-24 15:05:40 +02:00
|
|
|
logger.info("Connect to first AP")
|
2013-12-28 12:51:09 +01:00
|
|
|
if eap:
|
|
|
|
dev.connect(ssid, key_mgmt="FT-EAP", proto="WPA2", ieee80211w="1",
|
|
|
|
eap="EKE", identity="eke user", password="hello")
|
2013-12-28 12:42:43 +01:00
|
|
|
else:
|
2013-12-28 12:51:09 +01:00
|
|
|
if sae:
|
|
|
|
key_mgmt="FT-SAE"
|
|
|
|
else:
|
|
|
|
key_mgmt="FT-PSK"
|
|
|
|
dev.connect(ssid, psk=passphrase, key_mgmt=key_mgmt, proto="WPA2",
|
|
|
|
ieee80211w="1")
|
2013-05-24 15:05:40 +02:00
|
|
|
if dev.get_status_field('bssid') == apdev[0]['bssid']:
|
|
|
|
ap1 = apdev[0]
|
|
|
|
ap2 = apdev[1]
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd1ap = hapd0
|
|
|
|
hapd2ap = hapd1
|
2013-05-24 15:05:40 +02:00
|
|
|
else:
|
|
|
|
ap1 = apdev[1]
|
|
|
|
ap2 = apdev[0]
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd1ap = hapd1
|
|
|
|
hapd2ap = hapd0
|
|
|
|
hwsim_utils.test_connectivity(dev, hapd1ap)
|
2013-05-24 15:05:40 +02:00
|
|
|
|
2014-05-14 16:02:32 +02:00
|
|
|
dev.scan_for_bss(ap2['bssid'], freq="2412")
|
2014-06-01 14:48:48 +02:00
|
|
|
|
|
|
|
for i in range(0, roams):
|
|
|
|
logger.info("Roam to the second AP")
|
|
|
|
if over_ds:
|
|
|
|
dev.roam_over_ds(ap2['bssid'], fail_test=fail_test)
|
|
|
|
else:
|
|
|
|
dev.roam(ap2['bssid'], fail_test=fail_test)
|
|
|
|
if fail_test:
|
|
|
|
return
|
|
|
|
if dev.get_status_field('bssid') != ap2['bssid']:
|
|
|
|
raise Exception("Did not connect to correct AP")
|
|
|
|
if i == 0 or i == roams - 1:
|
2014-10-19 16:54:49 +02:00
|
|
|
hwsim_utils.test_connectivity(dev, hapd2ap)
|
2014-06-01 14:48:48 +02:00
|
|
|
|
|
|
|
logger.info("Roam back to the first AP")
|
|
|
|
if over_ds:
|
|
|
|
dev.roam_over_ds(ap1['bssid'])
|
|
|
|
else:
|
|
|
|
dev.roam(ap1['bssid'])
|
|
|
|
if dev.get_status_field('bssid') != ap1['bssid']:
|
|
|
|
raise Exception("Did not connect to correct AP")
|
|
|
|
if i == 0 or i == roams - 1:
|
2014-10-19 16:54:49 +02:00
|
|
|
hwsim_utils.test_connectivity(dev, hapd1ap)
|
2013-05-24 15:05:40 +02:00
|
|
|
|
|
|
|
def test_ap_ft(dev, apdev):
|
|
|
|
"""WPA2-PSK-FT AP"""
|
|
|
|
ssid = "test-ft"
|
|
|
|
passphrase="12345678"
|
|
|
|
|
|
|
|
params = ft_params1(ssid=ssid, passphrase=passphrase)
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
|
2013-05-24 15:05:40 +02:00
|
|
|
params = ft_params2(ssid=ssid, passphrase=passphrase)
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
|
2013-05-24 15:05:40 +02:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase)
|
2014-04-26 16:18:37 +02:00
|
|
|
if "[WPA2-FT/PSK-CCMP]" not in dev[0].request("SCAN_RESULTS"):
|
|
|
|
raise Exception("Scan results missing RSN element info")
|
2013-05-24 15:05:40 +02:00
|
|
|
|
2014-06-01 14:48:48 +02:00
|
|
|
def test_ap_ft_many(dev, apdev):
|
|
|
|
"""WPA2-PSK-FT AP multiple times"""
|
|
|
|
ssid = "test-ft"
|
|
|
|
passphrase="12345678"
|
|
|
|
|
|
|
|
params = ft_params1(ssid=ssid, passphrase=passphrase)
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
|
2014-06-01 14:48:48 +02:00
|
|
|
params = ft_params2(ssid=ssid, passphrase=passphrase)
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
|
2014-06-01 14:48:48 +02:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, roams=50)
|
2014-06-01 14:48:48 +02:00
|
|
|
|
2013-05-24 15:05:40 +02:00
|
|
|
def test_ap_ft_mixed(dev, apdev):
|
|
|
|
"""WPA2-PSK-FT mixed-mode AP"""
|
|
|
|
ssid = "test-ft-mixed"
|
|
|
|
passphrase="12345678"
|
|
|
|
|
|
|
|
params = ft_params1(rsn=False, ssid=ssid, passphrase=passphrase)
|
2014-03-22 17:57:44 +01:00
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
key_mgmt = hapd.get_config()['key_mgmt']
|
|
|
|
vals = key_mgmt.split(' ')
|
|
|
|
if vals[0] != "WPA-PSK" or vals[1] != "FT-PSK":
|
|
|
|
raise Exception("Unexpected GET_CONFIG(key_mgmt): " + key_mgmt)
|
2013-05-24 15:05:40 +02:00
|
|
|
params = ft_params2(rsn=False, ssid=ssid, passphrase=passphrase)
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
|
2013-05-24 15:05:40 +02:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
run_roams(dev[0], apdev, hapd, hapd1, ssid, passphrase)
|
2013-05-24 15:05:40 +02:00
|
|
|
|
|
|
|
def test_ap_ft_pmf(dev, apdev):
|
|
|
|
"""WPA2-PSK-FT AP with PMF"""
|
|
|
|
ssid = "test-ft"
|
|
|
|
passphrase="12345678"
|
|
|
|
|
|
|
|
params = ft_params1(ssid=ssid, passphrase=passphrase)
|
|
|
|
params["ieee80211w"] = "2";
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
|
2013-05-24 15:05:40 +02:00
|
|
|
params = ft_params2(ssid=ssid, passphrase=passphrase)
|
|
|
|
params["ieee80211w"] = "2";
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
|
2013-05-24 15:05:40 +02:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase)
|
2013-12-28 10:52:19 +01:00
|
|
|
|
|
|
|
def test_ap_ft_over_ds(dev, apdev):
|
|
|
|
"""WPA2-PSK-FT AP over DS"""
|
|
|
|
ssid = "test-ft"
|
|
|
|
passphrase="12345678"
|
|
|
|
|
|
|
|
params = ft_params1(ssid=ssid, passphrase=passphrase)
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
|
2013-12-28 10:52:19 +01:00
|
|
|
params = ft_params2(ssid=ssid, passphrase=passphrase)
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
|
2013-12-28 10:52:19 +01:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True)
|
2014-04-05 22:56:03 +02:00
|
|
|
check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-4"),
|
|
|
|
("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-4") ])
|
2013-12-28 10:52:19 +01:00
|
|
|
|
2014-06-01 14:48:48 +02:00
|
|
|
def test_ap_ft_over_ds_many(dev, apdev):
|
|
|
|
"""WPA2-PSK-FT AP over DS multiple times"""
|
|
|
|
ssid = "test-ft"
|
|
|
|
passphrase="12345678"
|
|
|
|
|
|
|
|
params = ft_params1(ssid=ssid, passphrase=passphrase)
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
|
2014-06-01 14:48:48 +02:00
|
|
|
params = ft_params2(ssid=ssid, passphrase=passphrase)
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
|
2014-06-01 14:48:48 +02:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True,
|
|
|
|
roams=50)
|
2014-06-01 14:48:48 +02:00
|
|
|
|
2013-12-28 10:52:19 +01:00
|
|
|
def test_ap_ft_pmf_over_ds(dev, apdev):
|
|
|
|
"""WPA2-PSK-FT AP over DS with PMF"""
|
|
|
|
ssid = "test-ft"
|
|
|
|
passphrase="12345678"
|
|
|
|
|
|
|
|
params = ft_params1(ssid=ssid, passphrase=passphrase)
|
|
|
|
params["ieee80211w"] = "2";
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
|
2013-12-28 10:52:19 +01:00
|
|
|
params = ft_params2(ssid=ssid, passphrase=passphrase)
|
|
|
|
params["ieee80211w"] = "2";
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
|
2013-12-28 10:52:19 +01:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True)
|
2013-12-28 12:42:43 +01:00
|
|
|
|
2014-03-23 17:31:58 +01:00
|
|
|
def test_ap_ft_over_ds_pull(dev, apdev):
|
|
|
|
"""WPA2-PSK-FT AP over DS (pull PMK)"""
|
|
|
|
ssid = "test-ft"
|
|
|
|
passphrase="12345678"
|
|
|
|
|
|
|
|
params = ft_params1(ssid=ssid, passphrase=passphrase)
|
|
|
|
params["pmk_r1_push"] = "0"
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
|
2014-03-23 17:31:58 +01:00
|
|
|
params = ft_params2(ssid=ssid, passphrase=passphrase)
|
|
|
|
params["pmk_r1_push"] = "0"
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
|
2014-03-23 17:31:58 +01:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True)
|
2014-03-23 17:31:58 +01:00
|
|
|
|
2013-12-28 12:42:43 +01:00
|
|
|
def test_ap_ft_sae(dev, apdev):
|
|
|
|
"""WPA2-PSK-FT-SAE AP"""
|
|
|
|
ssid = "test-ft"
|
|
|
|
passphrase="12345678"
|
|
|
|
|
|
|
|
params = ft_params1(ssid=ssid, passphrase=passphrase)
|
|
|
|
params['wpa_key_mgmt'] = "FT-SAE"
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
|
2013-12-28 12:42:43 +01:00
|
|
|
params = ft_params2(ssid=ssid, passphrase=passphrase)
|
|
|
|
params['wpa_key_mgmt'] = "FT-SAE"
|
2014-03-22 17:57:44 +01:00
|
|
|
hapd = hostapd.add_ap(apdev[1]['ifname'], params)
|
|
|
|
key_mgmt = hapd.get_config()['key_mgmt']
|
|
|
|
if key_mgmt.split(' ')[0] != "FT-SAE":
|
|
|
|
raise Exception("Unexpected GET_CONFIG(key_mgmt): " + key_mgmt)
|
2013-12-28 12:42:43 +01:00
|
|
|
|
2014-11-25 14:19:19 +01:00
|
|
|
dev[0].request("SET sae_groups ")
|
2014-10-19 16:54:49 +02:00
|
|
|
run_roams(dev[0], apdev, hapd0, hapd, ssid, passphrase, sae=True)
|
2013-12-28 12:42:43 +01:00
|
|
|
|
|
|
|
def test_ap_ft_sae_over_ds(dev, apdev):
|
|
|
|
"""WPA2-PSK-FT-SAE AP over DS"""
|
|
|
|
ssid = "test-ft"
|
|
|
|
passphrase="12345678"
|
|
|
|
|
|
|
|
params = ft_params1(ssid=ssid, passphrase=passphrase)
|
|
|
|
params['wpa_key_mgmt'] = "FT-SAE"
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
|
2013-12-28 12:42:43 +01:00
|
|
|
params = ft_params2(ssid=ssid, passphrase=passphrase)
|
|
|
|
params['wpa_key_mgmt'] = "FT-SAE"
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
|
2013-12-28 12:42:43 +01:00
|
|
|
|
2014-11-25 14:19:19 +01:00
|
|
|
dev[0].request("SET sae_groups ")
|
2014-10-19 16:54:49 +02:00
|
|
|
run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, sae=True,
|
|
|
|
over_ds=True)
|
2013-12-28 12:51:09 +01:00
|
|
|
|
|
|
|
def test_ap_ft_eap(dev, apdev):
|
|
|
|
"""WPA2-EAP-FT AP"""
|
|
|
|
ssid = "test-ft"
|
|
|
|
passphrase="12345678"
|
|
|
|
|
|
|
|
radius = hostapd.radius_params()
|
|
|
|
params = ft_params1(ssid=ssid, passphrase=passphrase)
|
|
|
|
params['wpa_key_mgmt'] = "FT-EAP"
|
|
|
|
params["ieee8021x"] = "1"
|
|
|
|
params = dict(radius.items() + params.items())
|
2014-03-22 17:57:44 +01:00
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
key_mgmt = hapd.get_config()['key_mgmt']
|
|
|
|
if key_mgmt.split(' ')[0] != "FT-EAP":
|
|
|
|
raise Exception("Unexpected GET_CONFIG(key_mgmt): " + key_mgmt)
|
2013-12-28 12:51:09 +01:00
|
|
|
params = ft_params2(ssid=ssid, passphrase=passphrase)
|
|
|
|
params['wpa_key_mgmt'] = "FT-EAP"
|
|
|
|
params["ieee8021x"] = "1"
|
|
|
|
params = dict(radius.items() + params.items())
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
|
2013-12-28 12:51:09 +01:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
run_roams(dev[0], apdev, hapd, hapd1, ssid, passphrase, eap=True)
|
2014-04-26 16:18:37 +02:00
|
|
|
if "[WPA2-FT/EAP-CCMP]" not in dev[0].request("SCAN_RESULTS"):
|
|
|
|
raise Exception("Scan results missing RSN element info")
|
2014-04-05 22:56:03 +02:00
|
|
|
check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-3"),
|
|
|
|
("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-3") ])
|
2014-03-23 17:31:58 +01:00
|
|
|
|
|
|
|
def test_ap_ft_eap_pull(dev, apdev):
|
|
|
|
"""WPA2-EAP-FT AP (pull PMK)"""
|
|
|
|
ssid = "test-ft"
|
|
|
|
passphrase="12345678"
|
|
|
|
|
|
|
|
radius = hostapd.radius_params()
|
|
|
|
params = ft_params1(ssid=ssid, passphrase=passphrase)
|
|
|
|
params['wpa_key_mgmt'] = "FT-EAP"
|
|
|
|
params["ieee8021x"] = "1"
|
|
|
|
params["pmk_r1_push"] = "0"
|
|
|
|
params = dict(radius.items() + params.items())
|
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
key_mgmt = hapd.get_config()['key_mgmt']
|
|
|
|
if key_mgmt.split(' ')[0] != "FT-EAP":
|
|
|
|
raise Exception("Unexpected GET_CONFIG(key_mgmt): " + key_mgmt)
|
|
|
|
params = ft_params2(ssid=ssid, passphrase=passphrase)
|
|
|
|
params['wpa_key_mgmt'] = "FT-EAP"
|
|
|
|
params["ieee8021x"] = "1"
|
|
|
|
params["pmk_r1_push"] = "0"
|
|
|
|
params = dict(radius.items() + params.items())
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
|
2014-03-23 17:31:58 +01:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
run_roams(dev[0], apdev, hapd, hapd1, ssid, passphrase, eap=True)
|
2014-03-23 18:23:16 +01:00
|
|
|
|
|
|
|
def test_ap_ft_mismatching_rrb_key_push(dev, apdev):
|
|
|
|
"""WPA2-PSK-FT AP over DS with mismatching RRB key (push)"""
|
|
|
|
ssid = "test-ft"
|
|
|
|
passphrase="12345678"
|
|
|
|
|
|
|
|
params = ft_params1(ssid=ssid, passphrase=passphrase)
|
|
|
|
params["ieee80211w"] = "2";
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
|
2014-03-23 18:23:16 +01:00
|
|
|
params = ft_params2_incorrect_rrb_key(ssid=ssid, passphrase=passphrase)
|
|
|
|
params["ieee80211w"] = "2";
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
|
2014-03-23 18:23:16 +01:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True,
|
|
|
|
fail_test=True)
|
2014-03-23 18:23:16 +01:00
|
|
|
|
|
|
|
def test_ap_ft_mismatching_rrb_key_pull(dev, apdev):
|
|
|
|
"""WPA2-PSK-FT AP over DS with mismatching RRB key (pull)"""
|
|
|
|
ssid = "test-ft"
|
|
|
|
passphrase="12345678"
|
|
|
|
|
|
|
|
params = ft_params1(ssid=ssid, passphrase=passphrase)
|
|
|
|
params["pmk_r1_push"] = "0"
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
|
2014-03-23 18:23:16 +01:00
|
|
|
params = ft_params2_incorrect_rrb_key(ssid=ssid, passphrase=passphrase)
|
|
|
|
params["pmk_r1_push"] = "0"
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
|
2014-03-23 18:23:16 +01:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True,
|
|
|
|
fail_test=True)
|
2014-03-23 18:23:16 +01:00
|
|
|
|
2014-05-17 09:44:41 +02:00
|
|
|
def test_ap_ft_mismatching_r0kh_id_pull(dev, apdev):
|
|
|
|
"""WPA2-PSK-FT AP over DS with mismatching R0KH-ID (pull)"""
|
|
|
|
ssid = "test-ft"
|
|
|
|
passphrase="12345678"
|
|
|
|
|
|
|
|
params = ft_params1(ssid=ssid, passphrase=passphrase)
|
|
|
|
params["pmk_r1_push"] = "0"
|
|
|
|
params["nas_identifier"] = "nas0.w1.fi"
|
|
|
|
hostapd.add_ap(apdev[0]['ifname'], params)
|
|
|
|
dev[0].connect(ssid, psk=passphrase, key_mgmt="FT-PSK", proto="WPA2")
|
|
|
|
|
|
|
|
params = ft_params2(ssid=ssid, passphrase=passphrase)
|
|
|
|
params["pmk_r1_push"] = "0"
|
|
|
|
hostapd.add_ap(apdev[1]['ifname'], params)
|
|
|
|
|
|
|
|
dev[0].scan_for_bss(apdev[1]['bssid'], freq="2412")
|
|
|
|
dev[0].roam_over_ds(apdev[1]['bssid'], fail_test=True)
|
|
|
|
|
2014-03-23 18:23:16 +01:00
|
|
|
def test_ap_ft_mismatching_rrb_r0kh_push(dev, apdev):
|
|
|
|
"""WPA2-PSK-FT AP over DS with mismatching R0KH key (push)"""
|
|
|
|
ssid = "test-ft"
|
|
|
|
passphrase="12345678"
|
|
|
|
|
|
|
|
params = ft_params1(ssid=ssid, passphrase=passphrase)
|
|
|
|
params["ieee80211w"] = "2";
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
|
2014-03-23 18:23:16 +01:00
|
|
|
params = ft_params2_r0kh_mismatch(ssid=ssid, passphrase=passphrase)
|
|
|
|
params["ieee80211w"] = "2";
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
|
2014-03-23 18:23:16 +01:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True,
|
|
|
|
fail_test=True)
|
2014-03-23 18:23:16 +01:00
|
|
|
|
|
|
|
def test_ap_ft_mismatching_rrb_r0kh_pull(dev, apdev):
|
|
|
|
"""WPA2-PSK-FT AP over DS with mismatching R0KH key (pull)"""
|
|
|
|
ssid = "test-ft"
|
|
|
|
passphrase="12345678"
|
|
|
|
|
|
|
|
params = ft_params1_r0kh_mismatch(ssid=ssid, passphrase=passphrase)
|
|
|
|
params["pmk_r1_push"] = "0"
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
|
2014-03-23 18:23:16 +01:00
|
|
|
params = ft_params2(ssid=ssid, passphrase=passphrase)
|
|
|
|
params["pmk_r1_push"] = "0"
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
|
2014-03-23 18:23:16 +01:00
|
|
|
|
2014-10-19 16:54:49 +02:00
|
|
|
run_roams(dev[0], apdev, hapd0, hapd1, ssid, passphrase, over_ds=True,
|
|
|
|
fail_test=True)
|
2014-06-01 11:25:48 +02:00
|
|
|
|
|
|
|
def test_ap_ft_gtk_rekey(dev, apdev):
|
|
|
|
"""WPA2-PSK-FT AP and GTK rekey"""
|
|
|
|
ssid = "test-ft"
|
|
|
|
passphrase="12345678"
|
|
|
|
|
|
|
|
params = ft_params1(ssid=ssid, passphrase=passphrase)
|
|
|
|
params['wpa_group_rekey'] = '1'
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
|
2014-06-01 11:25:48 +02:00
|
|
|
|
|
|
|
dev[0].connect(ssid, psk=passphrase, key_mgmt="FT-PSK", proto="WPA2",
|
|
|
|
ieee80211w="1")
|
|
|
|
|
|
|
|
ev = dev[0].wait_event(["WPA: Group rekeying completed"], timeout=2)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("GTK rekey timed out after initial association")
|
2014-10-19 16:54:49 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2014-06-01 11:25:48 +02:00
|
|
|
|
|
|
|
params = ft_params2(ssid=ssid, passphrase=passphrase)
|
|
|
|
params['wpa_group_rekey'] = '1'
|
2014-10-19 16:54:49 +02:00
|
|
|
hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
|
2014-06-01 11:25:48 +02:00
|
|
|
|
|
|
|
dev[0].scan_for_bss(apdev[1]['bssid'], freq="2412")
|
|
|
|
dev[0].roam(apdev[1]['bssid'])
|
|
|
|
if dev[0].get_status_field('bssid') != apdev[1]['bssid']:
|
|
|
|
raise Exception("Did not connect to correct AP")
|
2014-10-19 16:54:49 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd1)
|
2014-06-01 11:25:48 +02:00
|
|
|
|
|
|
|
ev = dev[0].wait_event(["WPA: Group rekeying completed"], timeout=2)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("GTK rekey timed out after FT protocol")
|
2014-10-19 16:54:49 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd1)
|