tests: Share a single definition of SAE-PK Sec=2 values
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
parent
5ee94a997e
commit
f179475bf7
1 changed files with 36 additions and 53 deletions
|
@ -7,6 +7,12 @@
|
||||||
import hostapd
|
import hostapd
|
||||||
from utils import *
|
from utils import *
|
||||||
|
|
||||||
|
SAE_PK_SEC2_SSID = "SAE-PK test"
|
||||||
|
SAE_PK_SEC2_PW = "dwxm-zv66-p5ue"
|
||||||
|
SAE_PK_SEC2_PW_FULL = "dwxm-zv66-p5ue-fotp-owjy-lfby-2xpg-vmwq-chtz-hilu-m3t2-qleg"
|
||||||
|
SAE_PK_SEC2_M = "431ff8322f93b9dc50ded9f3d14ace22"
|
||||||
|
SAE_PK_SEC2_PK = "MHcCAQEEIAJIGlfnteonDb7rQyP/SGQjwzrZAnfrXIm4280VWajYoAoGCCqGSM49AwEHoUQDQgAEeRkstKQV+FSAMqBayqFknn2nAQsdsh/MhdX6tiHOTAFin/sUMFRMyspPtIu7YvlKdsexhI0jPVhaYZn1jKWhZg=="
|
||||||
|
|
||||||
def run_sae_pk(apdev, dev, ssid, pw, m, pk, ap_groups=None):
|
def run_sae_pk(apdev, dev, ssid, pw, m, pk, ap_groups=None):
|
||||||
params = hostapd.wpa2_params(ssid=ssid)
|
params = hostapd.wpa2_params(ssid=ssid)
|
||||||
params['wpa_key_mgmt'] = 'SAE'
|
params['wpa_key_mgmt'] = 'SAE'
|
||||||
|
@ -35,29 +41,21 @@ def test_sae_pk(dev, apdev):
|
||||||
check_sae_pk_capab(dev[0])
|
check_sae_pk_capab(dev[0])
|
||||||
dev[0].set("sae_groups", "")
|
dev[0].set("sae_groups", "")
|
||||||
|
|
||||||
ssid = "SAE-PK test"
|
for i in range(14, len(SAE_PK_SEC2_PW_FULL) + 1):
|
||||||
pw = "dwxm-zv66-p5ue-fotp-owjy-lfby-2xpg-vmwq-chtz-hilu-m3t2-qleg"
|
p = SAE_PK_SEC2_PW_FULL[:i]
|
||||||
m = "431ff8322f93b9dc50ded9f3d14ace22"
|
|
||||||
pk = "MHcCAQEEIAJIGlfnteonDb7rQyP/SGQjwzrZAnfrXIm4280VWajYoAoGCCqGSM49AwEHoUQDQgAEeRkstKQV+FSAMqBayqFknn2nAQsdsh/MhdX6tiHOTAFin/sUMFRMyspPtIu7YvlKdsexhI0jPVhaYZn1jKWhZg=="
|
|
||||||
|
|
||||||
for i in range(14, len(pw) + 1):
|
|
||||||
p = pw[:i]
|
|
||||||
if p.endswith('-'):
|
if p.endswith('-'):
|
||||||
continue
|
continue
|
||||||
run_sae_pk(apdev[0], dev[0], ssid, p, m, pk)
|
run_sae_pk(apdev[0], dev[0], SAE_PK_SEC2_SSID, p, SAE_PK_SEC2_M,
|
||||||
|
SAE_PK_SEC2_PK)
|
||||||
|
|
||||||
def test_sae_pk_group_negotiation(dev, apdev):
|
def test_sae_pk_group_negotiation(dev, apdev):
|
||||||
"""SAE-PK"""
|
"""SAE-PK"""
|
||||||
check_sae_pk_capab(dev[0])
|
check_sae_pk_capab(dev[0])
|
||||||
dev[0].set("sae_groups", "20 19")
|
dev[0].set("sae_groups", "20 19")
|
||||||
|
|
||||||
ssid = "SAE-PK test"
|
|
||||||
pw = "dwxm-zv66-p5ue-fotp-owjy-lfby-2xpg-vmwq-chtz-hilu-m3t2-qleg"
|
|
||||||
m = "431ff8322f93b9dc50ded9f3d14ace22"
|
|
||||||
pk = "MHcCAQEEIAJIGlfnteonDb7rQyP/SGQjwzrZAnfrXIm4280VWajYoAoGCCqGSM49AwEHoUQDQgAEeRkstKQV+FSAMqBayqFknn2nAQsdsh/MhdX6tiHOTAFin/sUMFRMyspPtIu7YvlKdsexhI0jPVhaYZn1jKWhZg=="
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
run_sae_pk(apdev[0], dev[0], ssid, pw, m, pk, ap_groups="19 20")
|
run_sae_pk(apdev[0], dev[0], SAE_PK_SEC2_SSID, SAE_PK_SEC2_PW,
|
||||||
|
SAE_PK_SEC2_M, SAE_PK_SEC2_PK, ap_groups="19 20")
|
||||||
finally:
|
finally:
|
||||||
dev[0].set("sae_groups", "")
|
dev[0].set("sae_groups", "")
|
||||||
|
|
||||||
|
@ -66,12 +64,8 @@ def test_sae_pk_sec_2(dev, apdev):
|
||||||
check_sae_pk_capab(dev[0])
|
check_sae_pk_capab(dev[0])
|
||||||
dev[0].set("sae_groups", "")
|
dev[0].set("sae_groups", "")
|
||||||
|
|
||||||
ssid = "SAE-PK test"
|
run_sae_pk(apdev[0], dev[0], SAE_PK_SEC2_SSID, SAE_PK_SEC2_PW,
|
||||||
pw = "dwxm-zv66-p5ue"
|
SAE_PK_SEC2_M, SAE_PK_SEC2_PK)
|
||||||
m = "431ff8322f93b9dc50ded9f3d14ace22"
|
|
||||||
pk = "MHcCAQEEIAJIGlfnteonDb7rQyP/SGQjwzrZAnfrXIm4280VWajYoAoGCCqGSM49AwEHoUQDQgAEeRkstKQV+FSAMqBayqFknn2nAQsdsh/MhdX6tiHOTAFin/sUMFRMyspPtIu7YvlKdsexhI0jPVhaYZn1jKWhZg=="
|
|
||||||
|
|
||||||
run_sae_pk(apdev[0], dev[0], ssid, pw, m, pk)
|
|
||||||
|
|
||||||
def test_sae_pk_sec_3(dev, apdev):
|
def test_sae_pk_sec_3(dev, apdev):
|
||||||
"""SAE-PK with Sec 3"""
|
"""SAE-PK with Sec 3"""
|
||||||
|
@ -129,15 +123,13 @@ def test_sae_pk_password_without_pk(dev, apdev):
|
||||||
check_sae_pk_capab(dev[0])
|
check_sae_pk_capab(dev[0])
|
||||||
dev[0].set("sae_groups", "")
|
dev[0].set("sae_groups", "")
|
||||||
|
|
||||||
ssid = "SAE-PK test"
|
params = hostapd.wpa2_params(ssid=SAE_PK_SEC2_SSID)
|
||||||
pw = "dwxm-zv66-p5ue"
|
|
||||||
|
|
||||||
params = hostapd.wpa2_params(ssid=ssid)
|
|
||||||
params['wpa_key_mgmt'] = 'SAE'
|
params['wpa_key_mgmt'] = 'SAE'
|
||||||
params['sae_password'] = pw
|
params['sae_password'] = SAE_PK_SEC2_PW
|
||||||
hapd = hostapd.add_ap(apdev[0], params)
|
hapd = hostapd.add_ap(apdev[0], params)
|
||||||
|
|
||||||
dev[0].connect(ssid, sae_password=pw, key_mgmt="SAE", scan_freq="2412")
|
dev[0].connect(SAE_PK_SEC2_SSID, sae_password=SAE_PK_SEC2_PW,
|
||||||
|
key_mgmt="SAE", scan_freq="2412")
|
||||||
if dev[0].get_status_field("sae_pk") != "0":
|
if dev[0].get_status_field("sae_pk") != "0":
|
||||||
raise Exception("Unexpected sae_pk STATUS value")
|
raise Exception("Unexpected sae_pk STATUS value")
|
||||||
|
|
||||||
|
@ -146,17 +138,13 @@ def test_sae_pk_only(dev, apdev):
|
||||||
check_sae_pk_capab(dev[0])
|
check_sae_pk_capab(dev[0])
|
||||||
dev[0].set("sae_groups", "")
|
dev[0].set("sae_groups", "")
|
||||||
|
|
||||||
ssid = "SAE-PK test"
|
params = hostapd.wpa2_params(ssid=SAE_PK_SEC2_SSID)
|
||||||
pw = "dwxm-zv66-p5ue"
|
|
||||||
m = "431ff8322f93b9dc50ded9f3d14ace22"
|
|
||||||
pk = "MHcCAQEEIAJIGlfnteonDb7rQyP/SGQjwzrZAnfrXIm4280VWajYoAoGCCqGSM49AwEHoUQDQgAEeRkstKQV+FSAMqBayqFknn2nAQsdsh/MhdX6tiHOTAFin/sUMFRMyspPtIu7YvlKdsexhI0jPVhaYZn1jKWhZg=="
|
|
||||||
|
|
||||||
params = hostapd.wpa2_params(ssid=ssid)
|
|
||||||
params['wpa_key_mgmt'] = 'SAE'
|
params['wpa_key_mgmt'] = 'SAE'
|
||||||
params['sae_password'] = pw
|
params['sae_password'] = SAE_PK_SEC2_PW
|
||||||
hapd = hostapd.add_ap(apdev[0], params)
|
hapd = hostapd.add_ap(apdev[0], params)
|
||||||
|
|
||||||
dev[0].connect(ssid, sae_password=pw, key_mgmt="SAE", sae_pk="1",
|
dev[0].connect(SAE_PK_SEC2_SSID, sae_password=SAE_PK_SEC2_PW,
|
||||||
|
key_mgmt="SAE", sae_pk="1",
|
||||||
scan_freq="2412", wait_connect=False)
|
scan_freq="2412", wait_connect=False)
|
||||||
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED",
|
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED",
|
||||||
"CTRL-EVENT-NETWORK-NOT-FOUND"], timeout=10)
|
"CTRL-EVENT-NETWORK-NOT-FOUND"], timeout=10)
|
||||||
|
@ -167,9 +155,10 @@ def test_sae_pk_only(dev, apdev):
|
||||||
dev[0].request("DISCONNECT")
|
dev[0].request("DISCONNECT")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
|
|
||||||
params = hostapd.wpa2_params(ssid=ssid)
|
params = hostapd.wpa2_params(ssid=SAE_PK_SEC2_SSID)
|
||||||
params['wpa_key_mgmt'] = 'SAE'
|
params['wpa_key_mgmt'] = 'SAE'
|
||||||
params['sae_password'] = ['%s|pk=%s:%s' % (pw, m, pk)]
|
params['sae_password'] = ['%s|pk=%s:%s' % (SAE_PK_SEC2_PW, SAE_PK_SEC2_M,
|
||||||
|
SAE_PK_SEC2_PK)]
|
||||||
hapd2 = hostapd.add_ap(apdev[1], params)
|
hapd2 = hostapd.add_ap(apdev[1], params)
|
||||||
bssid2 = hapd2.own_addr()
|
bssid2 = hapd2.own_addr()
|
||||||
|
|
||||||
|
@ -186,21 +175,18 @@ def test_sae_pk_modes(dev, apdev):
|
||||||
check_sae_pk_capab(dev[0])
|
check_sae_pk_capab(dev[0])
|
||||||
dev[0].set("sae_groups", "")
|
dev[0].set("sae_groups", "")
|
||||||
|
|
||||||
ssid = "SAE-PK test"
|
params = hostapd.wpa2_params(ssid=SAE_PK_SEC2_SSID)
|
||||||
pw = "dwxm-zv66-p5ue"
|
|
||||||
m = "431ff8322f93b9dc50ded9f3d14ace22"
|
|
||||||
pk = "MHcCAQEEIAJIGlfnteonDb7rQyP/SGQjwzrZAnfrXIm4280VWajYoAoGCCqGSM49AwEHoUQDQgAEeRkstKQV+FSAMqBayqFknn2nAQsdsh/MhdX6tiHOTAFin/sUMFRMyspPtIu7YvlKdsexhI0jPVhaYZn1jKWhZg=="
|
|
||||||
|
|
||||||
params = hostapd.wpa2_params(ssid=ssid)
|
|
||||||
params['wpa_key_mgmt'] = 'SAE'
|
params['wpa_key_mgmt'] = 'SAE'
|
||||||
params["ieee80211w"] = "2"
|
params["ieee80211w"] = "2"
|
||||||
params['sae_password'] = ['%s|pk=%s:%s' % (pw, m, pk)]
|
params['sae_password'] = ['%s|pk=%s:%s' % (SAE_PK_SEC2_PW, SAE_PK_SEC2_M,
|
||||||
|
SAE_PK_SEC2_PK)]
|
||||||
hapd = hostapd.add_ap(apdev[0], params)
|
hapd = hostapd.add_ap(apdev[0], params)
|
||||||
|
|
||||||
tests = [(2, 0), (1, 1), (0, 1)]
|
tests = [(2, 0), (1, 1), (0, 1)]
|
||||||
for sae_pk, expected in tests:
|
for sae_pk, expected in tests:
|
||||||
dev[0].connect(ssid, sae_password=pw, key_mgmt="SAE",
|
dev[0].connect(SAE_PK_SEC2_SSID, sae_password=SAE_PK_SEC2_PW,
|
||||||
sae_pk=str(sae_pk), ieee80211w="2", scan_freq="2412")
|
key_mgmt="SAE", sae_pk=str(sae_pk), ieee80211w="2",
|
||||||
|
scan_freq="2412")
|
||||||
val = dev[0].get_status_field("sae_pk")
|
val = dev[0].get_status_field("sae_pk")
|
||||||
if val != str(expected):
|
if val != str(expected):
|
||||||
raise Exception("Unexpected sae_pk=%d result %s" % (sae_pk, val))
|
raise Exception("Unexpected sae_pk=%d result %s" % (sae_pk, val))
|
||||||
|
@ -213,18 +199,15 @@ def test_sae_pk_transition_disable(dev, apdev):
|
||||||
check_sae_pk_capab(dev[0])
|
check_sae_pk_capab(dev[0])
|
||||||
dev[0].set("sae_groups", "")
|
dev[0].set("sae_groups", "")
|
||||||
|
|
||||||
ssid = "SAE-PK test"
|
params = hostapd.wpa2_params(ssid=SAE_PK_SEC2_SSID)
|
||||||
pw = "dwxm-zv66-p5ue"
|
|
||||||
m = "431ff8322f93b9dc50ded9f3d14ace22"
|
|
||||||
pk = "MHcCAQEEIAJIGlfnteonDb7rQyP/SGQjwzrZAnfrXIm4280VWajYoAoGCCqGSM49AwEHoUQDQgAEeRkstKQV+FSAMqBayqFknn2nAQsdsh/MhdX6tiHOTAFin/sUMFRMyspPtIu7YvlKdsexhI0jPVhaYZn1jKWhZg=="
|
|
||||||
|
|
||||||
params = hostapd.wpa2_params(ssid=ssid)
|
|
||||||
params['wpa_key_mgmt'] = 'SAE'
|
params['wpa_key_mgmt'] = 'SAE'
|
||||||
params['sae_password'] = ['%s|pk=%s:%s' % (pw, m, pk)]
|
params['sae_password'] = ['%s|pk=%s:%s' % (SAE_PK_SEC2_PW, SAE_PK_SEC2_M,
|
||||||
|
SAE_PK_SEC2_PK)]
|
||||||
params['transition_disable'] = '0x02'
|
params['transition_disable'] = '0x02'
|
||||||
hapd = hostapd.add_ap(apdev[0], params)
|
hapd = hostapd.add_ap(apdev[0], params)
|
||||||
|
|
||||||
id = dev[0].connect(ssid, sae_password=pw, key_mgmt="SAE", scan_freq="2412")
|
id = dev[0].connect(SAE_PK_SEC2_SSID, sae_password=SAE_PK_SEC2_PW,
|
||||||
|
key_mgmt="SAE", scan_freq="2412")
|
||||||
ev = dev[0].wait_event(["TRANSITION-DISABLE"], timeout=1)
|
ev = dev[0].wait_event(["TRANSITION-DISABLE"], timeout=1)
|
||||||
if ev is None:
|
if ev is None:
|
||||||
raise Exception("Transition disable not indicated")
|
raise Exception("Transition disable not indicated")
|
||||||
|
|
Loading…
Reference in a new issue