[PATCH 46/55] wpa_supplicant: Add the PQC Parameter element to the first FT message

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


With AKM 00-0F-AC:32, the first FT protocol message includes the
Security Profile element and a PQC Parameter element with the ML-KEM
encapsulation key, and the ECDH public key if used by the PQC profile
(see Section 12.16.8.2 in Draft IEEE P802.11bt/D1.1).

Add these elements and keep the first message for the transcript. The
PQC Parameter element uses the Extended Length element format, which
cannot be parsed by the kernel IE validation, so pass the first message
to the driver as authentication data instead of IEs.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 src/rsn_supp/wpa.c    |   4 ++
 src/rsn_supp/wpa_ft.c | 136 ++++++++++++++++++++++++++++++++++++++++++
 src/rsn_supp/wpa_i.h  |   5 ++
 wpa_supplicant/sme.c  |  29 +++++++++
 4 files changed, 174 insertions(+)

diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c
index a644e5179166..b848230f552b 100644
--- a/src/rsn_supp/wpa.c
+++ b/src/rsn_supp/wpa.c
@@ -4617,6 +4617,10 @@ void wpa_sm_deinit(struct wpa_sm *sm)
 	os_free(sm->ft_auth2_ies);
 #ifdef CONFIG_ENC_ASSOC
 	crypto_ecdh_deinit(sm->ft_ecdh);
+#ifdef CONFIG_PQC
+	crypto_ml_kem_deinit(sm->ft_ml_kem);
+	wpabuf_free(sm->ft_msg1);
+#endif /* CONFIG_PQC */
 #endif /* CONFIG_ENC_ASSOC */
 #endif /* CONFIG_IEEE80211R */
 #ifdef CONFIG_TESTING_OPTIONS
diff --git a/src/rsn_supp/wpa_ft.c b/src/rsn_supp/wpa_ft.c
index 34f650e846c2..466d194d0dac 100644
--- a/src/rsn_supp/wpa_ft.c
+++ b/src/rsn_supp/wpa_ft.c
@@ -759,6 +759,117 @@ bool wpa_ft_mac_addr_change_allowed(struct wpa_sm *sm)
 
 #ifdef CONFIG_ENC_ASSOC
 
