[PATCH 10/55] AP: Support FT initial mobility domain association over IEEE 802.1X auth

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


In the association request frame, validate the MDE, the FTE and the
PMKR1Name in addition to the MIC element. Include the RSNE with the
PMKR1Name, the MDE, the FTE and the TIEs in the association response
frame, followed by the Key Delivery element.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 src/ap/ieee802_11.c  | 13 +++++++++-
 src/ap/wpa_auth.c    | 55 ++++++++++++++++++++++++++++++++++++++++++
 src/ap/wpa_auth.h    |  3 +++
 src/ap/wpa_auth_ft.c | 57 ++++++++++++++++++++++++++++++++++++++++++++
 src/ap/wpa_auth_ie.c |  6 +++++
 5 files changed, 133 insertions(+), 1 deletion(-)

diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index 76e5aee1652b..86a532c5f479 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -7173,6 +7173,16 @@ static int __check_assoc_ies(struct hostapd_data *hapd, struct sta_info *sta,
 	    hapd->mld_link_id != sta->mld_assoc_link_id)
 		mic_check = false;
 #endif /* CONFIG_IEEE80211BE */
+
+#ifdef CONFIG_IEEE80211R_AP
+	if (ap_sta_is_epp(sta) && sta->auth_alg == WLAN_AUTH_802_1X &&
+	    sta->eap_auth_data.ft) {
+		resp = wpa_auth_802_1x_ft_check_assoc(sta->wpa_sm, elems);
+		if (resp != WLAN_STATUS_SUCCESS)
+			goto out;
+	}
+#endif /* CONFIG_IEEE80211R_AP */
+
 	if (ap_sta_is_epp(sta) && sta->auth_alg == WLAN_AUTH_802_1X &&
 	    mic_check) {
 		const u8 *data;
@@ -8438,7 +8448,8 @@ static u16 send_assoc_resp(struct hostapd_data *hapd, struct sta_info *sta,
 #endif /* CONFIG_MBO */
 
 #ifdef CONFIG_IEEE80211R_AP
-	if (sta && status_code == WLAN_STATUS_SUCCESS) {
+	if (sta && status_code == WLAN_STATUS_SUCCESS &&
+	    !(sta->auth_alg == WLAN_AUTH_802_1X && ap_sta_is_epp(sta))) {
 		size_t left = end - p;
 
 		/* Try to minimize risk of running out of room for additional
diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c
index 5fc052096ed2..bd16aac765de 100644
--- a/src/ap/wpa_auth.c
+++ b/src/ap/wpa_auth.c
@@ -8398,6 +8398,61 @@ u8 * wpa_auth_write_assoc_resp_eppke(struct wpa_state_machine *sm,
 	if (!sm)
 		return pos;
 
+#ifdef CONFIG_IEEE80211R_AP
+	/* Handle FT initial mobility domain assoc */
+	if (sm->auth_alg == WLAN_AUTH_802_1X &&
+	    wpa_key_mgmt_ft(sm->wpa_key_mgmt) && sm->pmk_r1_name_valid) {
+		struct wpa_auth_config *conf = &sm->wpa_auth->conf;
+		int rsnxe_used = 0;
+
+#ifdef CONFIG_TESTING_OPTIONS
+		if (conf->ft_rsnxe_used)
+			rsnxe_used = conf->ft_rsnxe_used == 1;
+#endif /* CONFIG_TESTING_OPTIONS */
+
+		res = wpa_write_rsn_ie(conf, pos, end - pos, sm->pmk_r1_name);
+		if (res < 0)
+			return NULL;
+
+		pos += res;
+
+		res = wpa_write_mdie(conf, pos, end - pos);
+		if (res < 0)
+			return NULL;
+
+		pos += res;
+
+		res = wpa_write_ftie(conf, sm->wpa_key_mgmt, 0,
+				     conf->r0_key_holder,
+				     conf->r0_key_holder_len, NULL, NULL,
+				     pos, end - pos, NULL, 0, rsnxe_used, true);
+		if (res < 0 || end - pos < res + 2 * 7)
+			return NULL;
+
+		/* EAPOL-Key msg 3/4 of a PTK rekey repeats this FTE */
+		os_free(sm->assoc_resp_ftie);
+		sm->assoc_resp_ftie = os_memdup(pos, res);
+		if (!sm->assoc_resp_ftie)
+			return NULL;
+
+		pos += res;
+
+		*pos++ = WLAN_EID_TIMEOUT_INTERVAL;
+		*pos++ = 5;
+		*pos++ = WLAN_TIMEOUT_REASSOC_DEADLINE;
+		WPA_PUT_LE32(pos, conf->reassociation_deadline);
+		pos += 4;
+
+		*pos++ = WLAN_EID_TIMEOUT_INTERVAL;
+		*pos++ = 5;
+		*pos++ = WLAN_TIMEOUT_KEY_LIFETIME;
+		WPA_PUT_LE32(pos, conf->r0_key_lifetime);
+		pos += 4;
+
+		return wpa_auth_eid_key_delivery(pos, end - pos, sm, is_ml);
+	}
+#endif /* CONFIG_IEEE80211R_AP */
+
 	res = wpa_write_rsn_ie(&sm->wpa_auth->conf, pos, max_len, NULL);
 	if (res < 0)
 		return pos;
diff --git a/src/ap/wpa_auth.h b/src/ap/wpa_auth.h
index 41f467f903a1..a7d1163f48c2 100644
--- a/src/ap/wpa_auth.h
+++ b/src/ap/wpa_auth.h
@@ -782,6 +782,9 @@ int wpa_auth_802_1x_ft_pmk_to_ptk(struct wpa_state_machine *sm,
 				  const u8 *rsnxe, size_t rsnxe_len,
 				  const u8 *dhss, size_t dhss_len,
 				  struct wpa_ptk *ptk, size_t kdk_len);
+struct ieee802_11_elems;
+u16 wpa_auth_802_1x_ft_check_assoc(struct wpa_state_machine *sm,
+				   const struct ieee802_11_elems *elems);
 int wpa_auth_802_1x_set_key(struct wpa_authenticator *wpa_auth,
 			    enum wpa_alg alg, const u8 *addr,
 			    u8 *key, size_t key_len);
diff --git a/src/ap/wpa_auth_ft.c b/src/ap/wpa_auth_ft.c
index 3b687ca69df4..25f84898bfc5 100644
--- a/src/ap/wpa_auth_ft.c
+++ b/src/ap/wpa_auth_ft.c
@@ -2378,6 +2378,63 @@ out:
 	return ret;
 }
 
+
+u16 wpa_auth_802_1x_ft_check_assoc(struct wpa_state_machine *sm,
+				   const struct ieee802_11_elems *elems)
+{
+	struct wpa_auth_config *conf;
+	struct wpa_ie_data rsn;
+	struct wpa_ft_ies parse;
+	u16 status = WLAN_STATUS_SUCCESS;
+
+	if (!sm || !sm->pmk_r1_name_valid)
+		return WLAN_STATUS_UNSPECIFIED_FAILURE;
+
+	conf = &sm->wpa_auth->conf;
+
+	if (!elems->mdie || elems->mdie_len < sizeof(struct rsn_mdie) ||
+	    os_memcmp(elems->mdie, conf->mobility_domain,
+		      MOBILITY_DOMAIN_ID_LEN) != 0) {
+		wpa_printf(MSG_DEBUG, "FT: Invalid MDE in Assoc Request");
+		return WLAN_STATUS_INVALID_MDE;
+	}
+
+	if (!elems->ftie ||
+	    wpa_ft_parse_ies(elems->ftie - 2, elems->ftie_len + 2, &parse,
+			     sm->wpa_key_mgmt, false) < 0) {
+		wpa_printf(MSG_DEBUG, "FT: Invalid FTE in Assoc Request");
+		return WLAN_STATUS_INVALID_FTE;
+	}
+
+	if (!parse.r0kh_id || parse.r0kh_id_len != conf->r0_key_holder_len ||
+	    os_memcmp(parse.r0kh_id, conf->r0_key_holder,
+		      conf->r0_key_holder_len) != 0 ||
+	    !parse.r1kh_id ||
+	    os_memcmp(parse.r1kh_id, conf->r1_key_holder,
+		      FT_R1KH_ID_LEN) != 0 ||
+	    parse.fte_mic_len != 0) {
+		wpa_printf(MSG_DEBUG, "FT: FTE mismatch in Assoc Request");
+		status = WLAN_STATUS_INVALID_FTE;
+		goto out;
+	}
+
+	if (!elems->rsn_ie ||
+	    wpa_parse_wpa_ie_rsn(elems->rsn_ie - 2, elems->rsn_ie_len + 2,
+				 &rsn) < 0 ||
+	    rsn.num_pmkid != 1 || !rsn.pmkid ||
+	    os_memcmp_const(rsn.pmkid, sm->pmk_r1_name,
+			    WPA_PMK_NAME_LEN) != 0) {
+		wpa_printf(MSG_DEBUG,
+			   "FT: No PMKR1Name match in Assoc Request");
+		status = WLAN_STATUS_INVALID_PMKID;
+		goto out;
+	}
+
+out:
+	wpa_ft_parse_ies_free(&parse);
+	return status;
+}
+
 #endif /* CONFIG_IEEE8021X_AUTH */
 
 static inline int wpa_auth_get_seqnum(struct wpa_authenticator *wpa_auth,
diff --git a/src/ap/wpa_auth_ie.c b/src/ap/wpa_auth_ie.c
index e2c4125058b4..1a32ffd543c5 100644
--- a/src/ap/wpa_auth_ie.c
+++ b/src/ap/wpa_auth_ie.c
@@ -1399,6 +1399,11 @@ wpa_validate_wpa_ie(struct wpa_authenticator *wpa_auth,
 	}
 #endif /* CONFIG_IEEE80211R_AP && CONFIG_FILS */
 
+	/* The PMKID List carries PMKR1Name (checked by the caller) */
+	if (sm->epp && sm->auth_alg == WLAN_AUTH_802_1X &&
+	    wpa_key_mgmt_ft(sm->wpa_key_mgmt))
+		goto skip_pmkid;
+
 	if (!sm->epp || data.num_pmkid > 0)
 		sm->pmksa = NULL;
 	for (i = 0; i < data.num_pmkid; i++) {
@@ -1482,6 +1487,7 @@ wpa_validate_wpa_ie(struct wpa_authenticator *wpa_auth,
 				 (vlan && vlan->tagged[0]) ? "+" : "");
 		os_memcpy(wpa_auth->dot11RSNAPMKIDUsed, pmkid, PMKID_LEN);
 	}
+skip_pmkid:
 
 #ifdef CONFIG_SAE
 	if (sm->wpa_key_mgmt == WPA_KEY_MGMT_SAE ||
-- 
2.55.0




More information about the Hostap mailing list