[PATCH 33/55] tests: FT-EAP with PMKR0Name privacy

Ilan Peer ilan.peer at intel.com
Thu Dec 3 02:44:32 PST 2026


Verify that the PMKR0Name indicated in FT Authentication frames changes
after every fast BSS transition when both the AP and the STA support
PMKSA caching privacy, including when the R1KH needs to pull the PMK-R1
for the new PMKR0Name, and that it does not change when only the AP
supports it.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 tests/hwsim/test_ap_ft.py | 60 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 3 deletions(-)

diff --git a/tests/hwsim/test_ap_ft.py b/tests/hwsim/test_ap_ft.py
index 587e9a8de4ff..90af8d6a9a8f 100644
--- a/tests/hwsim/test_ap_ft.py
+++ b/tests/hwsim/test_ap_ft.py
@@ -141,12 +141,15 @@ def run_roams(dev, apdev, hapd0, hapd1, ssid, passphrase, over_ds=False,
               roam_with_reassoc=False, also_non_ft=False, only_one_way=False,
               wait_before_roam=0, return_after_initial=False, ieee80211w="1",
               sae_transition=False, beacon_prot=False, sae_ext_key=False,
-              check_ssid=False, gtk_rekey=False, eap_over_auth=False):
+              check_ssid=False, gtk_rekey=False, eap_over_auth=False,
+              pmksa_privacy=False):
     logger.info("Connect to first AP")
 
     copts = {}
     if eap_over_auth:
         copts["eap_over_auth_frame"] = "1"
+    if pmksa_privacy:
+        copts["pmksa_privacy"] = "1"
     copts["proto"] = "WPA2"
     copts["ieee80211w"] = ieee80211w
     copts["scan_freq"] = "2412"
@@ -4007,8 +4010,21 @@ def ft_enc_assoc_check_capture(capfile, sta, aps):
         if any(v not in ["1", "True"] for v in vals):
             raise Exception("Unprotected Reassociation frame (subtype %s): %s" % (subtype, str(vals)))
 
+def ft_pmk_r0_names(capfile, sta):
+    # PMKR0Name indicated in the RSNE of the first FT Authentication frame
+    filt = "wlan.fc.type_subtype == 0x000b && wlan.fixed.auth.alg == 2 && " + \
+           "wlan.fixed.auth_seq == 1 && wlan.fc.retry == 0 && " + \
+           "wlan.sa == " + sta
+
+    res = run_tshark(capfile, filt, ["wlan.pmkid.akms"])
+    names = [n for n in res.splitlines() if n]
+
+    logger.info("PMKR0Names: " + str(names))
+    return names
+
 def run_ap_ft_enc_assoc(dev, apdev, params, sha384=False, roams=1,
-                        eap_over_auth=False):
+                        ap_privacy=False, sta_privacy=False,
+                        r1_push=True, eap_over_auth=False):
     capfile = os.path.join(params['logdir'], "hwsim0.pcapng")
     ssid = "test-ft"
     passphrase = "12345678"
@@ -4025,6 +4041,12 @@ def run_ap_ft_enc_assoc(dev, apdev, params, sha384=False, roams=1,
         if eap_over_auth:
             p["eap_using_authentication_frames"] = "1"
 
+        if ap_privacy:
+            p["pmksa_caching_privacy"] = "1"
+
+        if not r1_push:
+            p["pmk_r1_push"] = "0"
+
         p = dict(list(radius.items()) + list(p.items()))
         hapds.append(hostapd.add_ap(apdev[i], p))
 
@@ -4032,7 +4054,7 @@ def run_ap_ft_enc_assoc(dev, apdev, params, sha384=False, roams=1,
     run_roams(dev[0], apdev, hapds[0], hapds[1], ssid, passphrase, eap=True,
               sha384=sha384, ieee80211w="2", roams=roams,
               force_initial_conn_to_first_ap=eap_over_auth,
-              eap_over_auth=eap_over_auth)
+              eap_over_auth=eap_over_auth, pmksa_privacy=sta_privacy)
 
     sta = dev[0].own_addr()
     ft_enc_assoc_check_capture(capfile, sta,
@@ -4043,6 +4065,18 @@ def run_ap_ft_enc_assoc(dev, apdev, params, sha384=False, roams=1,
 
         ft_1x_auth_check_capture(capfile)
 
+    return ft_pmk_r0_names(capfile, sta)
+
+def run_ap_ft_enc_assoc_pmksa_privacy(dev, apdev, params, sha384=False,
+                                      r1_push=True):
+    roams = 2
+    names = run_ap_ft_enc_assoc(dev, apdev, params, sha384=sha384,
+                                roams=roams, ap_privacy=True,
+                                sta_privacy=True, r1_push=r1_push)
+
+    if len(names) != 2 * roams or len(set(names)) != len(names):
+        raise Exception("PMKR0Name was reused: " + str(names))
+
 def test_ap_ft_eap_enc_assoc(dev, apdev, params):
     """FT-EAP with encrypted reassociation"""
     run_ap_ft_enc_assoc(dev, apdev, params)
@@ -4094,3 +4128,23 @@ def test_ap_ft_eap_enc_assoc_group_retry(dev, apdev, params):
     if not accepted or len(rejected) != len(accepted):
         raise Exception("Group 20 was not rejected before each FT: rejected=%d accepted=%d" %
                         (len(rejected), len(accepted)))
+
+def test_ap_ft_eap_enc_assoc_pmksa_privacy(dev, apdev, params):
+    """FT-EAP with encrypted reassociation and PMKR0Name privacy"""
+    run_ap_ft_enc_assoc_pmksa_privacy(dev, apdev, params)
+
+def test_ap_ft_eap_sha384_enc_assoc_pmksa_privacy(dev, apdev, params):
+    """FT-EAP-SHA384 with encrypted reassociation and PMKR0Name privacy"""
+    check_suite_b_192_capa(dev)
+    run_ap_ft_enc_assoc_pmksa_privacy(dev, apdev, params, sha384=True)
+
+def test_ap_ft_eap_enc_assoc_pmksa_privacy_pull(dev, apdev, params):
+    """FT-EAP with encrypted reassociation and PMKR0Name privacy, no push"""
+    run_ap_ft_enc_assoc_pmksa_privacy(dev, apdev, params, r1_push=False)
+
+def test_ap_ft_eap_enc_assoc_pmksa_privacy_ap_only(dev, apdev, params):
+    """FT-EAP with encrypted reassociation and PMKR0Name privacy only on AP"""
+    names = run_ap_ft_enc_assoc(dev, apdev, params, roams=2,
+                                ap_privacy=True)
+    if len(names) < 4 or len(set(names)) != 1:
+        raise Exception("Unexpected PMKR0Name change: " + str(names))
-- 
2.55.0




More information about the Hostap mailing list