From 4158b80eef04c32a42e3412dc36c430349fc8a92 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 14 Oct 2017 12:15:52 +0300 Subject: [PATCH] wlantest: Do not update RSC on replays This changes wlantest behavior to mark CCMP/TKIP replays for more cases in case a device is resetting its TSC. Previously, the RSC check got cleared on the first marked replay and the following packets were not marked as replays if they continued incrementing the PN even if that PN was below the highest value received with this key at some point in the past. Signed-off-by: Jouni Malinen --- wlantest/rx_data.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wlantest/rx_data.c b/wlantest/rx_data.c index 384e4dc7e..23586eaee 100644 --- a/wlantest/rx_data.c +++ b/wlantest/rx_data.c @@ -146,6 +146,7 @@ static void rx_data_bss_prot_group(struct wlantest *wt, u8 *decrypted = NULL; size_t dlen; u8 pn[6]; + int replay = 0; bss = bss_get(wt, hdr->addr2); if (bss == NULL) @@ -211,6 +212,7 @@ static void rx_data_bss_prot_group(struct wlantest *wt, " Retry" : ""); wpa_hexdump(MSG_INFO, "RX PN", pn, 6); wpa_hexdump(MSG_INFO, "RSC", bss->rsc[keyid], 6); + replay = 1; } skip_replay_det: @@ -233,7 +235,8 @@ skip_replay_det: if (decrypted) { rx_data_process(wt, bss->bssid, NULL, dst, src, decrypted, dlen, 1, NULL); - os_memcpy(bss->rsc[keyid], pn, 6); + if (!replay) + os_memcpy(bss->rsc[keyid], pn, 6); write_pcap_decrypted(wt, (const u8 *) hdr, hdrlen, decrypted, dlen); } else @@ -259,6 +262,7 @@ static void rx_data_bss_prot(struct wlantest *wt, const u8 *tk = NULL; int ptk_iter_done = 0; int try_ptk_iter = 0; + int replay = 0; if (hdr->addr1[0] & 0x01) { rx_data_bss_prot_group(wt, hdr, hdrlen, qos, dst, src, @@ -413,6 +417,7 @@ static void rx_data_bss_prot(struct wlantest *wt, " Retry" : ""); wpa_hexdump(MSG_INFO, "RX PN", pn, 6); wpa_hexdump(MSG_INFO, "RSC", rsc, 6); + replay = 1; } skip_replay_det: @@ -457,7 +462,8 @@ skip_replay_det: const u8 *peer_addr = NULL; if (!(fc & (WLAN_FC_FROMDS | WLAN_FC_TODS))) peer_addr = hdr->addr1; - os_memcpy(rsc, pn, 6); + if (!replay) + os_memcpy(rsc, pn, 6); rx_data_process(wt, bss->bssid, sta->addr, dst, src, decrypted, dlen, 1, peer_addr); write_pcap_decrypted(wt, (const u8 *) hdr, hdrlen, -- 2.39.2