[PATCH 44/55] AP: Process the PQC Parameter element in the FT protocol
Ilan Peer
ilan.peer at intel.com
Thu Dec 3 02:44:43 PST 2026
With AKM 00-0F-AC:32, the first FT protocol message includes a PQC
Parameter element. Process it, and include the ML-KEM ciphertext (and
the ECDH public key, if used by the PQC profile) and the Supported
Groups element in the second message (see Section 12.16.8.2 in Draft
IEEE P802.11bt/D1.1).
Accept the PQC AKM only if an FT PQC security profile is enabled and
matches the Security Profile element in the first message.
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
src/ap/ieee802_11.c | 7 +-
src/ap/wpa_auth.c | 5 +
src/ap/wpa_auth.h | 6 ++
src/ap/wpa_auth_ft.c | 220 ++++++++++++++++++++++++++++++++++++++++-
src/ap/wpa_auth_glue.c | 2 +
src/ap/wpa_auth_i.h | 8 ++
6 files changed, 246 insertions(+), 2 deletions(-)
diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index ab4e45f9d5c9..61901311df21 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -6235,6 +6235,7 @@ static void handle_auth(struct hostapd_data *hapd,
struct ieee802_11_elems elems;
size_t auth_var_len = len - IEEE80211_HDRLEN -
sizeof(mgmt->u.auth);
+ const struct security_profile_entry *sp = NULL;
if (ieee802_11_parse_elems(mgmt->u.auth.variable,
auth_var_len, &elems,
@@ -6244,10 +6245,14 @@ static void handle_auth(struct hostapd_data *hapd,
__func__);
goto fail;
}
+
if (validate_security_profile(hapd, sta, false, &elems,
- "FT", NULL))
+ "FT", &sp))
goto fail;
+
+ wpa_auth_set_security_profile(sta->wpa_sm, sp);
}
+
wpa_ft_process_auth(sta->wpa_sm,
auth_transaction, mgmt->u.auth.variable,
len - IEEE80211_HDRLEN -
diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c
index 301382e7a895..02fc5adcd1f4 100644
--- a/src/ap/wpa_auth.c
+++ b/src/ap/wpa_auth.c
@@ -1204,6 +1204,11 @@ static void wpa_free_sta_sm(struct wpa_state_machine *sm)
#ifdef CONFIG_IEEE80211R_AP
os_free(sm->assoc_resp_ftie);
wpabuf_free(sm->ft_pending_req_ies);
+#ifdef CONFIG_PQC
+ wpabuf_free(sm->ft_msg1);
+ wpabuf_clear_free(sm->ft_dhss);
+ wpabuf_clear_free(sm->ft_ml_kem_ss);
+#endif /* CONFIG_PQC */
#endif /* CONFIG_IEEE80211R_AP */
os_free(sm->last_rx_eapol_key);
os_free(sm->wpa_ie);
diff --git a/src/ap/wpa_auth.h b/src/ap/wpa_auth.h
index fd21de55e8f2..5bc5838d0c82 100644
--- a/src/ap/wpa_auth.h
+++ b/src/ap/wpa_auth.h
@@ -349,6 +349,12 @@ struct wpa_auth_config {
u8 security_profile[257];
size_t security_profile_len;
bool pqc_enabled;
+
+ /* AKMs implied by the enabled security profile */
+ int sp_key_mgmt;
+
+ /* -1 terminated, or NULL */
+ const int *security_profiles;
};
typedef enum {
diff --git a/src/ap/wpa_auth_ft.c b/src/ap/wpa_auth_ft.c
index 926341bd30d4..3323d3386878 100644
--- a/src/ap/wpa_auth_ft.c
+++ b/src/ap/wpa_auth_ft.c
@@ -3651,6 +3651,14 @@ static int wpa_ft_set_key_mgmt(struct wpa_state_machine *sm,
return 0;
key_mgmt = parse->key_mgmt & sm->wpa_auth->conf.wpa_key_mgmt;
+
+#ifdef CONFIG_PQC
+ /* The PQC AKM is implied by the enabled security profiles */
+ if (!key_mgmt)
+ key_mgmt = parse->key_mgmt & sm->wpa_auth->conf.sp_key_mgmt &
+ WPA_KEY_MGMT_FT_PQC_8021X;
+#endif /* CONFIG_PQC */
+
if (!key_mgmt) {
wpa_printf(MSG_DEBUG, "FT: Invalid key mgmt (0x%x) from "
MACSTR, parse->key_mgmt, MAC2STR(sm->addr));
@@ -3835,6 +3843,172 @@ static u16 wpa_ft_process_dh(struct wpa_state_machine *sm,
}
+#ifdef CONFIG_PQC
+
+static bool wpa_ft_sec_prof_enabled(const struct wpa_auth_config *conf, int num)
+{
+ int i;
+
+ for (i = 0; conf->security_profiles && conf->security_profiles[i] >= 0;
+ i++) {
+ if (conf->security_profiles[i] == num)
+ return true;
+ }
+
+ return false;
+}
+
+
+static void wpa_ft_pqc_clear(struct wpa_state_machine *sm)
+{
+ sm->ft_pqc_profile = NULL;
+ wpabuf_free(sm->ft_msg1);
+ sm->ft_msg1 = NULL;
+ wpabuf_clear_free(sm->ft_dhss);
+ sm->ft_dhss = NULL;
+ wpabuf_clear_free(sm->ft_ml_kem_ss);
+ sm->ft_ml_kem_ss = NULL;
+}
+
+#endif /* CONFIG_PQC */
+
+
+static u16 wpa_ft_process_pqc(struct wpa_state_machine *sm,
+ const u8 *ies, size_t ies_len,
+ struct wpabuf **pqc_elem)
+{
+#ifdef CONFIG_PQC
+ const struct element *elem, *pqc = NULL;
+ struct crypto_ecdh *ecdh = NULL;
+ struct crypto_ml_kem *ml_kem = NULL;
+ struct wpabuf *pub = NULL, *ct = NULL;
+ const u8 *pos, *end;
+ u8 content, sec_prof;
+ u16 status = WLAN_STATUS_UNSPECIFIED_FAILURE;
+ size_t len;
+
+ /*
+ * Process the PQC Parameter element of the first FT message and build
+ * the one for the second message (see Section 12.16.8.2 in Draft IEEE
+ * P802.11bt/D1.1).
+ */
+ for_each_element_id(elem, WLAN_EID_EXT_LENGTH, ies, ies_len) {
+ if (le_to_host16(((const struct ext_len_element *)
+ elem)->ext_id) !=
+ WLAN_EID_EXT_LEN_PQC_PARAMETER)
+ continue;
+
+ if (pqc) {
+ wpa_printf(MSG_DEBUG,
+ "FT: More than one PQC Parameter element");
+ return WLAN_STATUS_REJECTED_INVALID_SECURITY_PROFILE;
+ }
+
+ pqc = elem;
+ }
+
+ if (!pqc || element_datalen(pqc) < 2) {
+ wpa_printf(MSG_DEBUG,
+ "FT: Missing or truncated PQC Parameter element");
+ return WLAN_STATUS_REJECTED_INVALID_SECURITY_PROFILE;
+ }
+
+ pos = element_data(pqc);
+ end = pos + element_datalen(pqc);
+ sec_prof = *pos++;
+ content = *pos++;
+
+ /* The first FT message includes the Security Profile element */
+ if (!sm->security_profile ||
+ sm->security_profile->number != sec_prof ||
+ !sec_prof_pqc(sec_prof) || !sec_prof_get(sec_prof) ||
+ sec_prof_get(sec_prof)->key_mgmt != WPA_KEY_MGMT_FT_PQC_8021X ||
+ !wpa_ft_sec_prof_enabled(&sm->wpa_auth->conf, sec_prof)) {
+ wpa_printf(MSG_DEBUG, "FT: Invalid PQC security profile %u",
+ sec_prof);
+ return WLAN_STATUS_REJECTED_INVALID_SECURITY_PROFILE;
+ }
+
+ sm->ft_pqc_profile = pqc_profile_get(sec_prof);
+ if (!sm->ft_pqc_profile)
+ return WLAN_STATUS_REJECTED_INVALID_SECURITY_PROFILE;
+
+ if (content != (sm->ft_pqc_profile->group ?
+ PQC_CONTENT_PK_PARAM_AND_ML_KEM_ENC_KEY :
+ PQC_CONTENT_ML_KEM_ENC_KEY)) {
+ wpa_printf(MSG_DEBUG, "FT: Unexpected PQC content %u", content);
+ return WLAN_STATUS_INVALID_ML_KEM_PARAMETER;
+ }
+
+ if (sm->ft_pqc_profile->group) {
+ size_t pub_len;
+
+ ecdh = crypto_ecdh_init(sm->ft_pqc_profile->group);
+ if (!ecdh)
+ goto out;
+
+ pub_len = crypto_ecdh_prime_len(ecdh);
+ if ((size_t)(end - pos) < pub_len) {
+ status = WLAN_STATUS_INVALID_PUBLIC_KEY;
+ goto out;
+ }
+
+ sm->ft_dhss = crypto_ecdh_set_peerkey(ecdh, 0, pos, pub_len);
+ if (!sm->ft_dhss) {
+ wpa_printf(MSG_DEBUG, "FT: Invalid DH public key");
+ status = WLAN_STATUS_INVALID_PUBLIC_KEY;
+ goto out;
+ }
+
+ pos += pub_len;
+ pub = crypto_ecdh_get_pubkey(ecdh, 0);
+ if (!pub)
+ goto out;
+ }
+
+ ml_kem = crypto_ml_kem_init(sm->ft_pqc_profile->kem);
+ if (!ml_kem)
+ goto out;
+
+ if (pos == end ||
+ crypto_ml_kem_encapsulate(ml_kem, pos, end - pos, &ct,
+ &sm->ft_ml_kem_ss) < 0) {
+ wpa_printf(MSG_DEBUG, "FT: Invalid ML-KEM encapsulation key");
+ status = WLAN_STATUS_INVALID_ML_KEM_PARAMETER;
+ goto out;
+ }
+
+ len = 2 + (pub ? wpabuf_len(pub) : 0) + wpabuf_len(ct);
+ *pqc_elem = wpabuf_alloc(5 + len);
+ if (!*pqc_elem)
+ goto out;
+
+ wpabuf_put_u8(*pqc_elem, WLAN_EID_EXT_LENGTH);
+ wpabuf_put_le16(*pqc_elem, WLAN_EID_EXT_LEN_PQC_PARAMETER);
+ wpabuf_put_le16(*pqc_elem, len);
+ wpabuf_put_u8(*pqc_elem, sec_prof);
+ if (pub) {
+ wpabuf_put_u8(*pqc_elem, PQC_CONTENT_PK_PARAM_AND_ML_KEM_CT);
+ wpabuf_put_buf(*pqc_elem, pub);
+ } else {
+ wpabuf_put_u8(*pqc_elem, PQC_CONTENT_ML_KEM_CT);
+ }
+
+ wpabuf_put_buf(*pqc_elem, ct);
+
+ status = WLAN_STATUS_SUCCESS;
+out:
+ crypto_ecdh_deinit(ecdh);
+ crypto_ml_kem_deinit(ml_kem);
+ wpabuf_free(pub);
+ wpabuf_free(ct);
+ return status;
+#else /* CONFIG_PQC */
+ return WLAN_STATUS_UNSPECIFIED_FAILURE;
+#endif /* CONFIG_PQC */
+}
+
+
static int wpa_ft_add_dh_elems(struct wpa_state_machine *sm, u16 group,
struct crypto_ecdh *ecdh,
u8 **resp_ies, size_t *resp_ies_len)
@@ -3908,11 +4082,15 @@ static int wpa_ft_process_auth_req(struct wpa_state_machine *sm,
#ifdef CONFIG_ENC_ASSOC
struct crypto_ecdh *ecdh = NULL;
struct wpabuf *dhss_buf = NULL;
+ struct wpabuf *pqc_elem = NULL;
u16 group = 0;
#endif /* CONFIG_ENC_ASSOC */
*resp_ies = NULL;
*resp_ies_len = 0;
+#ifdef CONFIG_PQC
+ wpa_ft_pqc_clear(sm);
+#endif /* CONFIG_PQC */
sm->pmk_r1_name_valid = 0;
#ifdef CONFIG_PMKSA_PRIVACY
@@ -3969,7 +4147,25 @@ static int wpa_ft_process_auth_req(struct wpa_state_machine *sm,
sm->ft_enc_assoc = sm->ft_over_air &&
wpa_ft_auth_req_enc_assoc(conf, parse.rsnxe, parse.rsnxe_len);
- if (sm->ft_enc_assoc) {
+ if (wpa_key_mgmt_pqc(sm->wpa_key_mgmt)) {
+ u16 status;
+
+ if (!sm->ft_enc_assoc) {
+ wpa_printf(MSG_DEBUG,
+ "FT: PQC AKM without encrypted reassociation");
+ retval = WLAN_STATUS_REJECTED_INVALID_SECURITY_PROFILE;
+ goto out;
+ }
+
+ status = wpa_ft_process_pqc(sm, ies, ies_len, &pqc_elem);
+ if (status != WLAN_STATUS_SUCCESS) {
+ retval = status;
+ goto out;
+ }
+ }
+
+ /* With the PQC AKM, the DH key is in the PQC Parameter element */
+ if (sm->ft_enc_assoc && !wpa_key_mgmt_pqc(sm->wpa_key_mgmt)) {
u16 status;
status = wpa_ft_process_dh(sm, ies, ies_len, &group, &ecdh,
@@ -4245,6 +4441,23 @@ pmk_r1_derived:
*resp_ies_len = pos - *resp_ies;
#ifdef CONFIG_ENC_ASSOC
+ if (pqc_elem) {
+ u8 *tmp;
+
+ tmp = os_realloc(*resp_ies,
+ *resp_ies_len + wpabuf_len(pqc_elem));
+ if (!tmp)
+ goto fail;
+ *resp_ies = tmp;
+ os_memcpy(tmp + *resp_ies_len, wpabuf_head(pqc_elem),
+ wpabuf_len(pqc_elem));
+ *resp_ies_len += wpabuf_len(pqc_elem);
+ }
+
+ /*
+ * With the PQC AKM, ecdh is NULL, so only the Supported Groups element
+ * is added (see Section 12.16.8.2 in Draft IEEE P802.11bt/D1.1).
+ */
if (sm->ft_enc_assoc &&
wpa_ft_add_dh_elems(sm, group, ecdh, resp_ies, resp_ies_len) < 0)
goto fail;
@@ -4276,7 +4489,12 @@ out:
#ifdef CONFIG_ENC_ASSOC
crypto_ecdh_deinit(ecdh);
wpabuf_clear_free(dhss_buf);
+ wpabuf_free(pqc_elem);
#endif /* CONFIG_ENC_ASSOC */
+#ifdef CONFIG_PQC
+ if (retval != WLAN_STATUS_SUCCESS)
+ wpa_ft_pqc_clear(sm);
+#endif /* CONFIG_PQC */
wpa_ft_parse_ies_free(&parse);
return retval;
}
diff --git a/src/ap/wpa_auth_glue.c b/src/ap/wpa_auth_glue.c
index aa62334392e3..00f615de474d 100644
--- a/src/ap/wpa_auth_glue.c
+++ b/src/ap/wpa_auth_glue.c
@@ -112,6 +112,8 @@ static void hostapd_wpa_auth_config_update(struct hostapd_data *hapd,
pos = hostapd_eid_security_profile(hapd, _conf->security_profile);
_conf->security_profile_len = pos - _conf->security_profile;
_conf->pqc_enabled = hostapd_pqc_enabled(hapd->conf);
+ _conf->sp_key_mgmt = hostapd_config_sp_key_mgmt(hapd->conf);
+ _conf->security_profiles = hapd->conf->security_profiles;
}
static void hostapd_wpa_auth_conf(struct hostapd_iface *iface,
diff --git a/src/ap/wpa_auth_i.h b/src/ap/wpa_auth_i.h
index 1efbe58c5951..90507a789141 100644
--- a/src/ap/wpa_auth_i.h
+++ b/src/ap/wpa_auth_i.h
@@ -148,6 +148,14 @@ struct wpa_state_machine {
bool ft_over_air;
#endif /* CONFIG_ENC_ASSOC */
+#ifdef CONFIG_PQC
+ const struct ieee80211_pqc_profile *ft_pqc_profile;
+ struct wpabuf *ft_msg1;
+ struct wpabuf *ft_dhss;
+ struct wpabuf *ft_ml_kem_ss;
+ size_t ft_kdk_len;
+#endif /* CONFIG_PQC */
+
#ifdef CONFIG_PMKSA_PRIVACY
u8 ft_pmk_r0_name[WPA_PMK_NAME_LEN];
bool ft_pmk_r0_name_valid;
--
2.55.0
More information about the Hostap
mailing list