]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wlantest: Fix TK iteration based on the PTK file
authorJouni Malinen <quic_jouni@quicinc.com>
Thu, 1 Feb 2024 17:51:56 +0000 (19:51 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 1 Feb 2024 17:51:56 +0000 (19:51 +0200)
Use of ptk_len is not valid here to check what is the length of the
actual TK. Fix this by using ptk->tk_len instead so that the appropriate
decryption function can be selected for cases where the TKs are
configured through the PTK file.

Fixes: ce7bdb54e5c9 ("wlantest: Extend Management frame decryption to support GCMP and CCMP-256")
Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
wlantest/rx_mgmt.c

index 6fa61612c0c28969f3ad57d7649e0adcb7c9b16f..ac7ea6abc4ac46d56bcefe1647274893d7fc8c8c 100644 (file)
@@ -3062,21 +3062,21 @@ static int check_bip(struct wlantest *wt, const u8 *data, size_t len)
 }
 
 
-static u8 * try_tk(struct wpa_ptk *ptk, size_t ptk_len,
+static u8 * try_tk(struct wpa_ptk *ptk,
                   const u8 *data, size_t len, size_t *dlen)
 {
        const struct ieee80211_hdr *hdr;
        u8 *decrypted, *frame;
 
        hdr = (const struct ieee80211_hdr *) data;
-       if (ptk_len == 16) {
+       if (ptk->tk_len == 16) {
                decrypted = ccmp_decrypt(ptk->tk, hdr, NULL, NULL, NULL,
                                         data + 24, len - 24, dlen);
                if (!decrypted)
                        decrypted = gcmp_decrypt(ptk->tk, 16, hdr, NULL, NULL,
                                                 NULL,
                                                 data + 24, len - 24, dlen);
-       } else if (ptk_len == 32) {
+       } else if (ptk->tk_len == 32) {
                decrypted = ccmp_256_decrypt(ptk->tk, hdr, NULL, NULL, NULL,
                                             data + 24, len - 24, dlen);
                if (!decrypted)
@@ -3112,7 +3112,7 @@ static u8 * mgmt_decrypt_tk(struct wlantest *wt, const u8 *data, size_t len,
 
        wpa_debug_level = MSG_WARNING;
        dl_list_for_each(ptk, &wt->ptk, struct wlantest_ptk, list) {
-               decrypted = try_tk(&ptk->ptk, ptk->ptk_len, data, len, dlen);
+               decrypted = try_tk(&ptk->ptk, data, len, dlen);
                if (decrypted) {
                        wpa_debug_level = prev_level;
                        add_note(wt, MSG_DEBUG,