[PATCH 12/55] wpa_supplicant: Use FT key hierarchy with IEEE 802.1X Authentication
Ilan Peer
ilan.peer at intel.com
Thu Dec 3 02:44:11 PST 2026
When an FT AKM is used, include the MDE of the target AP in the
first Authentication frame and validate the MDE and the FTE in the
second Authentication frame. On successful authentication, derive
the FT key hierarchy and the PTK from XXKey.
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
src/rsn_supp/wpa.c | 1 +
src/rsn_supp/wpa.h | 7 +++
src/rsn_supp/wpa_ft.c | 27 ++++++++++
src/rsn_supp/wpa_i.h | 2 +
wpa_supplicant/sme.c | 86 +++++++++++++++++++++++++++++--
wpa_supplicant/wpa_supplicant_i.h | 4 ++
6 files changed, 124 insertions(+), 3 deletions(-)
diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c
index d877ff9964db..7baf744056cf 100644
--- a/src/rsn_supp/wpa.c
+++ b/src/rsn_supp/wpa.c
@@ -4614,6 +4614,7 @@ void wpa_sm_deinit(struct wpa_sm *sm)
os_free(sm->ctx);
#ifdef CONFIG_IEEE80211R
os_free(sm->assoc_resp_ies);
+ os_free(sm->ft_auth2_ies);
#endif /* CONFIG_IEEE80211R */
#ifdef CONFIG_TESTING_OPTIONS
wpabuf_free(sm->test_assoc_ie);
diff --git a/src/rsn_supp/wpa.h b/src/rsn_supp/wpa.h
index 572daa2d977d..6ebe09f90874 100644
--- a/src/rsn_supp/wpa.h
+++ b/src/rsn_supp/wpa.h
@@ -597,6 +597,7 @@ static inline bool wpa_sm_uses_spp_amsdu(struct wpa_sm *sm)
#ifdef CONFIG_IEEE80211R
int wpa_sm_set_ft_params(struct wpa_sm *sm, const u8 *ies, size_t ies_len);
+int wpa_sm_set_ft_auth2_ies(struct wpa_sm *sm, const u8 *ies, size_t ies_len);
int wpa_ft_prepare_auth_request(struct wpa_sm *sm, const u8 *mdie);
int wpa_ft_add_mdie(struct wpa_sm *sm, u8 *ies, size_t ies_len,
const u8 *mdie);
@@ -634,6 +635,12 @@ wpa_sm_set_ft_params(struct wpa_sm *sm, const u8 *ies, size_t ies_len)
return 0;
}
+static inline int
+wpa_sm_set_ft_auth2_ies(struct wpa_sm *sm, const u8 *ies, size_t ies_len)
+{
+ return 0;
+}
+
static inline int wpa_ft_prepare_auth_request(struct wpa_sm *sm,
const u8 *mdie)
{
diff --git a/src/rsn_supp/wpa_ft.c b/src/rsn_supp/wpa_ft.c
index 8b6956bdc0f0..cf0ed63957bc 100644
--- a/src/rsn_supp/wpa_ft.c
+++ b/src/rsn_supp/wpa_ft.c
@@ -243,6 +243,33 @@ int wpa_sm_set_ft_params(struct wpa_sm *sm, const u8 *ies, size_t ies_len)
}
+/*
+ * According to Section 12.16.6.2 in IEEE P802.11bi/D6.0, ith FT initial
+ * mobility domain association, the MDE and the FTE in the association response
+ * frame have to be the same as in the second authentication frame. Store the
+ * elements from the second authentication frame for later verification.
+ */
+int wpa_sm_set_ft_auth2_ies(struct wpa_sm *sm, const u8 *ies, size_t ies_len)
+{
+ if (!sm)
+ return 0;
+
+ os_free(sm->ft_auth2_ies);
+ sm->ft_auth2_ies = NULL;
+ sm->ft_auth2_ies_len = 0;
+
+ if (!ies || !ies_len)
+ return 0;
+
+ sm->ft_auth2_ies = os_memdup(ies, ies_len);
+ if (!sm->ft_auth2_ies)
+ return -1;
+
+ sm->ft_auth2_ies_len = ies_len;
+ return 0;
+}
+
+
/**
* wpa_ft_gen_req_ies - Generate FT (IEEE 802.11r) IEs for Auth/ReAssoc Request
* @sm: Pointer to WPA state machine data from wpa_sm_init()
diff --git a/src/rsn_supp/wpa_i.h b/src/rsn_supp/wpa_i.h
index 72b26d1d9e29..c3130ca0d00e 100644
--- a/src/rsn_supp/wpa_i.h
+++ b/src/rsn_supp/wpa_i.h
@@ -188,6 +188,8 @@ struct wpa_sm {
unsigned int ft_completed:1;
unsigned int ft_reassoc_completed:1;
unsigned int ft_protocol:1;
+ u8 *ft_auth2_ies;
+ size_t ft_auth2_ies_len;
int over_the_ds_in_progress;
u8 target_ap[ETH_ALEN]; /* over-the-DS target AP */
int set_ptk_after_assoc;
diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c
index 46544847319f..89648949677d 100644
--- a/wpa_supplicant/sme.c
+++ b/wpa_supplicant/sme.c
@@ -165,6 +165,19 @@ static int sme_get_pmk_for_1x_auth(struct wpa_supplicant *wpa_s,
len = wpa_hash_len(wpa_s->auth_1x->pqc_profile->hash);
#endif /* CONFIG_PQC */
+#ifdef CONFIG_IEEE80211R
+ /* XXKey is the second 256 bits of the MSK for FT-EAP */
+ if (wpa_s->auth_1x && wpa_s->auth_1x->ft &&
+ !wpa_key_mgmt_sha384(key_mgmt)) {
+ u8 msk[2 * PMK_LEN];
+
+ res = eapol_sm_get_key(wpa_s->eapol, msk, sizeof(msk));
+ if (res == 0)
+ os_memcpy(pmk_buf, msk + PMK_LEN, PMK_LEN);
+
+ forced_memzero(msk, sizeof(msk));
+ } else
+#endif /* CONFIG_IEEE80211R */
res = eapol_sm_get_key(wpa_s->eapol, pmk_buf, len);
if (res) {
wpa_msg(wpa_s, MSG_INFO,
@@ -666,6 +679,23 @@ static int sme_init_802_1x_for_ptk(struct wpa_supplicant *wpa_s, bool external)
}
auth_1x->rsnxe_len = rsnxe_len;
+#ifdef CONFIG_IEEE80211R
+ /* Set MDE in the first frame */
+ auth_1x->ft = false;
+ wpa_sm_set_ft_auth2_ies(wpa_s->wpa, NULL, 0);
+ if (!external && wpa_key_mgmt_ft(wpa_s->key_mgmt) &&
+ wpa_s->current_bss) {
+ const u8 *mde;
+
+ mde = wpa_bss_get_ie(wpa_s->current_bss,
+ WLAN_EID_MOBILITY_DOMAIN);
+ if (mde && mde[1] == sizeof(struct rsn_mdie)) {
+ os_memcpy(auth_1x->mdie, mde, 2 + mde[1]);
+ auth_1x->ft = true;
+ }
+ }
+#endif /* CONFIG_IEEE80211R */
+
return 0;
fail:
sme_802_1x_auth_data_free(wpa_s);
@@ -681,7 +711,8 @@ sme_build_802_1x_for_ptk(struct wpa_supplicant *wpa_s)
struct wpabuf *buf = NULL;
size_t rsne_len = auth_1x->rsne_len;
size_t rsnxe_len = auth_1x->rsnxe_len;
- size_t total_len = 3 + WPA_NONCE_LEN + rsne_len + rsnxe_len;
+ size_t total_len = 3 + WPA_NONCE_LEN + rsne_len + rsnxe_len +
+ (auth_1x->ft ? sizeof(auth_1x->mdie) : 0);
#ifdef CONFIG_PQC
size_t pqc_data_len = 2;
u8 present = PQC_CONTENT_NONE;
@@ -744,6 +775,8 @@ sme_build_802_1x_for_ptk(struct wpa_supplicant *wpa_s)
wpabuf_put_data(buf, auth_1x->rsne, rsne_len);
wpabuf_put_data(buf, auth_1x->rsnxe, rsnxe_len);
+ if (auth_1x->ft)
+ wpabuf_put_data(buf, auth_1x->mdie, sizeof(auth_1x->mdie));
if (wpa_key_mgmt_pqc(wpa_s->key_mgmt)) {
#ifdef CONFIG_PQC
@@ -4504,6 +4537,33 @@ static int sme_validate_8021x_auth_elems(struct wpa_supplicant *wpa_s,
if (sme_validate_8021x_common_elems(wpa_s, elems, pdu) < 0)
return -1;
+#ifdef CONFIG_IEEE80211R
+ /* IEEE P802.11bi/D6.0, 12.16.8.4 */
+ if (wpa_s->auth_1x->ft) {
+ u8 ft_ies[2 + 3 + 2 + 255];
+ size_t len;
+
+ if (!elems->mdie || !elems->ftie ||
+ elems->mdie_len != wpa_s->auth_1x->mdie[1] ||
+ os_memcmp(elems->mdie, &wpa_s->auth_1x->mdie[2],
+ elems->mdie_len) != 0) {
+ wpa_msg(wpa_s, MSG_INFO,
+ "IEEE 802.1X: Missing or mismatching MDE/FTE");
+ return -1;
+ }
+
+ os_memcpy(ft_ies, elems->mdie - 2, 2 + elems->mdie_len);
+ len = 2 + elems->mdie_len;
+ os_memcpy(ft_ies + len, elems->ftie - 2, 2 + elems->ftie_len);
+ len += 2 + elems->ftie_len;
+ if (wpa_sm_set_ft_params(wpa_s->wpa, ft_ies, len) < 0 ||
+ wpa_sm_set_ft_auth2_ies(wpa_s->wpa, ft_ies, len) < 0) {
+ wpa_msg(wpa_s, MSG_INFO, "IEEE 802.1X: Invalid FTE");
+ return -1;
+ }
+ }
+#endif /* CONFIG_IEEE80211R */
+
if (wpa_key_mgmt_pqc(wpa_s->key_mgmt))
return sme_802_1x_process_pqc_params(wpa_s, elems);
@@ -4795,6 +4855,26 @@ static int sme_802_1x_derive_ptk_and_install(
}
#endif /* CONFIG_PQC */
+#ifdef CONFIG_IEEE80211R
+ if (auth_1x->ft) {
+ if (!auth_1x->dhss ||
+ wpa_sm_802_1x_ft_pmk_to_ptk(wpa_s->wpa, pmk, pmk_len,
+ auth_1x->snonce,
+ auth_1x->anonce, peer_addr,
+ key_mgmt,
+ pairwise_cipher,
+ wpabuf_head(auth_1x->dhss),
+ wpabuf_len(auth_1x->dhss),
+ &ptk, kdk_len) < 0) {
+ wpa_msg(wpa_s, MSG_INFO, "FT: PTK derivation failed");
+
+ forced_memzero(pmk, PMK_LEN_MAX);
+ return -1;
+ }
+ goto ptk_derived;
+ }
+#endif /* CONFIG_IEEE80211R */
+
if (!auth_1x->dhss ||
wpa_auth_802_1x_pmk_to_ptk(pmk, pmk_len, wpa_s->own_addr, peer_addr,
auth_1x->snonce, auth_1x->anonce,
@@ -4806,9 +4886,9 @@ static int sme_802_1x_derive_ptk_and_install(
forced_memzero(pmk, PMK_LEN_MAX);
return -1;
}
-#ifdef CONFIG_PQC
+#if defined(CONFIG_PQC) || defined(CONFIG_IEEE80211R)
ptk_derived:
-#endif /* CONFIG_PQC */
+#endif /* CONFIG_PQC || CONFIG_IEEE80211R */
forced_memzero(pmk, PMK_LEN_MAX);
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index 71396e72326c..2b98e8ac5ab2 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -729,6 +729,8 @@ struct last_scan_ssid {
* @rsne_len: Length of RSNE
* @rsnxe: RSNXE
* @rsnxe_len: Length of RSNXE
+ * @ft: FT initial mobility domain association
+ * @mdie: MDE from target AP
* @eap_success: Whether EAP authentication was successful
*/
struct auth_802_1x_data {
@@ -747,6 +749,8 @@ struct auth_802_1x_data {
size_t rsne_len;
u8 rsnxe[257];
size_t rsnxe_len;
+ bool ft;
+ u8 mdie[2 + 3];
bool eap_success;
--
2.55.0
More information about the Hostap
mailing list