[PATCH 29/55] AP: Rename the local PMK-R0 SA after FT with PMKR0Name privacy

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


When both the FTO and the target FTR support PMKSA caching privacy,
the PMKR0Name is recomputed from the ANonce and SNonce after a
successful FT reassociation.

Remember the PMKR0Name indicated in the FT Authentication frame and
rename the PMK-R0 SA once the FT reassociation completes, if this AP is
also the R0KH.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 src/ap/wpa_auth.c    |  3 ++
 src/ap/wpa_auth_ft.c | 74 ++++++++++++++++++++++++++++++++++++++++++++
 src/ap/wpa_auth_i.h  |  8 +++++
 3 files changed, 85 insertions(+)

diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c
index bd16aac765de..f5e0c9495834 100644
--- a/src/ap/wpa_auth.c
+++ b/src/ap/wpa_auth.c
@@ -2584,6 +2584,9 @@ int wpa_auth_sm_event(struct wpa_state_machine *sm, enum wpa_event event)
 		/* Using FT protocol, not WPA auth state machine */
 		sm->ft_completed = 1;
 		wpa_auth_set_ptk_rekey_timer(sm);
+#ifdef CONFIG_PMKSA_PRIVACY
+		wpa_ft_update_pmk_r0_name(sm);
+#endif /* CONFIG_PMKSA_PRIVACY */
 		return 0;
 #else /* CONFIG_IEEE80211R_AP */
 		break;
diff --git a/src/ap/wpa_auth_ft.c b/src/ap/wpa_auth_ft.c
index 166fa0531e0f..9fd324267d8b 100644
--- a/src/ap/wpa_auth_ft.c
+++ b/src/ap/wpa_auth_ft.c
@@ -1643,6 +1643,41 @@ static void wpa_ft_set_r1_name(struct wpa_ft_pmk_r0_sa *r0,
 }
 
 
