[PATCH 23/55] FT: Support encrypted reassociation

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


With Association frame encryption in the FT protocol, the
Reassociation Request/Response frames are protected, so the FTE in the
Reassociation Response frame uses a 0 octet MIC and an Element Count
of 0.

On the AP, build the FTE accordingly, send the Reassociation Response
frame protected, include the Security Profile element if the request
included one, and reject an unprotected Reassociation Request frame.

On the station, validate the FTE accordingly, reject an unencrypted
Reassociation Response frame and verify that its Security Profile
element matches the one in the Beacon frame. Do not add the own RSNXE
to the Reassociation Request frame when the FT elements already
include it.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 src/ap/ieee802_11.c     | 25 +++++++++++++++++
 src/ap/wpa_auth_ft.c    | 15 +++++++---
 src/rsn_supp/wpa_ft.c   | 19 +++++++++++--
 wpa_supplicant/events.c | 62 +++++++++++++++++++++++++++++++++++++++++
 wpa_supplicant/sme.c    |  9 ++++--
 5 files changed, 122 insertions(+), 8 deletions(-)

diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index 1fa4b0b6df67..d3e35bc11103 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -8737,6 +8737,19 @@ rsnxe_done:
 		if (hapd->conf->security_profiles)
 			p = hostapd_eid_security_profile(hapd, p);
 	}
+
+#ifdef CONFIG_IEEE80211R_AP
+	if (sta && sta->auth_alg == WLAN_AUTH_FT &&
+	    wpa_auth_sta_ft_enc_assoc(sta->wpa_sm) &&
+	    status_code == WLAN_STATUS_SUCCESS) {
+		/* Include the Security Profile element as with EPPKE */
+		if (hapd->conf->security_profiles &&
+		    end - p >= (long int)hostapd_security_profile_len(hapd))
+			p = hostapd_eid_security_profile(hapd, p);
+		reply->frame_control |= WLAN_FC_PROTECTED;
+	}
+#endif /* CONFIG_IEEE80211R_AP */
+
 #endif /* CONFIG_ENC_ASSOC */
 
 #ifdef CONFIG_DPP2
@@ -9283,6 +9296,18 @@ static void handle_assoc(struct hostapd_data *hapd,
 	}
 #endif /* CONFIG_FILS */
 
+#if defined(CONFIG_IEEE80211R_AP) && defined(CONFIG_ENC_ASSOC)
+	if (sta->auth_alg == WLAN_AUTH_FT &&
+	    wpa_auth_sta_ft_enc_assoc(sta->wpa_sm) &&
+	    !(fc & WLAN_FC_PROTECTED)) {
+		wpa_printf(MSG_DEBUG,
+			   "FT: Unprotected Reassociation Request frame");
+
+		resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
+		goto fail;
+	}
+#endif /* CONFIG_IEEE80211R_AP && CONFIG_ENC_ASSOC */
+
 	/* followed by SSID and Supported rates; and HT capabilities if 802.11n
 	 * is used */
 	resp = check_assoc_ies(hapd, sta, pos, left,
diff --git a/src/ap/wpa_auth_ft.c b/src/ap/wpa_auth_ft.c
index c2b9aef3593d..0a6bbfaf68d7 100644
--- a/src/ap/wpa_auth_ft.c
+++ b/src/ap/wpa_auth_ft.c
@@ -2788,6 +2788,8 @@ u8 * wpa_sm_write_assoc_resp_ies(struct wpa_state_machine *sm, u8 *pos,
 	const u8 *kck;
 	size_t kck_len;
 	size_t key_len;
+	bool no_mic;
+	u8 no_mic_elem_count = 0;
 
 	if (sm == NULL)
 		return pos;
@@ -2984,10 +2986,12 @@ u8 * wpa_sm_write_assoc_resp_ies(struct wpa_state_machine *sm, u8 *pos,
 					      NULL, &psk_len, NULL))
 			key_len = psk_len;
 	}
+
+	no_mic = auth_alg == WLAN_AUTH_FT && wpa_auth_sta_ft_enc_assoc(sm);
 	res = wpa_write_ftie(conf, sm->wpa_key_mgmt, key_len,
 			     r0kh_id, r0kh_id_len,
 			     anonce, snonce, pos, end - pos,
-			     subelem, subelem_len, rsnxe_used, false);
+			     subelem, subelem_len, rsnxe_used, no_mic);
 	os_free(subelem);
 	if (res < 0)
 		return NULL;
