[PATCH 1/3] hostapd: ctrl_iface: add commands to get GTK/IGTK/BIGTK

Johannes Berg johannes at sipsolutions.net
Fri Sep 11 07:21:56 PDT 2026


From: Johannes Berg <johannes.berg at intel.com>

For some of the tests that the relay module enables we'll
have to have beacon protection, so the relay will have to
recalculate the MIC in the MME.

Add testing commands to get the GTK/IGTK/BIGTK from hostapd.

Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 hostapd/ctrl_iface.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 380a7bc24b6b..dc36b302de57 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -2559,6 +2559,39 @@ static int hostapd_ctrl_get_pmk(struct hostapd_data *hapd, const char *cmd,
 }
 
 
+static int hostapd_ctrl_get_gtk(struct hostapd_data *hapd, char *buf,
+				size_t buflen)
+{
+	if (hapd->last_gtk_alg == WPA_ALG_NONE)
+		return -1;
+
+	return wpa_snprintf_hex(buf, buflen, hapd->last_gtk,
+				hapd->last_gtk_len);
+}
+
+
+static int hostapd_ctrl_get_igtk(struct hostapd_data *hapd, char *buf,
+				 size_t buflen)
+{
+	if (hapd->last_igtk_alg == WPA_ALG_NONE)
+		return -1;
+
+	return wpa_snprintf_hex(buf, buflen, hapd->last_igtk,
+				hapd->last_igtk_len);
+}
+
+
+static int hostapd_ctrl_get_bigtk(struct hostapd_data *hapd, char *buf,
+				  size_t buflen)
+{
+	if (hapd->last_bigtk_alg == WPA_ALG_NONE)
+		return -1;
+
+	return wpa_snprintf_hex(buf, buflen, hapd->last_bigtk,
+				hapd->last_bigtk_len);
+}
+
+
 static int hostapd_ctrl_register_frame(struct hostapd_data *hapd,
 				       const char *cmd)
 {
@@ -4486,6 +4519,12 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
 	} else if (os_strncmp(buf, "GET_PMK ", 8) == 0) {
 		reply_len = hostapd_ctrl_get_pmk(hapd, buf + 8, reply,
 						 reply_size);
+	} else if (os_strcmp(buf, "GET_GTK") == 0) {
+		reply_len = hostapd_ctrl_get_gtk(hapd, reply, reply_size);
+	} else if (os_strcmp(buf, "GET_IGTK") == 0) {
+		reply_len = hostapd_ctrl_get_igtk(hapd, reply, reply_size);
+	} else if (os_strcmp(buf, "GET_BIGTK") == 0) {
+		reply_len = hostapd_ctrl_get_bigtk(hapd, reply, reply_size);
 	} else if (os_strncmp(buf, "REGISTER_FRAME ", 15) == 0) {
 		if (hostapd_ctrl_register_frame(hapd, buf + 16) < 0)
 			reply_len = -1;
-- 
2.55.0




More information about the Hostap mailing list