aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest/rx_data.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2010-11-07 17:43:10 (GMT)
committerJouni Malinen <j@w1.fi>2010-11-07 21:29:02 (GMT)
commitd06df64d14e591140ba8f0bef17947b3183a14e0 (patch)
tree783eeabde423c1b96233823398d13bd7b8b9f75f /wlantest/rx_data.c
parent3215df77eeaf4fee01d03b1a164b1329cfdcfb52 (diff)
downloadhostap-d06df64d14e591140ba8f0bef17947b3183a14e0.zip
hostap-d06df64d14e591140ba8f0bef17947b3183a14e0.tar.gz
hostap-d06df64d14e591140ba8f0bef17947b3183a14e0.tar.bz2
wlantest: Derive PMK from RADIUS exchange
Decrypt MPPE keys and derive PMK from RADIUS exchange if RADIUS shared secret is known. Use the derived PMK when trying to derive PTK during 4-Way Handshake.
Diffstat (limited to 'wlantest/rx_data.c')
-rw-r--r--wlantest/rx_data.c56
1 files changed, 35 insertions, 21 deletions
diff --git a/wlantest/rx_data.c b/wlantest/rx_data.c
index 0320144..b9a12c9 100644
--- a/wlantest/rx_data.c
+++ b/wlantest/rx_data.c
@@ -110,29 +110,43 @@ static void rx_data_eapol_key_1_of_4(struct wlantest *wt, const u8 *dst,
}
-static void derive_ptk(struct wlantest_bss *bss, struct wlantest_sta *sta,
- u16 ver, const u8 *data, size_t len)
+static int try_pmk(struct wlantest_bss *bss, struct wlantest_sta *sta,
+ u16 ver, const u8 *data, size_t len,
+ struct wlantest_pmk *pmk)
+{
+ struct wpa_ptk ptk;
+ size_t ptk_len = 48; /* FIX: 64 for TKIP */
+ wpa_pmk_to_ptk(pmk->pmk, sizeof(pmk->pmk),
+ "Pairwise key expansion",
+ bss->bssid, sta->addr, sta->anonce, sta->snonce,
+ (u8 *) &ptk, ptk_len,
+ 0 /* FIX: SHA256 based on AKM */);
+ if (check_mic(ptk.kck, ver,
+ data, len) < 0)
+ return -1;
+
+ wpa_printf(MSG_INFO, "Derived PTK for STA " MACSTR " BSSID " MACSTR
+ ")", MAC2STR(sta->addr), MAC2STR(bss->bssid));
+ os_memcpy(&sta->ptk, &ptk, sizeof(ptk));
+ sta->ptk_set = 1;
+ return 0;
+}
+
+
+static void derive_ptk(struct wlantest *wt, struct wlantest_bss *bss,
+ struct wlantest_sta *sta, u16 ver,
+ const u8 *data, size_t len)
{
struct wlantest_pmk *pmk;
dl_list_for_each(pmk, &bss->pmk, struct wlantest_pmk, list) {
- struct wpa_ptk ptk;
- size_t ptk_len = 48; /* FIX: 64 for TKIP */
- wpa_pmk_to_ptk(pmk->pmk, sizeof(pmk->pmk),
- "Pairwise key expansion",
- bss->bssid, sta->addr, sta->anonce, sta->snonce,
- (u8 *) &ptk, ptk_len,
- 0 /* FIX: SHA256 based on AKM */);
- if (check_mic(ptk.kck, ver,
- data, len) < 0)
- continue;
-
- wpa_printf(MSG_INFO, "Derived PTK for STA " MACSTR " BSSID "
- MACSTR ")",
- MAC2STR(sta->addr), MAC2STR(bss->bssid));
- os_memcpy(&sta->ptk, &ptk, sizeof(ptk));
- sta->ptk_set = 1;
- break;
+ if (try_pmk(bss, sta, ver, data, len, pmk) == 0)
+ return;
+ }
+
+ dl_list_for_each(pmk, &wt->pmk, struct wlantest_pmk, list) {
+ if (try_pmk(bss, sta, ver, data, len, pmk) == 0)
+ return;
}
}
@@ -159,7 +173,7 @@ static void rx_data_eapol_key_2_of_4(struct wlantest *wt, const u8 *dst,
hdr = (const struct wpa_eapol_key *) (eapol + 1);
os_memcpy(sta->snonce, hdr->key_nonce, WPA_NONCE_LEN);
key_info = WPA_GET_BE16(hdr->key_info);
- derive_ptk(bss, sta, key_info & WPA_KEY_INFO_TYPE_MASK, data, len);
+ derive_ptk(wt, bss, sta, key_info & WPA_KEY_INFO_TYPE_MASK, data, len);
}
@@ -192,7 +206,7 @@ static void rx_data_eapol_key_3_of_4(struct wlantest *wt, const u8 *dst,
}
os_memcpy(sta->anonce, hdr->key_nonce, WPA_NONCE_LEN);
if (recalc) {
- derive_ptk(bss, sta, key_info & WPA_KEY_INFO_TYPE_MASK,
+ derive_ptk(wt, bss, sta, key_info & WPA_KEY_INFO_TYPE_MASK,
data, len);
}