]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wlantest: Handle variable length MIC field in EAPOL-Key with OWE
authorJouni Malinen <quic_jouni@quicinc.com>
Tue, 8 Aug 2023 07:30:10 +0000 (10:30 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 8 Aug 2023 07:30:10 +0000 (10:30 +0300)
The Key MIC field is of variable length when using OWE, so determine the
correct length based on which group was negotiated for OWE during
association.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
wlantest/rx_eapol.c
wlantest/rx_mgmt.c
wlantest/wlantest.h

index 5a38123ac745f6322f85e892681f079334964ee6..629aa973bc8f3a56c18afaba480fa145025795ae 100644 (file)
@@ -34,17 +34,20 @@ static int is_zero(const u8 *buf, size_t len)
 static size_t determine_mic_len(struct wlantest_sta *sta)
 {
        size_t pmk_len = PMK_LEN;
+       int group = 0;
 
-       if (sta && wpa_key_mgmt_sae_ext_key(sta->key_mgmt) &&
-           sta->sae_group) {
-               switch (sta->sae_group) {
-               case 20:
-                       pmk_len = 48;
-                       break;
-               case 21:
-                       pmk_len = 64;
-                       break;
-               }
+       if (sta && wpa_key_mgmt_sae_ext_key(sta->key_mgmt))
+               group = sta->sae_group;
+       else if (sta && sta->key_mgmt == WPA_KEY_MGMT_OWE)
+               group = sta->owe_group;
+
+       switch (group) {
+       case 20:
+               pmk_len = 48;
+               break;
+       case 21:
+               pmk_len = 64;
+               break;
        }
 
        return wpa_mic_len(sta->key_mgmt, pmk_len);
index 62adaa848b090f591c8815457db3a7066e5e7df8..ba98034bd9facbf6fd0ac6dd36c3b4372ca74d99 100644 (file)
@@ -932,6 +932,11 @@ static void rx_mgmt_assoc_req(struct wlantest *wt, const u8 *data, size_t len)
                sta->rsnxe_len = elems.rsnxe_len;
        }
 
+       if (elems.owe_dh && elems.owe_dh_len >= 2) {
+               sta->owe_group = WPA_GET_LE16(elems.owe_dh);
+               wpa_printf(MSG_DEBUG, "OWE using group %u", sta->owe_group);
+       }
+
        sta->assocreq_capab_info = le_to_host16(mgmt->u.assoc_req.capab_info);
        sta->assocreq_listen_int =
                le_to_host16(mgmt->u.assoc_req.listen_interval);
@@ -1014,6 +1019,7 @@ static void rx_mgmt_assoc_resp(struct wlantest *wt, const u8 *data, size_t len)
        struct wlantest_bss *bss;
        struct wlantest_sta *sta;
        u16 capab, status, aid;
+       struct ieee802_11_elems elems;
        const u8 *ies;
        size_t ies_len;
        struct wpa_ft_ies parse;
@@ -1063,16 +1069,15 @@ static void rx_mgmt_assoc_resp(struct wlantest *wt, const u8 *data, size_t len)
                }
        }
 
+       if (ieee802_11_parse_elems(ies, ies_len, &elems, 0) == ParseFailed) {
+               add_note(wt, MSG_INFO,
+                        "Failed to parse IEs in AssocResp from " MACSTR,
+                        MAC2STR(mgmt->sa));
+       }
+
        if (status == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY) {
-               struct ieee802_11_elems elems;
-               if (ieee802_11_parse_elems(ies, ies_len, &elems, 0) ==
-                   ParseFailed) {
-                       add_note(wt, MSG_INFO, "Failed to parse IEs in "
-                                "AssocResp from " MACSTR,
-                                MAC2STR(mgmt->sa));
-               } else if (elems.timeout_int == NULL ||
-                          elems.timeout_int[0] !=
-                          WLAN_TIMEOUT_ASSOC_COMEBACK) {
+               if (!elems.timeout_int ||
+                   elems.timeout_int[0] != WLAN_TIMEOUT_ASSOC_COMEBACK) {
                        add_note(wt, MSG_INFO, "No valid Timeout Interval IE "
                                 "with Assoc Comeback time in AssocResp "
                                 "(status=30) from " MACSTR,
@@ -1115,6 +1120,11 @@ static void rx_mgmt_assoc_resp(struct wlantest *wt, const u8 *data, size_t len)
                if (parse.r1kh_id)
                        os_memcpy(bss->r1kh_id, parse.r1kh_id, FT_R1KH_ID_LEN);
        }
+
+       if (elems.owe_dh && elems.owe_dh_len >= 2) {
+               sta->owe_group = WPA_GET_LE16(elems.owe_dh);
+               wpa_printf(MSG_DEBUG, "OWE using group %u", sta->owe_group);
+       }
 }
 
 
@@ -1179,6 +1189,11 @@ static void rx_mgmt_reassoc_req(struct wlantest *wt, const u8 *data,
                sta->rsnxe_len = elems.rsnxe_len;
        }
 
+       if (elems.owe_dh && elems.owe_dh_len >= 2) {
+               sta->owe_group = WPA_GET_LE16(elems.owe_dh);
+               wpa_printf(MSG_DEBUG, "OWE using group %u", sta->owe_group);
+       }
+
        sta->assocreq_capab_info =
                le_to_host16(mgmt->u.reassoc_req.capab_info);
        sta->assocreq_listen_int =
@@ -1899,6 +1914,11 @@ static void rx_mgmt_reassoc_resp(struct wlantest *wt, const u8 *data,
                process_bigtk_subelem(wt, bss, sta, kek, kek_len,
                                      parse.bigtk, parse.bigtk_len);
        }
+
+       if (elems.owe_dh && elems.owe_dh_len >= 2) {
+               sta->owe_group = WPA_GET_LE16(elems.owe_dh);
+               wpa_printf(MSG_DEBUG, "OWE using group %u", sta->owe_group);
+       }
 }
 
 
index 6a85cc19ef0778ff6b44bb77e2e7b00570abaee6..068cf3efb5bf626636991ecbee581ea31126053e 100644 (file)
@@ -120,6 +120,7 @@ struct wlantest_sta {
        u32 rx_tid[16 + 1];
 
        u16 sae_group;
+       u16 owe_group;
 };
 
 struct wlantest_tdls {