diff mbox series

[v3,1/6] hostapd: ctrl_iface: add commands to get GTK/IGTK/BIGTK

Message ID 20260914144205.4bbd4597b9f5.I91a1d4893862b7f2e04707626ba62c2216e835c9@changeid
State New
Headers show
Series [v3,1/6] hostapd: ctrl_iface: add commands to get GTK/IGTK/BIGTK | expand

Commit Message

Johannes Berg Sept. 14, 2026, 12:42 p.m. UTC
From: Johannes Berg <johannes.berg@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@intel.com>
---
 hostapd/ctrl_iface.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
diff mbox series

Patch

diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 6c197c36e1ec..c37e9cec5989 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -2575,6 +2575,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)
 {
@@ -4502,6 +4535,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;