[PATCH 34/55] AP: Support a new STA MAC address with PMKR0Name privacy in FT
Ilan Peer
ilan.peer at intel.com
Thu Dec 3 02:44:33 PST 2026
According to Note 2 in Section 12.16.7.3 in Draft IEEE P802.11bi/D6.0,
the STA needs to use a new MAC address together with the new PMKR0Name
for the privacy to be effective. However, as the PMK-R0 and PMK-R1 SAs
are looked up with the current STA address, FT with a new MAC address
would fail.
With PMKSA caching privacy, identify the PMK-R0 SA and the PMK-R1 SA by
PMKR0Name only (see Section 13.5.2). The S1KH-ID is the SPA used when
the PMK-R0 was derived, so always derive the PMK-R1 with the SPA stored
in the PMK-R0 SA. The PTK is still derived with the current STA address.
Without PMKSA caching privacy the stored SPA is the same as the current
STA address, so there is no change in behavior.
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
src/ap/wpa_auth_ft.c | 67 +++++++++++++++++++++++++++++---------------
1 file changed, 45 insertions(+), 22 deletions(-)
diff --git a/src/ap/wpa_auth_ft.c b/src/ap/wpa_auth_ft.c
index 3b415a2c650b..0b59ccee07fa 100644
--- a/src/ap/wpa_auth_ft.c
+++ b/src/ap/wpa_auth_ft.c
@@ -1564,6 +1564,23 @@ static int wpa_ft_store_pmk_r0(struct wpa_authenticator *wpa_auth,
}
+static bool wpa_ft_pmk_r0_name_match(const struct wpa_ft_pmk_r0_sa *r0,
+ const u8 *spa, const u8 *pmk_r0_name)
+{
+ if (os_memcmp_const(r0->pmk_r0_name, pmk_r0_name,
+ WPA_PMK_NAME_LEN) != 0)
+ return false;
+
+#ifdef CONFIG_PMKSA_PRIVACY
+ /* The STA may use a new MAC address with a rotated PMKR0Name */
+ if (r0->xxkey_len)
+ return true;
+#endif /* CONFIG_PMKSA_PRIVACY */
+
+ return ether_addr_equal(r0->spa, spa);
+}
+
+
static int wpa_ft_fetch_pmk_r0(struct wpa_authenticator *wpa_auth,
const u8 *spa, const u8 *pmk_r0_name,
const struct wpa_ft_pmk_r0_sa **r0_out)
@@ -1574,9 +1591,7 @@ static int wpa_ft_fetch_pmk_r0(struct wpa_authenticator *wpa_auth,
os_get_reltime(&now);
dl_list_for_each(r0, &cache->pmk_r0, struct wpa_ft_pmk_r0_sa, list) {
- if (ether_addr_equal(r0->spa, spa) &&
- os_memcmp_const(r0->pmk_r0_name, pmk_r0_name,
- WPA_PMK_NAME_LEN) == 0) {
+ if (wpa_ft_pmk_r0_name_match(r0, spa, pmk_r0_name)) {
*r0_out = r0;
return 0;
}
@@ -1597,9 +1612,7 @@ wpa_ft_find_pmk_r0(struct wpa_authenticator *wpa_auth, const u8 *spa,
struct wpa_ft_pmk_r0_sa *r0;
dl_list_for_each(r0, &cache->pmk_r0, struct wpa_ft_pmk_r0_sa, list) {
- if (ether_addr_equal(r0->spa, spa) &&
- os_memcmp_const(r0->pmk_r0_name, pmk_r0_name,
- WPA_PMK_NAME_LEN) == 0)
+ if (wpa_ft_pmk_r0_name_match(r0, spa, pmk_r0_name))
return r0;
}
@@ -1679,16 +1692,22 @@ static int wpa_ft_rename_pmk_r0(struct wpa_authenticator *wpa_auth,
static const u8 * wpa_ft_get_pmk_r1_name(struct wpa_authenticator *wpa_auth,
- const u8 *spa, const u8 *pmk_r0_name)
+ const u8 *pmk_r0_name,
+ const u8 **spa)
{
struct wpa_ft_pmk_cache *cache = wpa_auth->ft_pmk_cache;
struct wpa_ft_pmk_r1_sa *r1;
+ /*
+ * According to Section 13.5.2 in Draft IEEE P802.11bi/D6.0, the PMK-R1
+ * is identified by PMKR0Name only
+ */
dl_list_for_each(r1, &cache->pmk_r1, struct wpa_ft_pmk_r1_sa, list) {
- if (ether_addr_equal(r1->spa, spa) &&
- os_memcmp_const(r1->pmk_r0_name, pmk_r0_name,
- WPA_PMK_NAME_LEN) == 0)
+ if (os_memcmp_const(r1->pmk_r0_name, pmk_r0_name,
+ WPA_PMK_NAME_LEN) == 0) {
+ *spa = r1->spa;
return r1->pmk_r1_name;
+ }
}
return NULL;
@@ -1698,15 +1717,19 @@ static const u8 * wpa_ft_get_pmk_r1_name(struct wpa_authenticator *wpa_auth,
static int wpa_ft_r0_derive_pmk_r1(const struct wpa_ft_pmk_r0_sa *r0,
- const u8 *r1kh_id, const u8 *s1kh_id,
+ const u8 *r1kh_id,
u8 *pmk_r1, u8 *pmk_r1_name)
{
#ifdef CONFIG_PMKSA_PRIVACY
const u8 *name;
#endif /* CONFIG_PMKSA_PRIVACY */
+ /*
+ * S1KH-ID is the SPA when the PMK-R0 was derived (Section 12.7.1.6.4
+ * in Draft IEEE P802.11bi/D6.0)
+ */
if (wpa_derive_pmk_r1(r0->pmk_r0, r0->pmk_r0_len, r0->pmk_r0_name,
- r1kh_id, s1kh_id, pmk_r1, pmk_r1_name) < 0)
+ r1kh_id, r0->spa, pmk_r1, pmk_r1_name) < 0)
return -1;
#ifdef CONFIG_PMKSA_PRIVACY
@@ -3676,7 +3699,7 @@ static int wpa_ft_local_derive_pmk_r1(struct wpa_authenticator *wpa_auth,
wpa_printf(MSG_DEBUG, "FT: Requested PMKR0Name found in local cache");
- if (wpa_ft_r0_derive_pmk_r1(r0, conf->r1_key_holder, sm->addr,
+ if (wpa_ft_r0_derive_pmk_r1(r0, conf->r1_key_holder,
out_pmk_r1, out_pmk_r1_name) < 0)
return -1;
@@ -3687,7 +3710,7 @@ static int wpa_ft_local_derive_pmk_r1(struct wpa_authenticator *wpa_auth,
if (r0->session_timeout)
session_timeout = r0->session_timeout - now.sec;
- wpa_ft_store_pmk_r1(wpa_auth, sm->addr, out_pmk_r1, r0->pmk_r0_len,
+ wpa_ft_store_pmk_r1(wpa_auth, r0->spa, out_pmk_r1, r0->pmk_r0_len,
out_pmk_r1_name, r0->pmk_r0_name,
sm->pairwise, r0->vlan, expires_in, session_timeout,
r0->identity, r0->identity_len,
@@ -3969,13 +3992,13 @@ static int wpa_ft_process_auth_req(struct wpa_state_machine *sm,
if (conf->pmksa_caching_privacy &&
ieee802_11_rsnx_capab_len(parse.rsnxe, parse.rsnxe_len,
WLAN_RSNX_CAPAB_PMKSA_CACHING_PRIVACY)) {
- const u8 *name;
+ const u8 *name, *spa = NULL;
- name = wpa_ft_get_pmk_r1_name(sm->wpa_auth, sm->addr,
- parse.rsn_pmkid);
+ name = wpa_ft_get_pmk_r1_name(sm->wpa_auth, parse.rsn_pmkid,
+ &spa);
if (name) {
os_memcpy(pmk_r1_name, name, WPA_PMK_NAME_LEN);
- if (wpa_ft_fetch_pmk_r1(sm->wpa_auth, sm->addr,
+ if (wpa_ft_fetch_pmk_r1(sm->wpa_auth, spa,
pmk_r1_name, pmk_r1,
&pmk_r1_len, &pairwise, &vlan,
&identity, &identity_len,
@@ -4751,7 +4774,7 @@ static int wpa_ft_send_rrb_auth_resp(struct wpa_state_machine *sm,
static int wpa_ft_rrb_build_r0(const u8 *key, const size_t key_len,
const struct tlv_list *tlvs,
const struct wpa_ft_pmk_r0_sa *pmk_r0,
- const u8 *r1kh_id, const u8 *s1kh_id,
+ const u8 *r1kh_id,
const struct tlv_list *tlv_auth,
const u8 *src_addr, u8 type,
u8 **packet, size_t *packet_len)
@@ -4786,7 +4809,7 @@ static int wpa_ft_rrb_build_r0(const u8 *key, const size_t key_len,
};
wpa_printf(MSG_DEBUG, "FT: Derive PMK-R1 for peer AP");
- if (wpa_ft_r0_derive_pmk_r1(pmk_r0, r1kh_id, s1kh_id, pmk_r1,
+ if (wpa_ft_r0_derive_pmk_r1(pmk_r0, r1kh_id, pmk_r1,
pmk_r1_name) < 0)
return -1;
WPA_PUT_LE16(f_pairwise, pmk_r0->pairwise);
@@ -4956,7 +4979,7 @@ static int wpa_ft_rrb_rx_pull(struct wpa_authenticator *wpa_auth,
&packet, &packet_len);
} else {
ret = wpa_ft_rrb_build_r0(key, key_len, resp, r0, f_r1kh_id,
- f_s1kh_id, resp_auth, wpa_auth->addr,
+ resp_auth, wpa_auth->addr,
FT_PACKET_R0KH_R1KH_RESP,
&packet, &packet_len);
}
@@ -5893,7 +5916,7 @@ static int wpa_ft_generate_pmk_r1(struct wpa_authenticator *wpa_auth,
MAC2STR(wpa_auth->addr), MAC2STR(r1kh->addr));
if (wpa_ft_rrb_build_r0(r1kh->key, sizeof(r1kh->key), push, pmk_r0,
- r1kh->id, s1kh_id, push_auth, wpa_auth->addr,
+ r1kh->id, push_auth, wpa_auth->addr,
FT_PACKET_R0KH_R1KH_PUSH,
&packet, &packet_len) < 0)
return -1;
--
2.55.0
More information about the Hostap
mailing list