@@ -2995,8 +2999,11 @@ u8 * wpa_sm_write_assoc_resp_ies(struct wpa_state_machine *sm, u8 *pos,
 	ftie_len = res;
 	pos += res;
 
-	if (sm->wpa_key_mgmt == WPA_KEY_MGMT_FT_SAE_EXT_KEY &&
-	    key_len == SHA512_MAC_LEN) {
+	if (no_mic) {
+		fte_mic = NULL;
+		elem_count = &no_mic_elem_count;
+	} else if (sm->wpa_key_mgmt == WPA_KEY_MGMT_FT_SAE_EXT_KEY &&
+		   key_len == SHA512_MAC_LEN) {
 		struct rsn_ftie_sha512 *_ftie =
 			(struct rsn_ftie_sha512 *) (ftie + 2);
 
@@ -3060,7 +3067,7 @@ u8 * wpa_sm_write_assoc_resp_ies(struct wpa_state_machine *sm, u8 *pos,
 		kck = sm->PTK.kck;
 		kck_len = sm->PTK.kck_len;
 	}
-	if (auth_alg == WLAN_AUTH_FT &&
+	if (auth_alg == WLAN_AUTH_FT && !no_mic &&
 	    wpa_ft_mic(sm->wpa_key_mgmt, kck, kck_len,
 		       sm->addr, sm->wpa_auth->addr, 6,
 		       mdie, mdie_len, ftie, ftie_len,
diff --git a/src/rsn_supp/wpa_ft.c b/src/rsn_supp/wpa_ft.c
index 2ea45ca80641..d3a314bb69ed 100644
--- a/src/rsn_supp/wpa_ft.c
+++ b/src/rsn_supp/wpa_ft.c
@@ -1351,8 +1351,10 @@ int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies,
 		goto fail;
 	}
 
-	if (sm->key_mgmt == WPA_KEY_MGMT_FT_SAE_EXT_KEY &&
-	    sm->pmk_r1_len == SHA512_MAC_LEN)
+	if (wpa_ft_uses_enc_assoc(sm))
+		mic_len = 0;
+	else if (sm->key_mgmt == WPA_KEY_MGMT_FT_SAE_EXT_KEY &&
+		 sm->pmk_r1_len == SHA512_MAC_LEN)
 		mic_len = 32;
 	else if ((sm->key_mgmt == WPA_KEY_MGMT_FT_SAE_EXT_KEY &&
 		  sm->pmk_r1_len == SHA384_MAC_LEN) ||
@@ -1423,6 +1425,18 @@ int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies,
 		goto fail;
 	}
 
+	if (!mic_len) {
+		if (parse.fte_elem_count) {
+			wpa_printf(MSG_DEBUG,
+				   "FT: Unexpected Element Count %u with 0 octet MIC",
+				   parse.fte_elem_count);
+
+			goto fail;
+		}
+
+		goto mic_done;
+	}
+
 	count = 3;
 	if (parse.ric)
 		count += ieee802_11_ie_count(parse.ric, parse.ric_len);
@@ -1464,6 +1478,7 @@ int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies,
 		goto fail;
 	}
 
+mic_done:
 	if (parse.fte_rsnxe_used && !sm->ap_rsnxe) {
 		wpa_printf(MSG_INFO,
 			   "FT: FTE indicated that AP uses RSNXE, but RSNXE was not included in Beacon/Probe Response frames");
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index cb351b5507e5..e96a05ac7709 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -4037,6 +4037,13 @@ static int wpas_rx_enc_assoc_resp(struct wpa_supplicant *wpa_s, const u8 *aa,
 {
 	struct ptksa_cache_entry *entry;
 
+#ifdef CONFIG_SME
+	/* The FT protocol processes the encrypted Reassociation Response */
+	if (wpa_s->sme.auth_alg == WPA_AUTH_ALG_FT &&
+	    wpa_ft_uses_enc_assoc(wpa_s->wpa))
+		return 0;
+#endif /* CONFIG_SME */
+
 	entry = ptksa_cache_get(wpa_s->ptksa, aa, wpa_s->pairwise_cipher);
 	if (!entry || (entry->auth_alg != WLAN_AUTH_EPPKE &&
 		       entry->auth_alg != WLAN_AUTH_802_1X)) {
@@ -4063,6 +4070,40 @@ static int wpas_rx_enc_assoc_resp(struct wpa_supplicant *wpa_s, const u8 *aa,
 					    entry->auth_alg,
 					    resp_ies, resp_ies_len);
 }
+
+#if defined(CONFIG_IEEE80211R) && defined(CONFIG_SME)
+
+static bool wpas_ft_sec_prof_mismatch(struct wpa_supplicant *wpa_s,
+				      const u8 *bssid, const u8 *resp_ies,
+				      size_t resp_ies_len)
+{
+	struct wpa_bss *bss;
+	const u8 *expected, *sp;
+
+	if (!wpa_s->sel_security_profile || !wpa_s->security_profile_len)
+		return false;
+
+	bss = wpa_bss_get_bssid(wpa_s, bssid);
+	if (!bss)
+		return false;
+
+	expected = wpa_bss_get_ie_ext(bss, WLAN_EID_EXT_SECURITY_PROFILE);
+	if (!expected)
+		return false;
+
+	sp = get_ie_ext(resp_ies, resp_ies_len, WLAN_EID_EXT_SECURITY_PROFILE);
+	if (!sp || sp[1] != expected[1] ||
+	    os_memcmp(sp, expected, 2 + sp[1]) != 0) {
+		wpa_printf(MSG_INFO,
+			   "FT: Security Profile element mismatch in Reassociation Response");
+
+		return true;
+	}
+
+	return false;
+}
+
+#endif /* CONFIG_IEEE80211R && CONFIG_SME */
 #endif /* CONFIG_ENC_ASSOC */
 
 
@@ -4272,6 +4313,27 @@ no_pfs:
 #ifdef CONFIG_IEEE80211R
 #ifdef CONFIG_SME
 	if (wpa_s->sme.auth_alg == WPA_AUTH_ALG_FT) {
+#ifdef CONFIG_ENC_ASSOC
+		if (wpa_ft_uses_enc_assoc(wpa_s->wpa) &&
+		    !wpa_s->assoc_resp_encrypted) {
+			wpa_printf(MSG_DEBUG,
+				   "FT: Reassociation Response was not encrypted");
+
+			wpa_supplicant_deauthenticate(wpa_s,
+						      WLAN_REASON_INVALID_IE);
+			return -1;
+		}
+
+		if (wpa_ft_uses_enc_assoc(wpa_s->wpa) && bssid_known &&
+		    wpas_ft_sec_prof_mismatch(wpa_s, bssid,
+					      data->assoc_info.resp_ies,
+					      data->assoc_info.resp_ies_len)) {
+			wpa_supplicant_deauthenticate(wpa_s,
+						      WLAN_REASON_INVALID_IE);
+			return -1;
+		}
+#endif /* CONFIG_ENC_ASSOC */
+
 		if (!bssid_known ||
 		    wpa_ft_validate_reassoc_resp(wpa_s->wpa,
 						 data->assoc_info.resp_ies,
diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c
index 981cc1205eec..08e42990100f 100644
--- a/wpa_supplicant/sme.c
+++ b/wpa_supplicant/sme.c
@@ -6201,10 +6201,15 @@ mscs_fail:
 		remove_ie(wpa_s->sme.assoc_req_ie,
 			  &wpa_s->sme.assoc_req_ie_len,
 			  WLAN_EID_FAST_BSS_TRANSITION);
+
 		/* Remove own RSNXE if AP does not advertise RSNXE to match FT
-		 * specific backwards compatibility expectations. */
+		 * specific backwards compatibility expectations, or if the FT
+		 * elements already include it.
+		 */
 		if (!wpa_bss_get_rsnxe(wpa_s, wpa_s->current_bss, ssid,
-				       wpa_s->valid_links))
+				       wpa_s->valid_links) ||
+		    get_ie(wpa_s->sme.ft_ies, wpa_s->sme.ft_ies_len,
+			   WLAN_EID_RSNX))
 			remove_ie(wpa_s->sme.assoc_req_ie,
 				  &wpa_s->sme.assoc_req_ie_len,
 				  WLAN_EID_RSNX);
-- 
2.55.0




More information about the Hostap mailing list