wlantest: Implement TKIP replay detection

This commit is contained in:
Jouni Malinen 2010-11-13 12:40:36 +02:00
parent 6c9c513783
commit 4dac84539e
3 changed files with 20 additions and 3 deletions

View file

@ -979,8 +979,10 @@ static void rx_data_bss_prot_group(struct wlantest *wt,
return;
}
/* TODO: different replay protection for TKIP */
ccmp_get_pn(pn, data);
if (bss->group_cipher == WPA_CIPHER_TKIP)
tkip_get_pn(pn, data);
else
ccmp_get_pn(pn, data);
if (os_memcmp(pn, bss->rsc[keyid], 6) <= 0) {
wpa_printf(MSG_INFO, "CCMP/TKIP replay detected: SA=" MACSTR,
MAC2STR(hdr->addr2));
@ -1061,7 +1063,10 @@ static void rx_data_bss_prot(struct wlantest *wt,
rsc = sta->rsc_fromds[tid];
ccmp_get_pn(pn, data);
if (sta->pairwise_cipher == WPA_CIPHER_TKIP)
tkip_get_pn(pn, data);
else
ccmp_get_pn(pn, data);
if (os_memcmp(pn, rsc, 6) <= 0) {
wpa_printf(MSG_INFO, "CCMP/TKIP replay detected: SA=" MACSTR,
MAC2STR(hdr->addr2));

View file

@ -392,3 +392,14 @@ u8 * tkip_decrypt(const u8 *tk, const struct ieee80211_hdr *hdr,
*decrypted_len = plain_len - 8;
return plain;
}
void tkip_get_pn(u8 *pn, const u8 *data)
{
pn[0] = data[7]; /* PN5 */
pn[1] = data[6]; /* PN4 */
pn[2] = data[5]; /* PN3 */
pn[3] = data[4]; /* PN2 */
pn[4] = data[0]; /* PN1 */
pn[5] = data[2]; /* PN0 */
}

View file

@ -155,5 +155,6 @@ void ccmp_get_pn(u8 *pn, const u8 *data);
u8 * tkip_decrypt(const u8 *tk, const struct ieee80211_hdr *hdr,
const u8 *data, size_t data_len, size_t *decrypted_len);
void tkip_get_pn(u8 *pn, const u8 *data);
#endif /* WLANTEST_H */