[PATCH 30/55] AP: Process PMKR0Name update RRB messages

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


Add an RRB message from the R1KH to the R0KH carrying the old PMKR0Name,
the PMKR1Name and the nonces of an FT transition with PMKR0Name privacy
(IEEE P802.11bi/D6.0, 12.16.7.3). The R0KH renames the matching PMK-R0
SA.

This adds only the R0KH side, i.e., receiving and processing the
message; the R1KH does not send it yet.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 src/ap/hostapd.h       |   3 ++
 src/ap/wpa_auth.h      |   4 ++
 src/ap/wpa_auth_ft.c   | 105 +++++++++++++++++++++++++++++++++++++++++
 src/ap/wpa_auth_glue.c |  16 +++++++
 4 files changed, 128 insertions(+)

diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
index 3055f7de8f08..262a66c33d65 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -265,6 +265,9 @@ struct hostapd_data {
 	struct eth_p_oui_ctx *oui_push;
 	struct eth_p_oui_ctx *oui_sreq;
 	struct eth_p_oui_ctx *oui_sresp;
+#ifdef CONFIG_PMKSA_PRIVACY
+	struct eth_p_oui_ctx *oui_r0name;
+#endif /* CONFIG_PMKSA_PRIVACY */
 #endif /* CONFIG_IEEE80211R_AP */
 
 	struct wps_context *wps;
diff --git a/src/ap/wpa_auth.h b/src/ap/wpa_auth.h
index ad57fe483dd1..0091cfb453fc 100644
--- a/src/ap/wpa_auth.h
+++ b/src/ap/wpa_auth.h
@@ -48,6 +48,7 @@ struct ft_rrb_frame {
 #define FT_PACKET_R0KH_R1KH_PUSH 0x03
 #define FT_PACKET_R0KH_R1KH_SEQ_REQ 0x04
 #define FT_PACKET_R0KH_R1KH_SEQ_RESP 0x05
+#define FT_PACKET_R0KH_R1KH_R0NAME_UPDATE 0x06
 
 /* packet layout
  *  IEEE 802 extended OUI ethertype frame header
@@ -89,6 +90,9 @@ struct ft_rrb_frame {
 #define FT_RRB_RADIUS_CUI    16
 #define FT_RRB_SESSION_TIMEOUT  17 /* le32 seconds */
 
+#define FT_RRB_ANONCE        18 /* WPA_NONCE_LEN */
+#define FT_RRB_SNONCE        19 /* WPA_NONCE_LEN */
+
 struct ft_rrb_tlv {
 	le16 type;
 	le16 len;
diff --git a/src/ap/wpa_auth_ft.c b/src/ap/wpa_auth_ft.c
index 9fd324267d8b..009a6c4ba0dc 100644
--- a/src/ap/wpa_auth_ft.c
+++ b/src/ap/wpa_auth_ft.c
@@ -5208,6 +5208,105 @@ static int wpa_ft_rrb_rx_push(struct wpa_authenticator *wpa_auth,
 	return 0;
 }
 
+#ifdef CONFIG_PMKSA_PRIVACY
+
+static int wpa_ft_rrb_rx_r0_name_update(struct wpa_authenticator *wpa_auth,
+					const u8 *src_addr,
+					const u8 *enc, size_t enc_len,
+					const u8 *auth, size_t auth_len,
+					int no_defer)
+{
+	const char *msgtype = "PMKR0Name update";
+	u8 *plain = NULL;
+	size_t plain_len = 0;
+	struct ft_remote_r1kh *r1kh, *r1kh_wildcard;
+	const u8 *key;
+	size_t key_len;
+	int seq_ret;
+	const u8 *f_r0kh_id, *f_r1kh_id, *f_s1kh_id, *f_pmk_r0_name;
+	const u8 *f_anonce, *f_snonce, *f_pmk_r1_name;
+	size_t f_r0kh_id_len, f_r1kh_id_len, f_s1kh_id_len;
+	size_t f_pmk_r0_name_len, f_anonce_len, f_snonce_len;
+	size_t f_pmk_r1_name_len;
+
+	wpa_printf(MSG_DEBUG, "FT: Received PMKR0Name update");
+
+	RRB_GET_AUTH(FT_RRB_R0KH_ID, r0kh_id, msgtype, -1);
+	wpa_hexdump(MSG_DEBUG, "FT: R0KH-ID", f_r0kh_id, f_r0kh_id_len);
+
+	if (wpa_ft_rrb_check_r0kh(wpa_auth, f_r0kh_id, f_r0kh_id_len)) {
+		wpa_printf(MSG_DEBUG, "FT: R0KH-ID mismatch");
+		goto out;
+	}
+
+	RRB_GET_AUTH(FT_RRB_R1KH_ID, r1kh_id, msgtype, FT_R1KH_ID_LEN);
+	wpa_hexdump(MSG_DEBUG, "FT: R1KH-ID", f_r1kh_id, f_r1kh_id_len);
+
+	wpa_ft_rrb_lookup_r1kh(wpa_auth, f_r1kh_id, &r1kh, &r1kh_wildcard);
+	if (r1kh) {
+		key = r1kh->key;
+		key_len = sizeof(r1kh->key);
+	} else if (r1kh_wildcard) {
+		wpa_printf(MSG_DEBUG, "FT: Using wildcard R1KH-ID");
+		key = r1kh_wildcard->key;
+		key_len = sizeof(r1kh_wildcard->key);
+	} else {
+		goto out;
+	}
+
+	seq_ret = FT_RRB_SEQ_DROP;
+	if (r1kh)
+		seq_ret = wpa_ft_rrb_seq_chk(r1kh->seq, src_addr, enc, enc_len,
+					     auth, auth_len, msgtype, no_defer);
+
+	if (!no_defer && r1kh_wildcard &&
+	    (!r1kh || !ether_addr_equal(r1kh->addr, src_addr)))
+		seq_ret = FT_RRB_SEQ_DEFER;
+
+	if (seq_ret == FT_RRB_SEQ_DROP)
+		goto out;
+
+	if (wpa_ft_rrb_decrypt(key, key_len, enc, enc_len, auth, auth_len,
+			       src_addr, FT_PACKET_R0KH_R1KH_R0NAME_UPDATE,
+			       &plain, &plain_len) < 0)
+		goto out;
+
+	if (!r1kh)
+		r1kh = wpa_ft_rrb_add_r1kh(wpa_auth, r1kh_wildcard, src_addr,
+					   f_r1kh_id,
+					   wpa_auth->conf.rkh_pos_timeout);
+	if (!r1kh)
+		goto out;
+
+	if (seq_ret == FT_RRB_SEQ_DEFER) {
+		wpa_ft_rrb_seq_req(wpa_auth, r1kh->seq, src_addr, f_r0kh_id,
+				   f_r0kh_id_len, f_r1kh_id, key, key_len,
+				   enc, enc_len, auth, auth_len,
+				   &wpa_ft_rrb_rx_r0_name_update);
+		goto out;
+	}
+
+	wpa_ft_rrb_seq_accept(wpa_auth, r1kh->seq, src_addr, auth, auth_len,
+			      msgtype);
+	wpa_ft_rrb_r1kh_replenish(wpa_auth, r1kh,
+				  wpa_auth->conf.rkh_pos_timeout);
+
+	RRB_GET(FT_RRB_S1KH_ID, s1kh_id, msgtype, ETH_ALEN);
+	RRB_GET(FT_RRB_PMK_R0_NAME, pmk_r0_name, msgtype, WPA_PMK_NAME_LEN);
+	RRB_GET(FT_RRB_ANONCE, anonce, msgtype, WPA_NONCE_LEN);
+	RRB_GET(FT_RRB_SNONCE, snonce, msgtype, WPA_NONCE_LEN);
+	RRB_GET(FT_RRB_PMK_R1_NAME, pmk_r1_name, msgtype, WPA_PMK_NAME_LEN);
+
+	wpa_ft_rename_pmk_r0(wpa_auth, f_s1kh_id, f_pmk_r0_name, f_r1kh_id,
+			     f_pmk_r1_name, f_anonce, f_snonce);
+
+out:
+	os_free(plain);
+
+	return 0;
+}
+
+#endif /* CONFIG_PMKSA_PRIVACY */
 
 static int wpa_ft_rrb_rx_seq(struct wpa_authenticator *wpa_auth,
 			     const u8 *src_addr, int type,
@@ -5672,6 +5771,12 @@ void wpa_ft_rrb_oui_rx(struct wpa_authenticator *wpa_auth, const u8 *src_addr,
 		wpa_ft_rrb_rx_seq_resp(wpa_auth, src_addr, enc, elen, auth,
 				       alen, no_defer);
 		break;
+#ifdef CONFIG_PMKSA_PRIVACY
+	case FT_PACKET_R0KH_R1KH_R0NAME_UPDATE:
+		wpa_ft_rrb_rx_r0_name_update(wpa_auth, src_addr, enc, elen,
+					     auth, alen, no_defer);
+		break;
+#endif /* CONFIG_PMKSA_PRIVACY */
 	}
 }
 
diff --git a/src/ap/wpa_auth_glue.c b/src/ap/wpa_auth_glue.c
index 603da9b1a8e5..32ab00f5628c 100644
--- a/src/ap/wpa_auth_glue.c
+++ b/src/ap/wpa_auth_glue.c
@@ -975,6 +975,10 @@ static struct eth_p_oui_ctx * hostapd_wpa_get_oui(struct hostapd_data *hapd,
 		return hapd->oui_sreq;
 	case FT_PACKET_R0KH_R1KH_SEQ_RESP:
 		return hapd->oui_sresp;
+#ifdef CONFIG_PMKSA_PRIVACY
+	case FT_PACKET_R0KH_R1KH_R0NAME_UPDATE:
+		return hapd->oui_r0name;
+#endif /* CONFIG_PMKSA_PRIVACY */
 #endif /* CONFIG_IEEE80211R_AP */
 	default:
 		return NULL;
@@ -1657,6 +1661,14 @@ static int hostapd_wpa_register_ft_oui(struct hostapd_data *hapd,
 	if (!hapd->oui_sresp)
 		return -1;
 
+#ifdef CONFIG_PMKSA_PRIVACY
+	hapd->oui_r0name = eth_p_oui_register(hapd, ft_iface,
+					      FT_PACKET_R0KH_R1KH_R0NAME_UPDATE,
+					      hostapd_rrb_oui_receive, hapd);
+	if (!hapd->oui_r0name)
+		return -1;
+#endif /* CONFIG_PMKSA_PRIVACY */
+
 	return 0;
 }
 
@@ -1673,6 +1685,10 @@ static void hostapd_wpa_unregister_ft_oui(struct hostapd_data *hapd)
 	hapd->oui_sreq = NULL;
 	eth_p_oui_unregister(hapd->oui_sresp);
 	hapd->oui_sresp = NULL;
+#ifdef CONFIG_PMKSA_PRIVACY
+	eth_p_oui_unregister(hapd->oui_r0name);
+	hapd->oui_r0name = NULL;
+#endif /* CONFIG_PMKSA_PRIVACY */
 }
 #endif /* CONFIG_IEEE80211R_AP */
 
-- 
2.55.0




More information about the Hostap mailing list