]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Add coverage for PASN deauthentication
authorIlan Peer <ilan.peer@intel.com>
Tue, 16 Mar 2021 09:43:23 +0000 (11:43 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 16 Mar 2021 20:50:10 +0000 (22:50 +0200)
Signed-off-by: Ilan Peer <ilan.peer@intel.com>
tests/hwsim/test_pasn.py

index 543e1e90924210004882c2a4c8fc87a9c44058ba..f2c7b3b221b6c5cd023fd54b7d40d5e831eba590 100644 (file)
@@ -46,9 +46,10 @@ def start_pasn_ap(apdev, params):
             raise HwsimSkip("PASN not supported")
         raise
 
-def check_pasn_ptk(dev, hapd, cipher, fail_ptk=False):
+def check_pasn_ptk(dev, hapd, cipher, fail_ptk=False, clear_keys=True):
     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:
             return
@@ -61,6 +62,17 @@ def check_pasn_ptk(dev, hapd, cipher, fail_ptk=False):
         raise Exception("TK/KDK mismatch")
     elif fail_ptk:
         raise Exception("TK/KDK match although key derivation should have failed")
+    elif clear_keys:
+        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="",
@@ -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=False)
     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=False)
 
         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=False)
     finally:
         dev[0].set("force_kdk_derivation", "0")