[PATCH 43/55] AP: Add a testing option for extra elements in FT Authentication frames

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


Add 'ft_auth_resp_elements' testing option to append elements to the
second FT protocol message. This allows testing how the station
handles unexpected elements.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 hostapd/config_file.c  |  4 ++++
 src/ap/ap_config.c     |  1 +
 src/ap/ap_config.h     |  1 +
 src/ap/wpa_auth.c      |  2 ++
 src/ap/wpa_auth.h      |  1 +
 src/ap/wpa_auth_ft.c   | 16 ++++++++++++++++
 src/ap/wpa_auth_glue.c |  3 +++
 7 files changed, 28 insertions(+)

diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index fd7b8b8fbda4..cc2e11888ec4 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -4635,6 +4635,10 @@ static int hostapd_config_fill(struct hostapd_config *conf,
 	} else if (os_strcmp(buf, "eapol_m1_elements") == 0) {
 		if (parse_wpabuf_hex(line, buf, &bss->eapol_m1_elements, pos))
 			return 1;
+	} else if (os_strcmp(buf, "ft_auth_resp_elements") == 0) {
+		if (parse_wpabuf_hex(line, buf, &bss->ft_auth_resp_elements,
+				     pos))
+			return 1;
 	} else if (os_strcmp(buf, "eapol_m3_elements") == 0) {
 		if (parse_wpabuf_hex(line, buf, &bss->eapol_m3_elements, pos))
 			return 1;
diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c
index 86cfc281a77c..c435e3fcc41c 100644
--- a/src/ap/ap_config.c
+++ b/src/ap/ap_config.c
@@ -983,6 +983,7 @@ void hostapd_config_free_bss(struct hostapd_bss_config *conf)
 	wpabuf_free(conf->igtk_rsc_override);
 	wpabuf_free(conf->eapol_m1_elements);
 	wpabuf_free(conf->eapol_m3_elements);
+	wpabuf_free(conf->ft_auth_resp_elements);
 	wpabuf_free(conf->presp_elements);
 #endif /* CONFIG_TESTING_OPTIONS */
 
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index c1ee0c0727c6..200b22851d3e 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -730,6 +730,7 @@ struct hostapd_bss_config {
 	unsigned int oci_freq_override_wnm_sleep;
 	struct wpabuf *eapol_m1_elements;
 	struct wpabuf *eapol_m3_elements;
+	struct wpabuf *ft_auth_resp_elements;
 	bool eapol_m3_no_encrypt;
 	bool eapol_key_reserved_random;
 	int test_assoc_comeback_type;
diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c
index f5e0c9495834..301382e7a895 100644
--- a/src/ap/wpa_auth.c
+++ b/src/ap/wpa_auth.c
@@ -955,6 +955,8 @@ static void wpa_auth_free_conf(struct wpa_auth_config *conf)
 	conf->eapol_m1_elements = NULL;
 	wpabuf_free(conf->eapol_m3_elements);
 	conf->eapol_m3_elements = NULL;
+	wpabuf_free(conf->ft_auth_resp_elements);
+	conf->ft_auth_resp_elements = NULL;
 #endif /* CONFIG_TESTING_OPTIONS */
 }
 
diff --git a/src/ap/wpa_auth.h b/src/ap/wpa_auth.h
index 55c2a8950722..fd21de55e8f2 100644
--- a/src/ap/wpa_auth.h
+++ b/src/ap/wpa_auth.h
@@ -269,6 +269,7 @@ struct wpa_auth_config {
 	bool delay_eapol_tx;
 	struct wpabuf *eapol_m1_elements;
 	struct wpabuf *eapol_m3_elements;
+	struct wpabuf *ft_auth_resp_elements;
 	bool eapol_m3_no_encrypt;
 	bool eapol_key_reserved_random;
 #endif /* CONFIG_TESTING_OPTIONS */
diff --git a/src/ap/wpa_auth_ft.c b/src/ap/wpa_auth_ft.c
index c028236fb660..926341bd30d4 100644
--- a/src/ap/wpa_auth_ft.c
+++ b/src/ap/wpa_auth_ft.c
@@ -4250,6 +4250,22 @@ pmk_r1_derived:
 		goto fail;
 #endif /* CONFIG_ENC_ASSOC */
 
+#ifdef CONFIG_TESTING_OPTIONS
+	if (conf->ft_auth_resp_elements) {
+		const struct wpabuf *extra = conf->ft_auth_resp_elements;
+		u8 *tmp;
+
+		tmp = os_realloc(*resp_ies, *resp_ies_len + wpabuf_len(extra));
+		if (!tmp)
+			goto fail;
+
+		*resp_ies = tmp;
+		os_memcpy(tmp + *resp_ies_len, wpabuf_head(extra),
+			  wpabuf_len(extra));
+		*resp_ies_len += wpabuf_len(extra);
+	}
+#endif /* CONFIG_TESTING_OPTIONS */
+
 	retval = WLAN_STATUS_SUCCESS;
 	goto out;
 fail:
diff --git a/src/ap/wpa_auth_glue.c b/src/ap/wpa_auth_glue.c
index 32ab00f5628c..aa62334392e3 100644
--- a/src/ap/wpa_auth_glue.c
+++ b/src/ap/wpa_auth_glue.c
@@ -313,6 +313,9 @@ static void hostapd_wpa_auth_conf(struct hostapd_iface *iface,
 		wconf->eapol_m1_elements = wpabuf_dup(conf->eapol_m1_elements);
 	if (conf->eapol_m3_elements)
 		wconf->eapol_m3_elements = wpabuf_dup(conf->eapol_m3_elements);
+	if (conf->ft_auth_resp_elements)
+		wconf->ft_auth_resp_elements =
+			wpabuf_dup(conf->ft_auth_resp_elements);
 	wconf->eapol_m3_no_encrypt = conf->eapol_m3_no_encrypt;
 	wconf->eapol_key_reserved_random = conf->eapol_key_reserved_random;
 #endif /* CONFIG_TESTING_OPTIONS */
-- 
2.55.0




More information about the Hostap mailing list