aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest/rx_eapol.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2013-11-17 20:52:15 (GMT)
committerJouni Malinen <j@w1.fi>2013-11-17 21:09:38 (GMT)
commita0530dff5b34d2758375afbb0b4bc808bb3c06d4 (patch)
treee67f28a542262a66290a87ee34b1c1059f3b8d9f /wlantest/rx_eapol.c
parent848bb8dea9ec5765a559df753a8cd0cfe290cabf (diff)
downloadhostap-a0530dff5b34d2758375afbb0b4bc808bb3c06d4.zip
hostap-a0530dff5b34d2758375afbb0b4bc808bb3c06d4.tar.gz
hostap-a0530dff5b34d2758375afbb0b4bc808bb3c06d4.tar.bz2
wlantest: Allow additional PTKs to be specified from a file
A text file with a hexdump of PTK (KCK|KEK=TK with 48 octets for CCMP or 64 octets for TKIP or alternative 16 or 32 octet TK for CCMP/TKIP) can now be read from a file specified with the -T command line argument. If the current known PTK fails to decrypt a frame (or if no current PTK is known) all listed PTKs are iterated to see if any of them matches. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wlantest/rx_eapol.c')
-rw-r--r--wlantest/rx_eapol.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/wlantest/rx_eapol.c b/wlantest/rx_eapol.c
index b18b3cf..5fde05a 100644
--- a/wlantest/rx_eapol.c
+++ b/wlantest/rx_eapol.c
@@ -19,6 +19,8 @@
#include "rsn_supp/wpa_ie.h"
#include "wlantest.h"
+extern int wpa_debug_level;
+
static int is_zero(const u8 *buf, size_t len)
{
@@ -157,6 +159,33 @@ static void derive_ptk(struct wlantest *wt, struct wlantest_bss *bss,
if (try_pmk(wt, bss, sta, ver, data, len, pmk) == 0)
return;
}
+
+ if (!sta->ptk_set) {
+ struct wlantest_ptk *ptk;
+ int prev_level = wpa_debug_level;
+
+ wpa_debug_level = MSG_WARNING;
+ dl_list_for_each(ptk, &wt->ptk, struct wlantest_ptk, list) {
+ if (check_mic(ptk->ptk.kck, ver, data, len) < 0)
+ continue;
+ wpa_printf(MSG_INFO, "Pre-set PTK matches for STA "
+ MACSTR " BSSID " MACSTR,
+ MAC2STR(sta->addr), MAC2STR(bss->bssid));
+ add_note(wt, MSG_DEBUG, "Using pre-set PTK");
+ os_memcpy(&sta->ptk, &ptk->ptk, sizeof(ptk->ptk));
+ wpa_hexdump(MSG_DEBUG, "PTK:KCK", sta->ptk.kck, 16);
+ wpa_hexdump(MSG_DEBUG, "PTK:KEK", sta->ptk.kek, 16);
+ wpa_hexdump(MSG_DEBUG, "PTK:TK1", sta->ptk.tk1, 16);
+ if (ptk->ptk_len > 48)
+ wpa_hexdump(MSG_DEBUG, "PTK:TK2",
+ sta->ptk.u.tk2, 16);
+ sta->ptk_set = 1;
+ os_memset(sta->rsc_tods, 0, sizeof(sta->rsc_tods));
+ os_memset(sta->rsc_fromds, 0, sizeof(sta->rsc_fromds));
+ }
+ wpa_debug_level = prev_level;
+ }
+
add_note(wt, MSG_DEBUG, "No matching PMK found to derive PTK");
}