]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
FT: Make FTE MIC calculation more flexible
authorJouni Malinen <quic_jouni@quicinc.com>
Fri, 25 Aug 2023 08:28:44 +0000 (11:28 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 25 Aug 2023 08:28:44 +0000 (11:28 +0300)
Generate the "extra" data buffer outside wpa_ft_mic() to make this
function easier to share for MLO FT Reassociation Response frame. This
replaces the earlier design in commit e6f64a8e1daf ("FT: FTE MIC
calculation for MLO Reassociation Request frame").

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

index 4456e6a1662c44b60340cee12b01d37f9bd8e674..c11b461ebcaaf4db1d070d7e54856f720a7638c9 100644 (file)
@@ -890,11 +890,11 @@ int wpa_ft_mic(int key_mgmt, const u8 *kck, size_t kck_len, const u8 *sta_addr,
               const u8 *rsnie, size_t rsnie_len,
               const u8 *ric, size_t ric_len,
               const u8 *rsnxe, size_t rsnxe_len,
-              const u8 link_addr[MAX_NUM_MLO_LINKS][ETH_ALEN],
+              const struct wpabuf *extra,
               u8 *mic)
 {
-       const u8 *addr[10 + MAX_NUM_MLO_LINKS];
-       size_t len[10 + MAX_NUM_MLO_LINKS];
+       const u8 *addr[11];
+       size_t len[11];
        size_t i, num_elem = 0;
        u8 zero_mic[32];
        size_t mic_len, fte_fixed_len;
@@ -972,14 +972,10 @@ int wpa_ft_mic(int key_mgmt, const u8 *kck, size_t kck_len, const u8 *sta_addr,
                num_elem++;
        }
 
-       if (link_addr) {
-               for (i = 0; i < MAX_NUM_MLO_LINKS; i++) {
-                       if (is_zero_ether_addr(link_addr[i]))
-                               continue;
-                       addr[num_elem] = link_addr[i];
-                       len[num_elem] = ETH_ALEN;
-                       num_elem++;
-               }
+       if (extra) {
+               addr[num_elem] = wpabuf_head(extra);
+               len[num_elem] = wpabuf_len(extra);
+               num_elem++;
        }
 
        for (i = 0; i < num_elem; i++)
index 2a7c75224e3aa39807a79a4c0c39028e2b157e5a..bfcd717810657327d04d50cbbb70842cdef2271a 100644 (file)
@@ -452,7 +452,6 @@ struct rsn_rdie {
 #pragma pack(pop)
 #endif /* _MSC_VER */
 
-#define MAX_NUM_MLO_LINKS 15
 
 int wpa_eapol_key_mic(const u8 *key, size_t key_len, int akmp, int ver,
                      const u8 *buf, size_t len, u8 *mic);
@@ -486,7 +485,7 @@ int wpa_ft_mic(int key_mgmt, const u8 *kck, size_t kck_len, const u8 *sta_addr,
               const u8 *rsnie, size_t rsnie_len,
               const u8 *ric, size_t ric_len,
               const u8 *rsnxe, size_t rsnxe_len,
-              const u8 link_addr[MAX_NUM_MLO_LINKS][ETH_ALEN],
+              const struct wpabuf *extra,
               u8 *mic);
 int wpa_derive_pmk_r0(const u8 *xxkey, size_t xxkey_len,
                      const u8 *ssid, size_t ssid_len,
@@ -558,6 +557,8 @@ int wpa_compare_rsn_ie(int ft_initial_assoc,
                       const u8 *ie2, size_t ie2len);
 int wpa_insert_pmkid(u8 *ies, size_t *ies_len, const u8 *pmkid);
 
+#define MAX_NUM_MLO_LINKS 15
+
 struct wpa_ft_ies {
        const u8 *mdie;
        size_t mdie_len;
index 82a2255c22c34289d611172c098ca647584c76d9..461679e5ec6c7d18e59a1befb8d7901f1b944209 100644 (file)
@@ -1290,6 +1290,7 @@ static void rx_mgmt_reassoc_req(struct wlantest *wt, const u8 *data,
                const u8 *kck;
                size_t kck_len;
                const u8 *aa, *spa;
+               struct wpabuf *extra = NULL;
 
                if (elems.basic_mle) {
                        aa = bss->mld_mac_addr;
@@ -1425,6 +1426,21 @@ static void rx_mgmt_reassoc_req(struct wlantest *wt, const u8 *data,
                        kck = sta->ptk.kck;
                        kck_len = sta->ptk.kck_len;
                }
+
+               if (elems.basic_mle) {
+                       int i;
+
+                       extra = wpabuf_alloc(MAX_NUM_MLO_LINKS * ETH_ALEN);
+                       if (!extra)
+                               return;
+                       for (i = 0; i < MAX_NUM_MLO_LINKS; i++) {
+                               if (!is_zero_ether_addr(sta->link_addr[i]))
+                                       wpabuf_put_data(extra,
+                                                       sta->link_addr[i],
+                                                       ETH_ALEN);
+                       }
+               }
+
                if (wpa_ft_mic(sta->key_mgmt, kck, kck_len,
                               spa, aa, 5,
                               parse.mdie - 2, parse.mdie_len + 2,
@@ -1433,11 +1449,13 @@ static void rx_mgmt_reassoc_req(struct wlantest *wt, const u8 *data,
                               parse.ric, parse.ric_len,
                               parse.rsnxe ? parse.rsnxe - 2 : NULL,
                               parse.rsnxe ? parse.rsnxe_len + 2 : 0,
-                              elems.basic_mle ? sta->link_addr : NULL,
+                              extra,
                               mic) < 0) {
+                       wpabuf_free(extra);
                        add_note(wt, MSG_INFO, "FT: Failed to calculate MIC");
                        return;
                }
+               wpabuf_free(extra);
 
                if (os_memcmp_const(mic, fte_mic, mic_len) != 0) {
                        int link_id;