[PATCH 27/55] AP: Identify the FT PMK-R1 by the PMKR0Name with PMKSA caching privacy
Ilan Peer
ilan.peer at intel.com
Thu Dec 3 02:44:26 PST 2026
With PMKSA caching privacy, the R1KH identifies the PMK-R1 by the
PMKR0Name indicated in the FT Authentication frame (See section
13.5.2 in Draft IEEE P802.11bi/D6.0).
Keep the PMKR0Name the PMK-R1 SA was derived from, and add it to the
PMK-R1 pull response so the R1KH can store it. A new PMK-R1 replaces an
existing PMK-R1 SA with the same PMKR1Name.
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
src/ap/wpa_auth_ft.c | 99 +++++++++++++++++++++++++++++++++++++++-----
1 file changed, 89 insertions(+), 10 deletions(-)
diff --git a/src/ap/wpa_auth_ft.c b/src/ap/wpa_auth_ft.c
index 4269e3d365f9..ef83871a1141 100644
--- a/src/ap/wpa_auth_ft.c
+++ b/src/ap/wpa_auth_ft.c
@@ -1249,6 +1249,9 @@ struct wpa_ft_pmk_r1_sa {
size_t radius_cui_len;
os_time_t session_timeout; /* 0 for no expiration */
/* TODO: radius_class, EAP type */
+#ifdef CONFIG_PMKSA_PRIVACY
+ u8 pmk_r0_name[WPA_PMK_NAME_LEN];
+#endif /* CONFIG_PMKSA_PRIVACY */
};
struct wpa_ft_pmk_cache {
@@ -1570,10 +1573,32 @@ static int wpa_ft_fetch_pmk_r0(struct wpa_authenticator *wpa_auth,
}
+#ifdef CONFIG_PMKSA_PRIVACY
+
+static const u8 * wpa_ft_get_pmk_r1_name(struct wpa_authenticator *wpa_auth,
+ const u8 *spa, const u8 *pmk_r0_name)
+{
+ struct wpa_ft_pmk_cache *cache = wpa_auth->ft_pmk_cache;
+ struct wpa_ft_pmk_r1_sa *r1;
+
+ 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)
+ return r1->pmk_r1_name;
+ }
+
+ return NULL;
+}
+
+#endif /* CONFIG_PMKSA_PRIVACY */
+
+
static int wpa_ft_store_pmk_r1(struct wpa_authenticator *wpa_auth,
const u8 *spa, const u8 *pmk_r1,
size_t pmk_r1_len,
- const u8 *pmk_r1_name, int pairwise,
+ const u8 *pmk_r1_name, const u8 *pmk_r0_name,
+ int pairwise,
const struct vlan_description *vlan,
int expires_in, int session_timeout,
const u8 *identity, size_t identity_len,
@@ -1581,7 +1606,7 @@ static int wpa_ft_store_pmk_r1(struct wpa_authenticator *wpa_auth,
{
struct wpa_ft_pmk_cache *cache = wpa_auth->ft_pmk_cache;
int max_expires_in = wpa_auth->conf.r1_max_key_lifetime;
- struct wpa_ft_pmk_r1_sa *r1;
+ struct wpa_ft_pmk_r1_sa *r1, *prev;
struct os_reltime now;
/* TODO: limit on number of entries in cache */
@@ -1590,6 +1615,15 @@ static int wpa_ft_store_pmk_r1(struct wpa_authenticator *wpa_auth,
if (max_expires_in && (max_expires_in < expires_in || expires_in == 0))
expires_in = max_expires_in;
+ dl_list_for_each(prev, &cache->pmk_r1, struct wpa_ft_pmk_r1_sa, list) {
+ if (ether_addr_equal(prev->spa, spa) &&
+ os_memcmp_const(prev->pmk_r1_name, pmk_r1_name,
+ WPA_PMK_NAME_LEN) == 0) {
+ wpa_ft_free_pmk_r1(prev);
+ break;
+ }
+ }
+
r1 = os_zalloc(sizeof(*r1));
if (r1 == NULL)
return -1;
@@ -1597,6 +1631,10 @@ static int wpa_ft_store_pmk_r1(struct wpa_authenticator *wpa_auth,
os_memcpy(r1->pmk_r1, pmk_r1, pmk_r1_len);
r1->pmk_r1_len = pmk_r1_len;
os_memcpy(r1->pmk_r1_name, pmk_r1_name, WPA_PMK_NAME_LEN);
+#ifdef CONFIG_PMKSA_PRIVACY
+ if (pmk_r0_name)
+ os_memcpy(r1->pmk_r0_name, pmk_r0_name, WPA_PMK_NAME_LEN);
+#endif /* CONFIG_PMKSA_PRIVACY */
os_memcpy(r1->spa, spa, ETH_ALEN);
r1->pairwise = pairwise;
if (vlan && vlan->notempty) {
@@ -2341,7 +2379,7 @@ void wpa_auth_ft_store_keys(struct wpa_state_machine *sm, const u8 *pmk_r0,
radius_cui, radius_cui_len, xxkey, xxkey_len,
sm->wpa_key_mgmt);
wpa_ft_store_pmk_r1(sm->wpa_auth, sm->addr, pmk_r1, key_len,
- sm->pmk_r1_name, sm->pairwise, &vlan,
+ sm->pmk_r1_name, pmk_r0_name, sm->pairwise, &vlan,
expires_in, session_timeout, identity,
identity_len, radius_cui, radius_cui_len);
}
@@ -3404,7 +3442,7 @@ static int wpa_ft_local_derive_pmk_r1(struct wpa_authenticator *wpa_auth,
session_timeout = r0->session_timeout - now.sec;
wpa_ft_store_pmk_r1(wpa_auth, sm->addr, out_pmk_r1, r0->pmk_r0_len,
- out_pmk_r1_name,
+ out_pmk_r1_name, r0->pmk_r0_name,
sm->pairwise, r0->vlan, expires_in, session_timeout,
r0->identity, r0->identity_len,
r0->radius_cui, r0->radius_cui_len);
@@ -3677,6 +3715,37 @@ static int wpa_ft_process_auth_req(struct wpa_state_machine *sm,
goto pmk_r1_derived;
}
+#ifdef CONFIG_PMKSA_PRIVACY
+ /* With PMKSA privacy, identify the PMK-R1 by PMKR0Name */
+ if (conf->pmksa_caching_privacy &&
+ ieee802_11_rsnx_capab_len(parse.rsnxe, parse.rsnxe_len,
+ WLAN_RSNX_CAPAB_PMKSA_CACHING_PRIVACY)) {
+ const u8 *name;
+
+ name = wpa_ft_get_pmk_r1_name(sm->wpa_auth, sm->addr,
+ parse.rsn_pmkid);
+ if (name) {
+ os_memcpy(pmk_r1_name, name, WPA_PMK_NAME_LEN);
+ if (wpa_ft_fetch_pmk_r1(sm->wpa_auth, sm->addr,
+ pmk_r1_name, pmk_r1,
+ &pmk_r1_len, &pairwise, &vlan,
+ &identity, &identity_len,
+ &radius_cui, &radius_cui_len,
+ &session_timeout) == 0) {
+ wpa_printf(MSG_DEBUG,
+ "FT: Found PMK-R1 for the PMKR0Name from local cache");
+ goto pmk_r1_derived;
+ }
+ }
+
+ /*
+ * TODO: Fall back to the PMKR1Name lookup below for a PMK-R1
+ * from an R0KH that does not support PMKR0Name privacy?
+ */
+ goto no_cached_pmk_r1;
+ }
+#endif /* CONFIG_PMKSA_PRIVACY */
+
/* Need to test all possible hash algorithms for FT-SAE-EXT-KEY since
* the key length is not yet known. For other AKMs, only the length
* identified by the AKM is used. */
@@ -3704,6 +3773,9 @@ static int wpa_ft_process_auth_req(struct wpa_state_machine *sm,
}
}
+#ifdef CONFIG_PMKSA_PRIVACY
+no_cached_pmk_r1:
+#endif /* CONFIG_PMKSA_PRIVACY */
wpa_printf(MSG_DEBUG,
"FT: No PMK-R1 available in local cache for the requested PMKR1Name");
if (wpa_ft_local_derive_pmk_r1(sm->wpa_auth, sm,
@@ -4512,7 +4584,7 @@ static int wpa_ft_rrb_rx_pull(struct wpa_authenticator *wpa_auth,
size_t f_pmk_r0_name_len;
const struct wpa_ft_pmk_r0_sa *r0;
int ret;
- struct tlv_list resp[2];
+ struct tlv_list resp[3];
struct tlv_list resp_auth[5];
struct ft_rrb_seq f_seq;
@@ -4601,9 +4673,12 @@ static int wpa_ft_rrb_rx_pull(struct wpa_authenticator *wpa_auth,
resp[0].type = FT_RRB_S1KH_ID;
resp[0].len = f_s1kh_id_len;
resp[0].data = f_s1kh_id;
- resp[1].type = FT_RRB_LAST_EMPTY;
- resp[1].len = 0;
- resp[1].data = NULL;
+ resp[1].type = FT_RRB_PMK_R0_NAME;
+ resp[1].len = f_pmk_r0_name_len;
+ resp[1].data = f_pmk_r0_name;
+ resp[2].type = FT_RRB_LAST_EMPTY;
+ resp[2].len = 0;
+ resp[2].data = NULL;
resp_auth[0].type = FT_RRB_NONCE;
resp_auth[0].len = f_nonce_len;
@@ -4669,12 +4744,13 @@ static int wpa_ft_rrb_rx_r1(struct wpa_authenticator *wpa_auth,
size_t key_len;
int seq_ret;
const u8 *f_r1kh_id, *f_s1kh_id, *f_r0kh_id;
- const u8 *f_pmk_r1_name, *f_pairwise, *f_pmk_r1;
+ const u8 *f_pmk_r1_name, *f_pairwise, *f_pmk_r1, *f_pmk_r0_name;
const u8 *f_expires_in;
size_t f_r1kh_id_len, f_s1kh_id_len, f_r0kh_id_len;
const u8 *f_identity, *f_radius_cui;
const u8 *f_session_timeout;
size_t f_pmk_r1_name_len, f_pairwise_len, f_pmk_r1_len;
+ size_t f_pmk_r0_name_len;
size_t f_expires_in_len;
size_t f_identity_len, f_radius_cui_len;
size_t f_session_timeout_len;
@@ -4762,6 +4838,9 @@ static int wpa_ft_rrb_rx_r1(struct wpa_authenticator *wpa_auth,
wpa_hexdump(MSG_DEBUG, "FT: PMKR1Name",
f_pmk_r1_name, WPA_PMK_NAME_LEN);
+ RRB_GET_OPTIONAL(FT_RRB_PMK_R0_NAME, pmk_r0_name, msgtype,
+ WPA_PMK_NAME_LEN);
+
pmk_r1_len = PMK_LEN;
if (wpa_ft_rrb_get_tlv(plain, plain_len, FT_RRB_PMK_R1, &f_pmk_r1_len,
&f_pmk_r1) == 0 &&
@@ -4811,7 +4890,7 @@ static int wpa_ft_rrb_rx_r1(struct wpa_authenticator *wpa_auth,
wpa_printf(MSG_DEBUG, "FT: session_timeout %d", session_timeout);
if (wpa_ft_store_pmk_r1(wpa_auth, f_s1kh_id, f_pmk_r1, pmk_r1_len,
- f_pmk_r1_name,
+ f_pmk_r1_name, f_pmk_r0_name,
pairwise, &vlan, expires_in, session_timeout,
f_identity, f_identity_len, f_radius_cui,
f_radius_cui_len) < 0)
--
2.55.0
More information about the Hostap
mailing list