+static int wpa_ft_rename_pmk_r0(struct wpa_authenticator *wpa_auth,
+				const u8 *spa, const u8 *pmk_r0_name,
+				const u8 *r1kh_id, const u8 *pmk_r1_name,
+				const u8 *anonce, const u8 *snonce)
+{
+	struct wpa_ft_pmk_r0_sa *r0;
+	u8 new_name[WPA_PMK_NAME_LEN];
+
+	r0 = wpa_ft_find_pmk_r0(wpa_auth, spa, pmk_r0_name);
+	if (!r0) {
+		wpa_printf(MSG_DEBUG,
+			   "FT: No PMK-R0 to update the PMKR0Name for STA "
+			   MACSTR, MAC2STR(spa));
+		return -1;
+	}
+
+	if (!r0->xxkey_len) {
+		wpa_printf(MSG_DEBUG, "FT: No XXKey for PMKR0Name privacy");
+		return -1;
+	}
+
+	if (wpa_derive_pmk_r0_name_privacy(r0->xxkey, r0->xxkey_len,
+					   anonce, snonce, r0->key_mgmt,
+					   new_name) < 0)
+		return -1;
+
+	wpa_ft_set_r1_name(r0, r1kh_id, pmk_r1_name);
+	os_memcpy(r0->pmk_r0_name, new_name, WPA_PMK_NAME_LEN);
+	wpa_printf(MSG_DEBUG, "FT: Updated PMKR0Name for STA " MACSTR,
+		   MAC2STR(spa));
+
+	return 0;
+}
+
+
 static const u8 * wpa_ft_get_pmk_r1_name(struct wpa_authenticator *wpa_auth,
 					 const u8 *spa, const u8 *pmk_r0_name)
 {
@@ -2343,6 +2378,38 @@ static int wpa_ft_pull_pmk_r1(struct wpa_state_machine *sm,
 	return 0;
 }
 
+#ifdef CONFIG_PMKSA_PRIVACY
+
+/*
+ * After a successful FT reassociation, the R1KH sends the ANonce and SNonce to
+ * the R0KH and the PMKR0Name is recomputed.
+ */
+void wpa_ft_update_pmk_r0_name(struct wpa_state_machine *sm)
+{
+	struct wpa_auth_config *conf = &sm->wpa_auth->conf;
+
+	if (!sm->ft_pmk_r0_name_valid)
+		return;
+
+	sm->ft_pmk_r0_name_valid = false;
+
+	/* TODO: Support FILS and FT-PSK with locally generated keys */
+	if (!sm->ft_enc_assoc || !wpa_auth_ap_sta_support_pmkid_privacy(sm) ||
+	    wpa_key_mgmt_fils(sm->wpa_key_mgmt) ||
+	    (conf->ft_psk_generate_local &&
+	     wpa_key_mgmt_ft_psk(sm->wpa_key_mgmt)))
+		return;
+
+	if (!wpa_ft_rrb_check_r0kh(sm->wpa_auth, sm->r0kh_id,
+				   sm->r0kh_id_len)) {
+		wpa_ft_rename_pmk_r0(sm->wpa_auth, sm->addr, sm->ft_pmk_r0_name,
+				     conf->r1_key_holder, sm->pmk_r1_name,
+				     sm->ANonce, sm->SNonce);
+		return;
+	}
+}
+
+#endif /* CONFIG_PMKSA_PRIVACY */
 
 int wpa_ft_store_pmk_fils(struct wpa_state_machine *sm,
 			  const u8 *pmk_r0, const u8 *pmk_r0_name)
@@ -3724,6 +3791,9 @@ static int wpa_ft_process_auth_req(struct wpa_state_machine *sm,
 	*resp_ies_len = 0;
 
 	sm->pmk_r1_name_valid = 0;
+#ifdef CONFIG_PMKSA_PRIVACY
+	sm->ft_pmk_r0_name_valid = false;
+#endif /* CONFIG_PMKSA_PRIVACY */
 	conf = &sm->wpa_auth->conf;
 
 	wpa_hexdump(MSG_DEBUG, "FT: Received authentication frame IEs",
@@ -3909,6 +3979,10 @@ pmk_r1_derived:
 	os_memcpy(sm->pmk_r1_name, pmk_r1_name, WPA_PMK_NAME_LEN);
 	os_memcpy(sm->pmk_r1, pmk_r1, pmk_r1_len);
 	sm->pmk_r1_len = pmk_r1_len;
+#ifdef CONFIG_PMKSA_PRIVACY
+	os_memcpy(sm->ft_pmk_r0_name, parse.rsn_pmkid, WPA_PMK_NAME_LEN);
+	sm->ft_pmk_r0_name_valid = true;
+#endif /* CONFIG_PMKSA_PRIVACY */
 
 	/*
 	 * Make sure the pairwise suite indicate by the STA matches the one that
diff --git a/src/ap/wpa_auth_i.h b/src/ap/wpa_auth_i.h
index 3f5c4538f2e6..1efbe58c5951 100644
--- a/src/ap/wpa_auth_i.h
+++ b/src/ap/wpa_auth_i.h
@@ -148,6 +148,11 @@ struct wpa_state_machine {
 	bool ft_over_air;
 #endif /* CONFIG_ENC_ASSOC */
 
+#ifdef CONFIG_PMKSA_PRIVACY
+	u8 ft_pmk_r0_name[WPA_PMK_NAME_LEN];
+	bool ft_pmk_r0_name_valid;
+#endif /* CONFIG_PMKSA_PRIVACY */
+
 	void (*ft_pending_cb)(void *ctx, const u8 *dst,
 			      u16 auth_transaction, u16 status,
 			      const u8 *ies, size_t ies_len);
@@ -364,6 +369,9 @@ bool wpa_ft_pmk_cache_radius_das_disconnect(
 void wpa_ft_pmk_cache_remove(struct wpa_ft_pmk_cache *cache,
 			     const u8 *sta_addr);
 void wpa_ft_install_ptk(struct wpa_state_machine *sm, int retry);
+#ifdef CONFIG_PMKSA_PRIVACY
+void wpa_ft_update_pmk_r0_name(struct wpa_state_machine *sm);
+#endif /* CONFIG_PMKSA_PRIVACY */
 int wpa_ft_store_pmk_fils(struct wpa_state_machine *sm, const u8 *pmk_r0,
 			  const u8 *pmk_r0_name);
 #endif /* CONFIG_IEEE80211R_AP */
-- 
2.55.0




More information about the Hostap mailing list