+#ifdef CONFIG_PQC
+
+static void wpa_ft_pqc_deinit(struct wpa_sm *sm)
+{
+	crypto_ml_kem_deinit(sm->ft_ml_kem);
+	sm->ft_ml_kem = NULL;
+	sm->ft_pqc_profile = NULL;
+	wpabuf_free(sm->ft_msg1);
+	sm->ft_msg1 = NULL;
+}
+
+
+static u8 * wpa_ft_add_pqc_param(struct wpa_sm *sm, u8 *ft_ies,
+				 size_t *ft_ies_len)
+{
+	struct wpabuf *buf = NULL, *ecdh_pub = NULL, *ml_kem_pub = NULL;
+	u8 sp[32];
+	int sp_len;
+	size_t len;
+	u8 *res;
+
+	/*
+	 * The first FT message includes the PQC Parameter element (see Section
+	 * 12.16.8.2 in Draft IEEE P802.11bt/D1.1).
+	 */
+	if (!sm->security_profile) {
+		wpa_printf(MSG_DEBUG, "FT: No security profile for PQC");
+		goto fail;
+	}
+
+	sm->ft_pqc_profile = pqc_profile_get(sm->security_profile->number);
+	if (!sm->ft_pqc_profile)
+		goto fail;
+
+	sm->ft_ml_kem = crypto_ml_kem_init(sm->ft_pqc_profile->kem);
+	if (!sm->ft_ml_kem || crypto_ml_kem_keygen(sm->ft_ml_kem) < 0)
+		goto fail;
+
+	ml_kem_pub = crypto_ml_kem_get_pubkey(sm->ft_ml_kem);
+	if (!ml_kem_pub)
+		goto fail;
+
+	if (sm->ft_pqc_profile->group) {
+		sm->ft_ecdh = crypto_ecdh_init(sm->ft_pqc_profile->group);
+		if (!sm->ft_ecdh)
+			goto fail;
+
+		ecdh_pub = crypto_ecdh_get_pubkey(sm->ft_ecdh, 0);
+		if (!ecdh_pub)
+			goto fail;
+	}
+
+	sp_len = security_profile_build_sta(sm, sm->security_profile->number,
+					    sp, sizeof(sp));
+	if (sp_len <= 0)
+		goto fail;
+
+	len = 2 + wpabuf_len(ml_kem_pub);
+	if (ecdh_pub)
+		len += wpabuf_len(ecdh_pub);
+
+	buf = wpabuf_alloc(*ft_ies_len + sp_len + 5 + len);
+	if (!buf)
+		goto fail;
+
+	wpabuf_put_data(buf, ft_ies, *ft_ies_len);
+	wpabuf_put_data(buf, sp, sp_len);
+	wpabuf_put_u8(buf, WLAN_EID_EXT_LENGTH);
+	wpabuf_put_le16(buf, WLAN_EID_EXT_LEN_PQC_PARAMETER);
+	wpabuf_put_le16(buf, len);
+	wpabuf_put_u8(buf, sm->security_profile->number);
+
+	if (ecdh_pub) {
+		wpabuf_put_u8(buf, PQC_CONTENT_PK_PARAM_AND_ML_KEM_ENC_KEY);
+		wpabuf_put_buf(buf, ecdh_pub);
+	} else {
+		wpabuf_put_u8(buf, PQC_CONTENT_ML_KEM_ENC_KEY);
+	}
+	wpabuf_put_buf(buf, ml_kem_pub);
+
+	res = os_memdup(wpabuf_head(buf), wpabuf_len(buf));
+	if (!res)
+		goto fail;
+
+	os_free(ft_ies);
+
+	*ft_ies_len = wpabuf_len(buf);
+	wpabuf_free(buf);
+	wpabuf_free(ecdh_pub);
+	wpabuf_free(ml_kem_pub);
+
+	sm->ft_enc_assoc = true;
+	wpa_printf(MSG_DEBUG, "FT: Use PQC security profile %d",
+		   sm->security_profile->number);
+
+	return res;
+
+fail:
+	wpabuf_free(buf);
+	wpabuf_free(ecdh_pub);
+	wpabuf_free(ml_kem_pub);
+	crypto_ecdh_deinit(sm->ft_ecdh);
+	sm->ft_ecdh = NULL;
+	wpa_ft_pqc_deinit(sm);
+	os_free(ft_ies);
+	return NULL;
+}
+
+#endif /* CONFIG_PQC */
+
+
 static u8 * wpa_ft_add_dh_param(struct wpa_sm *sm, u8 *ft_ies,
 				size_t *ft_ies_len)
 {
@@ -768,12 +879,20 @@ static u8 * wpa_ft_add_dh_param(struct wpa_sm *sm, u8 *ft_ies,
 	sm->ft_enc_assoc = false;
 	crypto_ecdh_deinit(sm->ft_ecdh);
 	sm->ft_ecdh = NULL;
+#ifdef CONFIG_PQC
+	wpa_ft_pqc_deinit(sm);
+#endif /* CONFIG_PQC */
 
 	if (!sm->assoc_encryption ||
 	    !ieee802_11_rsnx_capab(sm->ap_rsnxe,
 				   WLAN_RSNX_CAPAB_ASSOC_FRAME_ENCRYPTION))
 		return ft_ies;
 
+#ifdef CONFIG_PQC
+	if (sm->key_mgmt == WPA_KEY_MGMT_FT_PQC_8021X)
+		return wpa_ft_add_pqc_param(sm, ft_ies, ft_ies_len);
+#endif /* CONFIG_PQC */
+
 	if (!sm->ft_dh_group)
 		sm->ft_dh_group = 19;
 
@@ -843,6 +962,23 @@ int wpa_ft_prepare_auth_request(struct wpa_sm *sm, const u8 *mdie)
 		ft_ies = wpa_ft_add_dh_param(sm, ft_ies, &ft_ies_len);
 #endif /* CONFIG_ENC_ASSOC */
 	if (ft_ies) {
+#ifdef CONFIG_PQC
+		if (sm->ft_ml_kem) {
+			u8 hdr[6];
+
+			/* Authentication Algorithm, Transaction, Status */
+			WPA_PUT_LE16(hdr, WLAN_AUTH_FT);
+			WPA_PUT_LE16(hdr + 2, 1);
+			WPA_PUT_LE16(hdr + 4, WLAN_STATUS_SUCCESS);
+			sm->ft_msg1 = wpabuf_alloc(sizeof(hdr) + ft_ies_len);
+			if (sm->ft_msg1) {
+				wpabuf_put_data(sm->ft_msg1, hdr, sizeof(hdr));
+				wpabuf_put_data(sm->ft_msg1, ft_ies,
+						ft_ies_len);
+			}
+		}
+#endif /* CONFIG_PQC */
+
 		wpa_sm_update_ft_ies(sm, sm->mobility_domain,
 				     ft_ies, ft_ies_len);
 		os_free(ft_ies);
diff --git a/src/rsn_supp/wpa_i.h b/src/rsn_supp/wpa_i.h
index a15b8cd599aa..9c81299cd83e 100644
--- a/src/rsn_supp/wpa_i.h
+++ b/src/rsn_supp/wpa_i.h
@@ -206,6 +206,11 @@ struct wpa_sm {
 	struct crypto_ecdh *ft_ecdh;
 	u16 ft_dh_group; /* 0 means use the group 19 */
 	bool ft_enc_assoc;
+#ifdef CONFIG_PQC
+	const struct ieee80211_pqc_profile *ft_pqc_profile;
+	struct crypto_ml_kem *ft_ml_kem;
+	struct wpabuf *ft_msg1;
+#endif /* CONFIG_PQC */
 #endif /* CONFIG_ENC_ASSOC */
 #ifdef CONFIG_PASN
 	/*
diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c
index 4caa7631977d..1e506d3d772f 100644
--- a/wpa_supplicant/sme.c
+++ b/wpa_supplicant/sme.c
@@ -2513,6 +2513,35 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s,
 			params.ie = wpa_s->sme.ft_ies;
 			params.ie_len = wpa_s->sme.ft_ies_len;
 			params.epp_peer = wpa_ft_uses_enc_assoc(wpa_s->wpa);
+#ifdef CONFIG_PQC
+			/*
+			 * The PQC Parameter element uses the Extended Length
+			 * element format (2-octet Length field), which cannot
+			 * be parsed by the kernel IE validation. Pass the
+			 * Authentication frame body, starting from the
+			 * Authentication Transaction Sequence Number field, as
+			 * the opaque authentication data instead.
+			 */
+			if (wpa_s->key_mgmt == WPA_KEY_MGMT_FT_PQC_8021X &&
+			    wpa_ft_uses_enc_assoc(wpa_s->wpa)) {
+				wpabuf_free(resp);
+
+				resp = wpabuf_alloc(4 + wpa_s->sme.ft_ies_len);
+				if (!resp) {
+					wpas_connect_work_done(wpa_s);
+					return;
+				}
+
+				wpabuf_put_le16(resp, 1);
+				wpabuf_put_le16(resp, WLAN_STATUS_SUCCESS);
+				wpabuf_put_data(resp, wpa_s->sme.ft_ies,
+						wpa_s->sme.ft_ies_len);
+				params.auth_data = wpabuf_head(resp);
+				params.auth_data_len = wpabuf_len(resp);
+				params.ie = NULL;
+				params.ie_len = 0;
+			}
+#endif /* CONFIG_PQC */
 		}
 	}
 #endif /* CONFIG_IEEE80211R */
-- 
2.55.0




More information about the Hostap mailing list