[PATCH v2 15/15] tests: Add coverage for PASN deauthentication
Ilan Peer
ilan.peer at intel.com
Tue Mar 16 09:43:23 GMT 2021
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
tests/hwsim/test_pasn.py | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/tests/hwsim/test_pasn.py b/tests/hwsim/test_pasn.py
index ee6e6c8016..f7bc72e59d 100644
--- a/tests/hwsim/test_pasn.py
+++ b/tests/hwsim/test_pasn.py
@@ -47,9 +47,10 @@ def start_pasn_ap(apdev, params):
raise HwsimSkip("PASN not supported")
raise
-def check_pasn_ptk(dev, hapd, cipher, fail_ptk=0):
+def check_pasn_ptk(dev, hapd, cipher, fail_ptk=0, clear_keys=1):
sta_ptksa = dev.get_ptksa(hapd.own_addr(), cipher)
ap_ptksa = hapd.get_ptksa(dev.own_addr(), cipher)
+
if not (sta_ptksa and ap_ptksa):
if fail_ptk == 1:
return
@@ -62,6 +63,17 @@ def check_pasn_ptk(dev, hapd, cipher, fail_ptk=0):
raise Exception("TK/KDK mismatch")
elif fail_ptk == 1:
raise Exception("TK/KDK match although key derivation should have failed")
+ elif clear_keys == 1:
+ cmd = "PASN_DEAUTH bssid=%s" % hapd.own_addr()
+ dev.request(cmd)
+
+ # Wait a little to let the AP process the deauth
+ time.sleep(0.2)
+
+ sta_ptksa = dev.get_ptksa(hapd.own_addr(), cipher)
+ ap_ptksa = hapd.get_ptksa(dev.own_addr(), cipher)
+ if sta_ptksa or ap_ptksa:
+ raise Exception("TK/KDK not deleted as expected")
def check_pasn_akmp_cipher(dev, hapd, akmp="PASN", cipher="CCMP",
group="19", status=0, fail=0, nid="", fail_ptk=0):
@@ -293,7 +305,7 @@ def test_pasn_sae_kdk(dev, apdev):
dev[0].connect("test-sae", psk="12345678", key_mgmt="SAE",
scan_freq="2412")
- check_pasn_ptk(dev[0], hapd, "CCMP")
+ check_pasn_ptk(dev[0], hapd, "CCMP", clear_keys=0)
finally:
dev[0].set("force_kdk_derivation", "0")
@@ -328,7 +340,7 @@ def check_pasn_fils_kdk(dev, apdev, params, key_mgmt):
hapd.wait_sta()
hwsim_utils.test_connectivity(dev[0], hapd)
- check_pasn_ptk(dev[0], hapd, "CCMP")
+ check_pasn_ptk(dev[0], hapd, "CCMP", clear_keys=0)
dev[0].request("DISCONNECT")
dev[0].wait_disconnected()
@@ -348,7 +360,7 @@ def check_pasn_fils_kdk(dev, apdev, params, key_mgmt):
hapd.wait_sta()
hwsim_utils.test_connectivity(dev[0], hapd)
- check_pasn_ptk(dev[0], hapd, "CCMP")
+ check_pasn_ptk(dev[0], hapd, "CCMP", clear_keys=0)
finally:
dev[0].set("force_kdk_derivation", "0")
--
2.17.1
More information about the Hostap
mailing list