[PATCH 32/55] wpa_supplicant: Support PMKR0Name privacy in FT
Ilan Peer
ilan.peer at intel.com
Thu Dec 3 02:44:31 PST 2026
Section 12.16.7.3 in Draft IEEE P802.11bi/D6.0 requires the S0KH
to recompute the PMKR0Name after a successful FT when both the STA
and the target AP support PMKSA caching privacy and association
frame encryption is used.
Recompute the PMKR0Name once the FT reassociation completes so that
the next FT Authentication frame indicates a new PMKR0Name.
The PMKR1Name is not recomputed once derived, so record the PMKR1Name
used with each R1KH and reuse it in later FT and FT PASN exchanges with
that R1KH.
Do not derive the PMK-R0 again on a PTK rekey after FT, since that would
restore the original PMKR0Name.
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
src/rsn_supp/wpa.c | 5 ++
src/rsn_supp/wpa_ft.c | 120 +++++++++++++++++++++++++++++++++++++++---
src/rsn_supp/wpa_i.h | 15 ++++++
3 files changed, 134 insertions(+), 6 deletions(-)
diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c
index 115cacb63170..4a6df8946ea0 100644
--- a/src/rsn_supp/wpa.c
+++ b/src/rsn_supp/wpa.c
@@ -6200,6 +6200,11 @@ void wpa_sm_drop_sa(struct wpa_sm *sm)
sm->pasn_r1kh = NULL;
sm->n_pasn_r1kh = 0;
#endif /* CONFIG_PASN */
+#ifdef CONFIG_PMKSA_PRIVACY
+ os_free(sm->ft_r1_names);
+ sm->ft_r1_names = NULL;
+ sm->ft_n_r1_names = 0;
+#endif /* CONFIG_PMKSA_PRIVACY */
#endif /* CONFIG_IEEE80211R */
}
diff --git a/src/rsn_supp/wpa_ft.c b/src/rsn_supp/wpa_ft.c
index d3a314bb69ed..d1d33de8b5d6 100644
--- a/src/rsn_supp/wpa_ft.c
+++ b/src/rsn_supp/wpa_ft.c
@@ -35,6 +35,70 @@ static void wpa_ft_pasn_store_r1kh(struct wpa_sm *sm, const u8 *bssid)
#endif /* CONFIG_PASN */
+#ifdef CONFIG_PMKSA_PRIVACY
+
+static const u8 * wpa_ft_get_r1_name(const struct wpa_sm *sm,
+ const u8 *r1kh_id)
+{
+ size_t i;
+
+ for (i = 0; i < sm->ft_n_r1_names; i++) {
+ if (os_memcmp(sm->ft_r1_names[i].r1kh_id, r1kh_id,
+ FT_R1KH_ID_LEN) == 0)
+ return sm->ft_r1_names[i].pmk_r1_name;
+ }
+
+ return NULL;
+}
+
+
+static void wpa_ft_set_r1_name(struct wpa_sm *sm, const u8 *r1kh_id,
+ const u8 *pmk_r1_name)
+{
+ struct ft_r1_name *tmp;
+
+ /* PMKR1Name is not recomputed once derived */
+ if (wpa_ft_get_r1_name(sm, r1kh_id))
+ return;
+
+ tmp = os_realloc_array(sm->ft_r1_names, sm->ft_n_r1_names + 1,
+ sizeof(*tmp));
+ if (!tmp)
+ return;
+
+ sm->ft_r1_names = tmp;
+ tmp = &sm->ft_r1_names[sm->ft_n_r1_names++];
+ os_memcpy(tmp->r1kh_id, r1kh_id, FT_R1KH_ID_LEN);
+ os_memcpy(tmp->pmk_r1_name, pmk_r1_name, WPA_PMK_NAME_LEN);
+}
+
+#endif /* CONFIG_PMKSA_PRIVACY */
+
+
+static int wpa_ft_derive_pmk_r1(struct wpa_sm *sm, const u8 *r1kh_id,
+ u8 *pmk_r1, u8 *pmk_r1_name)
+{
+#ifdef CONFIG_PMKSA_PRIVACY
+ const u8 *name;
+#endif /* CONFIG_PMKSA_PRIVACY */
+
+ if (wpa_derive_pmk_r1(sm->pmk_r0, sm->pmk_r0_len, sm->pmk_r0_name,
+ r1kh_id, sm->own_addr, pmk_r1, pmk_r1_name) < 0)
+ return -1;
+
+#ifdef CONFIG_PMKSA_PRIVACY
+ name = wpa_ft_get_r1_name(sm, r1kh_id);
+ if (name) {
+ os_memcpy(pmk_r1_name, name, WPA_PMK_NAME_LEN);
+ wpa_hexdump(MSG_DEBUG, "FT: Use the first PMKR1Name",
+ pmk_r1_name, WPA_PMK_NAME_LEN);
+ }
+#endif /* CONFIG_PMKSA_PRIVACY */
+
+ return 0;
+}
+
+
int wpa_derive_ptk_ft(struct wpa_sm *sm, const unsigned char *src_addr,
const struct wpa_eapol_key *key, struct wpa_ptk *ptk)
{
@@ -45,6 +109,15 @@ int wpa_derive_ptk_ft(struct wpa_sm *sm, const unsigned char *src_addr,
size_t mpmk_len, kdk_len;
int ret = 0;
+ /*
+ * PTK rekey after a fast BSS transition: use the PMK-R1 of the current
+ * association. Deriving it again from the XXKey would give the
+ * PMKR0Name of the FT initial mobility domain association, which may
+ * have been changed with PMKR0Name privacy.
+ */
+ if (sm->ft_protocol && sm->pmk_r1_len)
+ goto pmk_r1_derived;
+
if (sm->xxkey_len > 0) {
mpmk = sm->xxkey;
mpmk_len = sm->xxkey_len;
@@ -72,6 +145,12 @@ int wpa_derive_ptk_ft(struct wpa_sm *sm, const unsigned char *src_addr,
sm->pmk_r1_name) < 0)
return -1;
+#ifdef CONFIG_PMKSA_PRIVACY
+ sm->ft_n_r1_names = 0;
+ wpa_ft_set_r1_name(sm, sm->r1kh_id, sm->pmk_r1_name);
+#endif /* CONFIG_PMKSA_PRIVACY */
+
+pmk_r1_derived:
wpa_ft_pasn_store_r1kh(sm, src_addr);
if (sm->force_kdk_derivation ||
@@ -131,6 +210,11 @@ int wpa_sm_802_1x_ft_pmk_to_ptk(struct wpa_sm *sm, const u8 *xxkey,
sm->pmk_r1_name) < 0)
return -1;
+#ifdef CONFIG_PMKSA_PRIVACY
+ sm->ft_n_r1_names = 0;
+ wpa_ft_set_r1_name(sm, sm->r1kh_id, sm->pmk_r1_name);
+#endif /* CONFIG_PMKSA_PRIVACY */
+
if (wpa_pmk_r1_to_ptk(sm->pmk_r1, sm->pmk_r1_len, snonce, anonce,
sm->own_addr, aa, sm->pmk_r1_name,
dhss, dhss_len, ptk, ptk_name, akmp, cipher,
@@ -959,9 +1043,8 @@ int wpa_ft_process_response(struct wpa_sm *sm, const u8 *ies, size_t ies_len,
wpa_hexdump(MSG_DEBUG, "FT: SNonce", sm->snonce, WPA_NONCE_LEN);
wpa_hexdump(MSG_DEBUG, "FT: ANonce", parse.fte_anonce, WPA_NONCE_LEN);
os_memcpy(sm->anonce, parse.fte_anonce, WPA_NONCE_LEN);
- if (wpa_derive_pmk_r1(sm->pmk_r0, sm->pmk_r0_len, sm->pmk_r0_name,
- sm->r1kh_id, sm->own_addr, sm->pmk_r1,
- sm->pmk_r1_name) < 0)
+ if (wpa_ft_derive_pmk_r1(sm, sm->r1kh_id, sm->pmk_r1,
+ sm->pmk_r1_name) < 0)
goto fail;
sm->pmk_r1_len = sm->pmk_r0_len;
if (sm->pmk_r1_len == SHA512_MAC_LEN)
@@ -1575,6 +1658,32 @@ mic_done:
* using wpa_supplicant SME */
}
+#ifdef CONFIG_PMKSA_PRIVACY
+ /* Handle PMKR0Name Privacy: Recompute PMKR0Name if necessary */
+ if (wpa_ft_uses_enc_assoc(sm) && sm->pmksa_privacy &&
+ !wpa_key_mgmt_fils(sm->key_mgmt) &&
+ ieee802_11_rsnx_capab(sm->ap_rsnxe,
+ WLAN_RSNX_CAPAB_PMKSA_CACHING_PRIVACY)) {
+ const u8 *xxkey = sm->xxkey;
+ size_t xxkey_len = sm->xxkey_len;
+
+ wpa_ft_set_r1_name(sm, sm->r1kh_id, sm->pmk_r1_name);
+
+ if (!xxkey_len && sm->cur_pmksa) {
+ xxkey = sm->cur_pmksa->pmk;
+ xxkey_len = sm->cur_pmksa->pmk_len;
+ }
+
+ if (!xxkey_len ||
+ wpa_derive_pmk_r0_name_privacy(xxkey, xxkey_len,
+ sm->anonce, sm->snonce,
+ sm->key_mgmt,
+ sm->pmk_r0_name) < 0)
+ wpa_printf(MSG_DEBUG,
+ "FT: Failed to update the PMKR0Name");
+ }
+#endif /* CONFIG_PMKSA_PRIVACY */
+
wpa_printf(MSG_DEBUG, "FT: Completed successfully");
ret = 0;
@@ -1699,9 +1808,8 @@ int wpa_pasn_ft_derive_pmk_r1(struct wpa_sm *sm, int akmp, const u8 *bssid,
* state machine, and as the same key hierarchy is used, there is no
* need to derive them again, so only derive PMK R1 etc.
*/
- if (wpa_derive_pmk_r1(sm->pmk_r0, sm->pmk_r0_len, sm->pmk_r0_name,
- r1kh_entry->r1kh_id, sm->own_addr, pmk_r1,
- pmk_r1_name) < 0)
+ if (wpa_ft_derive_pmk_r1(sm, r1kh_entry->r1kh_id, pmk_r1,
+ pmk_r1_name) < 0)
return -1;
*pmk_r1_len = sm->pmk_r0_len;
diff --git a/src/rsn_supp/wpa_i.h b/src/rsn_supp/wpa_i.h
index d956aba3570d..c2d17bda4b7f 100644
--- a/src/rsn_supp/wpa_i.h
+++ b/src/rsn_supp/wpa_i.h
@@ -19,6 +19,11 @@ struct pasn_ft_r1kh {
u8 r1kh_id[FT_R1KH_ID_LEN];
};
+struct ft_r1_name {
+ u8 r1kh_id[FT_R1KH_ID_LEN];
+ u8 pmk_r1_name[WPA_PMK_NAME_LEN];
+};
+
/**
* struct wpa_sm - Internal WPA state machine data
*/
@@ -212,6 +217,16 @@ struct wpa_sm {
struct pasn_ft_r1kh *pasn_r1kh;
unsigned int n_pasn_r1kh;
#endif /* CONFIG_PASN */
+#ifdef CONFIG_PMKSA_PRIVACY
+ /*
+ * PMKR1Name derived with each R1KH. With PMKR0Name privacy, the
+ * PMKR0Name changes after every fast BSS transition, but the
+ * PMKR1Name is not recomputed once derived. Keep the first one to use
+ * it again with the same R1KH.
+ */
+ struct ft_r1_name *ft_r1_names;
+ size_t ft_n_r1_names;
+#endif /* CONFIG_PMKSA_PRIVACY */
#endif /* CONFIG_IEEE80211R */
u16 pasn_group;
--
2.55.0
More information about the Hostap
mailing list