Add test code for fetching the last configured GTK
This can be useful for some test cases, so allow wpa_supplicant to be built with special test functionality to expose the current (last configured) GTK. This is disabled by default and can be enabled by adding following line into .config: CFLAGS += -DCONFIG_TESTING_GET_GTK The GTK can then be fetched with "wpa_cli get gtk". Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
parent
576bce9c86
commit
fa7ae9501b
3 changed files with 20 additions and 0 deletions
wpa_supplicant
|
@ -461,6 +461,14 @@ static int wpa_supplicant_ctrl_iface_get(struct wpa_supplicant *wpa_s,
|
||||||
return -1;
|
return -1;
|
||||||
return res;
|
return res;
|
||||||
#endif /* CONFIG_WIFI_DISPLAY */
|
#endif /* CONFIG_WIFI_DISPLAY */
|
||||||
|
#ifdef CONFIG_TESTING_GET_GTK
|
||||||
|
} else if (os_strcmp(cmd, "gtk") == 0) {
|
||||||
|
if (wpa_s->last_gtk_len == 0)
|
||||||
|
return -1;
|
||||||
|
res = wpa_snprintf_hex(buf, buflen, wpa_s->last_gtk,
|
||||||
|
wpa_s->last_gtk_len);
|
||||||
|
return res;
|
||||||
|
#endif /* CONFIG_TESTING_GET_GTK */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res < 0 || (unsigned int) res >= buflen)
|
if (res < 0 || (unsigned int) res >= buflen)
|
||||||
|
|
|
@ -708,6 +708,11 @@ struct wpa_supplicant {
|
||||||
u8 wnm_bss_termination_duration[12];
|
u8 wnm_bss_termination_duration[12];
|
||||||
struct neighbor_report *wnm_neighbor_report_elements;
|
struct neighbor_report *wnm_neighbor_report_elements;
|
||||||
#endif /* CONFIG_WNM */
|
#endif /* CONFIG_WNM */
|
||||||
|
|
||||||
|
#ifdef CONFIG_TESTING_GET_GTK
|
||||||
|
u8 last_gtk[32];
|
||||||
|
size_t last_gtk_len;
|
||||||
|
#endif /* CONFIG_TESTING_GET_GTK */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -437,6 +437,13 @@ static int wpa_supplicant_set_key(void *_wpa_s, enum wpa_alg alg,
|
||||||
/* Clear the MIC error counter when setting a new PTK. */
|
/* Clear the MIC error counter when setting a new PTK. */
|
||||||
wpa_s->mic_errors_seen = 0;
|
wpa_s->mic_errors_seen = 0;
|
||||||
}
|
}
|
||||||
|
#ifdef CONFIG_TESTING_GET_GTK
|
||||||
|
if (key_idx > 0 && addr && is_broadcast_ether_addr(addr) &&
|
||||||
|
alg != WPA_ALG_NONE && key_len <= sizeof(wpa_s->last_gtk)) {
|
||||||
|
os_memcpy(wpa_s->last_gtk, key, key_len);
|
||||||
|
wpa_s->last_gtk_len = key_len;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_TESTING_GET_GTK */
|
||||||
return wpa_drv_set_key(wpa_s, alg, addr, key_idx, set_tx, seq, seq_len,
|
return wpa_drv_set_key(wpa_s, alg, addr, key_idx, set_tx, seq, seq_len,
|
||||||
key, key_len);
|
key, key_len);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue