wlantest: Update STA info based on WPA/RSN IE in EAPOL-Key 2/4

The WPA/RSN IE in EAPOL-Key 2/4 is more reliable than the one in
(Re)Association Request frame. Update the STA info base don the
EAPOL-Key frame so that the correct cipher information is used
even if the (Re)Association Request frame is missing or corrupted
in the capture.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2012-03-21 16:19:00 -07:00 committed by Jouni Malinen
parent e1bd4e1934
commit c81defea87

View file

@ -13,6 +13,7 @@
#include "crypto/crypto.h" #include "crypto/crypto.h"
#include "common/defs.h" #include "common/defs.h"
#include "common/ieee802_11_defs.h" #include "common/ieee802_11_defs.h"
#include "common/ieee802_11_common.h"
#include "common/eapol_common.h" #include "common/eapol_common.h"
#include "common/wpa_common.h" #include "common/wpa_common.h"
#include "rsn_supp/wpa_ie.h" #include "rsn_supp/wpa_ie.h"
@ -219,6 +220,7 @@ static void rx_data_eapol_key_2_of_4(struct wlantest *wt, const u8 *dst,
wpa_hexdump(MSG_MSGDUMP, "EAPOL-Key Key Data - WPA IE", wpa_hexdump(MSG_MSGDUMP, "EAPOL-Key Key Data - WPA IE",
ie.wpa_ie, ie.wpa_ie_len); ie.wpa_ie, ie.wpa_ie_len);
if (os_memcmp(ie.wpa_ie, sta->rsnie, ie.wpa_ie_len) != 0) { if (os_memcmp(ie.wpa_ie, sta->rsnie, ie.wpa_ie_len) != 0) {
struct ieee802_11_elems elems;
wpa_printf(MSG_INFO, "Mismatch in WPA IE between " wpa_printf(MSG_INFO, "Mismatch in WPA IE between "
"EAPOL-Key 2/4 and (Re)Association " "EAPOL-Key 2/4 and (Re)Association "
"Request from " MACSTR, MAC2STR(sta->addr)); "Request from " MACSTR, MAC2STR(sta->addr));
@ -228,6 +230,17 @@ static void rx_data_eapol_key_2_of_4(struct wlantest *wt, const u8 *dst,
"Request", "Request",
sta->rsnie, sta->rsnie,
sta->rsnie[0] ? 2 + sta->rsnie[1] : 0); sta->rsnie[0] ? 2 + sta->rsnie[1] : 0);
/*
* The sniffer may have missed (Re)Association
* Request, so try to survive with the information from
* EAPOL-Key.
*/
os_memset(&elems, 0, sizeof(elems));
elems.wpa_ie = ie.wpa_ie + 2;
elems.wpa_ie_len = ie.wpa_ie_len - 2;
wpa_printf(MSG_DEBUG, "Update STA data based on WPA "
"IE in EAPOL-Key 2/4");
sta_update_assoc(sta, &elems);
} }
} }
@ -235,6 +248,7 @@ static void rx_data_eapol_key_2_of_4(struct wlantest *wt, const u8 *dst,
wpa_hexdump(MSG_MSGDUMP, "EAPOL-Key Key Data - RSN IE", wpa_hexdump(MSG_MSGDUMP, "EAPOL-Key Key Data - RSN IE",
ie.rsn_ie, ie.rsn_ie_len); ie.rsn_ie, ie.rsn_ie_len);
if (os_memcmp(ie.rsn_ie, sta->rsnie, ie.rsn_ie_len) != 0) { if (os_memcmp(ie.rsn_ie, sta->rsnie, ie.rsn_ie_len) != 0) {
struct ieee802_11_elems elems;
wpa_printf(MSG_INFO, "Mismatch in RSN IE between " wpa_printf(MSG_INFO, "Mismatch in RSN IE between "
"EAPOL-Key 2/4 and (Re)Association " "EAPOL-Key 2/4 and (Re)Association "
"Request from " MACSTR, MAC2STR(sta->addr)); "Request from " MACSTR, MAC2STR(sta->addr));
@ -244,6 +258,17 @@ static void rx_data_eapol_key_2_of_4(struct wlantest *wt, const u8 *dst,
"Request", "Request",
sta->rsnie, sta->rsnie,
sta->rsnie[0] ? 2 + sta->rsnie[1] : 0); sta->rsnie[0] ? 2 + sta->rsnie[1] : 0);
/*
* The sniffer may have missed (Re)Association
* Request, so try to survive with the information from
* EAPOL-Key.
*/
os_memset(&elems, 0, sizeof(elems));
elems.rsn_ie = ie.rsn_ie + 2;
elems.rsn_ie_len = ie.rsn_ie_len - 2;
wpa_printf(MSG_DEBUG, "Update STA data based on RSN "
"IE in EAPOL-Key 2/4");
sta_update_assoc(sta, &elems);
} }
} }
} }