[PATCH 24/55] tests: FT-EAP with encrypted reassociation

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


Add tests for the FT protocol with association frame encryption,
including an initial association using IEEE 802.1X in Authentication
frames.

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

diff --git a/tests/hwsim/test_ap_ft.py b/tests/hwsim/test_ap_ft.py
index f0e5f153b678..587e9a8de4ff 100644
--- a/tests/hwsim/test_ap_ft.py
+++ b/tests/hwsim/test_ap_ft.py
@@ -3978,3 +3978,119 @@ def test_ap_ft_eap_1x_auth_fte_mismatch(dev, apdev):
 
     if "CTRL-EVENT-CONNECTED" in ev:
         raise Exception("FTE mismatch in Association Response not detected")
+
+def ft_enc_assoc_check_capture(capfile, sta, aps):
+    # All FT Authentication frames carry the Diffie-Hellman Parameter element
+    filt = "wlan.fc.type_subtype == 0x000b && wlan.fixed.auth.alg == 2 && " + \
+           "wlan.fixed.status_code == 0 && (wlan.sa == " + sta + \
+           " || wlan.da == " + sta + ")"
+    res = run_tshark(capfile, filt, ["wlan.sa", "wlan.ext_tag.number"])
+    frames = [line.split('\t') for line in res.splitlines() if line]
+    srcs = [f[0] for f in frames]
+
+    if sta not in srcs or not any(ap in srcs for ap in aps):
+        raise Exception("FT Authentication frames missing: " + str(srcs))
+
+    for f in frames:
+        if len(f) < 2 or "32" not in f[1].split(','):
+            raise Exception("Diffie-Hellman Parameter element missing in FT Authentication frame from " +
+                            f[0])
+
+    # Reassociation Request/Response frames are encrypted
+    for subtype in ["0x0002", "0x0003"]:
+        filt = "wlan.fc.type_subtype == " + subtype
+        res = run_tshark(capfile, filt, ["wlan.fc.protected"])
+        vals = res.splitlines()
+        if not vals:
+            raise Exception("No Reassociation frames (subtype %s) in capture" % subtype)
+
+        if any(v not in ["1", "True"] for v in vals):
+            raise Exception("Unprotected Reassociation frame (subtype %s): %s" % (subtype, str(vals)))
+
+def run_ap_ft_enc_assoc(dev, apdev, params, sha384=False, roams=1,
+                        eap_over_auth=False):
+    capfile = os.path.join(params['logdir'], "hwsim0.pcapng")
+    ssid = "test-ft"
+    passphrase = "12345678"
+    key_mgmt = "FT-EAP-SHA384" if sha384 else "FT-EAP"
+
+    radius = hostapd.radius_params()
+    hapds = []
+    for i, ft_p in enumerate([ft_params1, ft_params2]):
+        p = ft_p(ssid=ssid, passphrase=passphrase)
+        p['wpa_key_mgmt'] = key_mgmt
+        p["ieee8021x"] = "1"
+        p["ieee80211w"] = "2"
+        p["assoc_frame_encryption"] = "1"
+        if eap_over_auth:
+            p["eap_using_authentication_frames"] = "1"
+
+        p = dict(list(radius.items()) + list(p.items()))
+        hapds.append(hostapd.add_ap(apdev[i], p))
+
+    dev[0].flush_scan_cache()
+    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)
+
+    sta = dev[0].own_addr()
+    ft_enc_assoc_check_capture(capfile, sta,
+                               [hapds[0].own_addr(), hapds[1].own_addr()])
+    if eap_over_auth:
+        if hapds[0].get_sta(sta)['auth_alg'] != '2':
+            raise Exception("FT was not used after the initial association")
+
+        ft_1x_auth_check_capture(capfile)
+
+def test_ap_ft_eap_enc_assoc(dev, apdev, params):
+    """FT-EAP with encrypted reassociation"""
+    run_ap_ft_enc_assoc(dev, apdev, params)
+
+def test_ap_ft_eap_sha384_enc_assoc(dev, apdev, params):
+    """FT-EAP-SHA384 with encrypted reassociation"""
+    check_suite_b_192_capa(dev)
+    run_ap_ft_enc_assoc(dev, apdev, params, sha384=True)
+
+def test_ap_ft_eap_enc_assoc_multi(dev, apdev, params):
+    """FT-EAP with encrypted reassociation, multiple roams"""
+    run_ap_ft_enc_assoc(dev, apdev, params, roams=5)
+
+def test_ap_ft_eap_enc_assoc_1x_auth(dev, apdev, params):
+    """FT-EAP over IEEE 802.1X auth frames and encrypted reassociation"""
+    run_ap_ft_enc_assoc(dev, apdev, params, roams=2, eap_over_auth=True)
+
+def test_ap_ft_eap_enc_assoc_group_retry(dev, apdev, params):
+    """FT-EAP with encrypted reassociation and group retry"""
+    capfile = os.path.join(params['logdir'], "hwsim0.pcapng")
+    ssid = "test-ft"
+    passphrase = "12345678"
+
+    radius = hostapd.radius_params()
+    hapds = []
+    for i, ft_p in enumerate([ft_params1, ft_params2]):
+        p = ft_p(ssid=ssid, passphrase=passphrase)
+        p['wpa_key_mgmt'] = "FT-EAP"
+        p["ieee8021x"] = "1"
+        p["ieee80211w"] = "2"
+        p["assoc_frame_encryption"] = "1"
+        p["ieee8021x_auth_groups"] = "19"
+        p = dict(list(radius.items()) + list(p.items()))
+        hapds.append(hostapd.add_ap(apdev[i], p))
+
+    dev[0].flush_scan_cache()
+    dev[0].set("ieee8021x_auth_groups", "20 19")
+    try:
+        run_roams(dev[0], apdev, hapds[0], hapds[1], ssid, passphrase, eap=True,
+                  ieee80211w="2", roams=2)
+    finally:
+        dev[0].set("ieee8021x_auth_groups", "")
+
+    filt = "wlan.fc.type_subtype == 0x000b && wlan.fixed.auth.alg == 2 && " + \
+           "wlan.fixed.auth_seq == 2 && wlan.fixed.status_code == "
+    rejected = run_tshark(capfile, filt + "77", ["wlan.sa"]).splitlines()
+    accepted = run_tshark(capfile, filt + "0", ["wlan.sa"]).splitlines()
+    logger.info("Rejected: %s, accepted: %s" % (str(rejected), str(accepted)))
+    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)))
-- 
2.55.0




More information about the Hostap mailing list