tests: TDLS with SAE

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2020-11-02 17:40:18 +02:00 committed by Jouni Malinen
parent a86078c876
commit 3b89dbaa7d

View File

@ -26,9 +26,13 @@ def connectivity(dev, hapd):
hwsim_utils.test_connectivity(dev[0], hapd) hwsim_utils.test_connectivity(dev[0], hapd)
hwsim_utils.test_connectivity(dev[1], hapd) hwsim_utils.test_connectivity(dev[1], hapd)
def connect_2sta(dev, ssid, hapd): def connect_2sta(dev, ssid, hapd, sae=False):
dev[0].connect(ssid, psk="12345678", scan_freq="2412") key_mgmt = "SAE" if sae else "WPA-PSK"
dev[1].connect(ssid, psk="12345678", scan_freq="2412") ieee80211w = "2" if sae else "1"
dev[0].connect(ssid, key_mgmt=key_mgmt, psk="12345678",
ieee80211w=ieee80211w, scan_freq="2412")
dev[1].connect(ssid, key_mgmt=key_mgmt, psk="12345678",
ieee80211w=ieee80211w, scan_freq="2412")
hapd.wait_sta() hapd.wait_sta()
hapd.wait_sta() hapd.wait_sta()
connectivity(dev, hapd) connectivity(dev, hapd)
@ -112,7 +116,7 @@ def check_connectivity(sta0, sta1, hapd):
hwsim_utils.test_connectivity(sta0, hapd) hwsim_utils.test_connectivity(sta0, hapd)
hwsim_utils.test_connectivity(sta1, hapd) hwsim_utils.test_connectivity(sta1, hapd)
def setup_tdls(sta0, sta1, hapd, reverse=False, expect_fail=False): def setup_tdls(sta0, sta1, hapd, reverse=False, expect_fail=False, sae=False):
logger.info("Setup TDLS") logger.info("Setup TDLS")
check_connectivity(sta0, sta1, hapd) check_connectivity(sta0, sta1, hapd)
bssid = hapd.own_addr() bssid = hapd.own_addr()
@ -124,18 +128,20 @@ def setup_tdls(sta0, sta1, hapd, reverse=False, expect_fail=False):
sta0.tdls_setup(addr1) sta0.tdls_setup(addr1)
time.sleep(1) time.sleep(1)
if expect_fail: if expect_fail:
tdls_check_ap(sta0, sta1, bssid, addr0, addr1) if not sae:
tdls_check_ap(sta0, sta1, bssid, addr0, addr1)
return return
if reverse: if reverse:
addr1 = sta0.p2p_interface_addr() addr1 = sta0.p2p_interface_addr()
addr0 = sta1.p2p_interface_addr() addr0 = sta1.p2p_interface_addr()
conf = wt.get_tdls_counter("setup_conf_ok", bssid, addr0, addr1) if not sae:
if conf == 0: conf = wt.get_tdls_counter("setup_conf_ok", bssid, addr0, addr1)
raise Exception("No TDLS Setup Confirm (success) seen") if conf == 0:
tdls_check_dl(sta0, sta1, bssid, addr0, addr1) raise Exception("No TDLS Setup Confirm (success) seen")
tdls_check_dl(sta0, sta1, bssid, addr0, addr1)
check_connectivity(sta0, sta1, hapd) check_connectivity(sta0, sta1, hapd)
def teardown_tdls(sta0, sta1, hapd, responder=False, wildcard=False): def teardown_tdls(sta0, sta1, hapd, responder=False, wildcard=False, sae=False):
logger.info("Teardown TDLS") logger.info("Teardown TDLS")
check_connectivity(sta0, sta1, hapd) check_connectivity(sta0, sta1, hapd)
bssid = hapd.own_addr() bssid = hapd.own_addr()
@ -148,11 +154,12 @@ def teardown_tdls(sta0, sta1, hapd, responder=False, wildcard=False):
else: else:
sta0.tdls_teardown(addr1) sta0.tdls_teardown(addr1)
time.sleep(1) time.sleep(1)
wt = Wlantest() if not sae:
teardown = wt.get_tdls_counter("teardown", bssid, addr0, addr1) wt = Wlantest()
if teardown == 0: teardown = wt.get_tdls_counter("teardown", bssid, addr0, addr1)
raise Exception("No TDLS Setup Teardown seen") if teardown == 0:
tdls_check_ap(sta0, sta1, bssid, addr0, addr1) raise Exception("No TDLS Setup Teardown seen")
tdls_check_ap(sta0, sta1, bssid, addr0, addr1)
check_connectivity(sta0, sta1, hapd) check_connectivity(sta0, sta1, hapd)
def check_tdls_link(sta0, sta1, connected=True): def check_tdls_link(sta0, sta1, connected=True):
@ -627,3 +634,17 @@ def _test_ap_open_tdls_external_control(dev, apdev):
time.sleep(0.1) time.sleep(0.1)
if connected: if connected:
raise Exception("TDLS teardown did not complete") raise Exception("TDLS teardown did not complete")
def test_ap_sae_tdls(dev, apdev):
"""SAE AP and two stations using TDLS"""
check_sae_capab(dev[0])
check_sae_capab(dev[1])
params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678")
params['wpa_key_mgmt'] = 'SAE'
params["ieee80211w"] = "2"
hapd = hostapd.add_ap(apdev[0], params)
wlantest_setup(hapd)
connect_2sta(dev, "test-wpa2-psk", hapd, sae=True)
setup_tdls(dev[0], dev[1], hapd, sae=True)
teardown_tdls(dev[0], dev[1], hapd, sae=True)
setup_tdls(dev[1], dev[0], hapd, sae=True)