aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wlantest/ctrl.c12
-rw-r--r--wlantest/rx_eapol.c12
-rw-r--r--wlantest/wlantest.h4
-rw-r--r--wlantest/wlantest_cli.c1
-rw-r--r--wlantest/wlantest_ctrl.h1
5 files changed, 26 insertions, 4 deletions
diff --git a/wlantest/ctrl.c b/wlantest/ctrl.c
index 2132b2b..32509b3 100644
--- a/wlantest/ctrl.c
+++ b/wlantest/ctrl.c
@@ -990,6 +990,15 @@ static void info_print_state(char *buf, size_t len, int state)
}
+static void info_print_gtk(char *buf, size_t len, struct wlantest_sta *sta)
+{
+ size_t pos;
+
+ pos = os_snprintf(buf, len, "IDX=%d,GTK=", sta->gtk_idx);
+ wpa_snprintf_hex(buf + pos, len - pos, sta->gtk, sta->gtk_len);
+}
+
+
static void ctrl_info_sta(struct wlantest *wt, int sock, u8 *cmd, size_t clen)
{
u8 *addr;
@@ -1029,6 +1038,9 @@ static void ctrl_info_sta(struct wlantest *wt, int sock, u8 *cmd, size_t clen)
case WLANTEST_STA_INFO_STATE:
info_print_state(resp, sizeof(resp), sta->state);
break;
+ case WLANTEST_STA_INFO_GTK:
+ info_print_gtk(resp, sizeof(resp), sta);
+ break;
default:
ctrl_send_simple(wt, sock, WLANTEST_CTRL_INVALID_CMD);
return;
diff --git a/wlantest/rx_eapol.c b/wlantest/rx_eapol.c
index e98dbe2..7619baf 100644
--- a/wlantest/rx_eapol.c
+++ b/wlantest/rx_eapol.c
@@ -326,8 +326,8 @@ static u8 * decrypt_eapol_key_data(const u8 *kek, u16 ver,
}
-static void learn_kde_keys(struct wlantest_bss *bss, const u8 *buf, size_t len,
- const u8 *rsc)
+static void learn_kde_keys(struct wlantest_bss *bss, struct wlantest_sta *sta,
+ const u8 *buf, size_t len, const u8 *rsc)
{
struct wpa_eapol_ie_parse ie;
@@ -361,7 +361,9 @@ static void learn_kde_keys(struct wlantest_bss *bss, const u8 *buf, size_t len,
wpa_hexdump(MSG_DEBUG, "GTK", ie.gtk + 2,
ie.gtk_len - 2);
bss->gtk_len[id] = ie.gtk_len - 2;
+ sta->gtk_len = ie.gtk_len - 2;
os_memcpy(bss->gtk[id], ie.gtk + 2, ie.gtk_len - 2);
+ os_memcpy(sta->gtk, ie.gtk + 2, ie.gtk_len - 2);
bss->rsc[id][0] = rsc[5];
bss->rsc[id][1] = rsc[4];
bss->rsc[id][2] = rsc[3];
@@ -369,6 +371,7 @@ static void learn_kde_keys(struct wlantest_bss *bss, const u8 *buf, size_t len,
bss->rsc[id][4] = rsc[1];
bss->rsc[id][5] = rsc[0];
bss->gtk_idx = id;
+ sta->gtk_idx = id;
wpa_hexdump(MSG_DEBUG, "RSC", bss->rsc[id], 6);
} else {
wpa_printf(MSG_INFO, "Invalid GTK KDE length %u",
@@ -561,7 +564,7 @@ static void rx_data_eapol_key_3_of_4(struct wlantest *wt, const u8 *dst,
bss->rsnie[0] ? 2 + bss->rsnie[1] : 0);
}
- learn_kde_keys(bss, decrypted, decrypted_len, hdr->key_rsc);
+ learn_kde_keys(bss, sta, decrypted, decrypted_len, hdr->key_rsc);
os_free(decrypted_buf);
}
@@ -711,7 +714,8 @@ static void rx_data_eapol_key_1_of_2(struct wlantest *wt, const u8 *dst,
decrypted, plain_len);
}
if (sta->proto & WPA_PROTO_RSN)
- learn_kde_keys(bss, decrypted, decrypted_len, hdr->key_rsc);
+ learn_kde_keys(bss, sta, decrypted, decrypted_len,
+ hdr->key_rsc);
else {
int klen = bss->group_cipher == WPA_CIPHER_TKIP ? 32 : 16;
if (decrypted_len == klen) {
diff --git a/wlantest/wlantest.h b/wlantest/wlantest.h
index 4c65d48..18ea3b9 100644
--- a/wlantest/wlantest.h
+++ b/wlantest/wlantest.h
@@ -93,6 +93,10 @@ struct wlantest_sta {
int pwrmgt;
int pspoll;
+
+ u8 gtk[32];
+ size_t gtk_len;
+ int gtk_idx;
};
struct wlantest_tdls {
diff --git a/wlantest/wlantest_cli.c b/wlantest/wlantest_cli.c
index 6377fc1..b957488 100644
--- a/wlantest/wlantest_cli.c
+++ b/wlantest/wlantest_cli.c
@@ -1226,6 +1226,7 @@ static const struct sta_infos sta_infos[] = {
{ "key_mgmt", WLANTEST_STA_INFO_KEY_MGMT },
{ "rsn_capab", WLANTEST_STA_INFO_RSN_CAPAB },
{ "state", WLANTEST_STA_INFO_STATE },
+ { "gtk", WLANTEST_STA_INFO_GTK },
{ NULL, 0 }
};
diff --git a/wlantest/wlantest_ctrl.h b/wlantest/wlantest_ctrl.h
index 9731bd6..b0c8123 100644
--- a/wlantest/wlantest_ctrl.h
+++ b/wlantest/wlantest_ctrl.h
@@ -157,6 +157,7 @@ enum wlantest_sta_info {
WLANTEST_STA_INFO_KEY_MGMT,
WLANTEST_STA_INFO_RSN_CAPAB,
WLANTEST_STA_INFO_STATE,
+ WLANTEST_STA_INFO_GTK,
};
enum wlantest_bss_info {