FT: Make FTE MIC calculation more flexible

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 e6f64a8e1d ("FT: FTE MIC
calculation for MLO Reassociation Request frame").

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
This commit is contained in:
Jouni Malinen 2023-08-25 11:28:44 +03:00 committed by Jouni Malinen
parent ff02f734ba
commit 7381c60db8
3 changed files with 29 additions and 14 deletions

View 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 *rsnie, size_t rsnie_len,
const u8 *ric, size_t ric_len, const u8 *ric, size_t ric_len,
const u8 *rsnxe, size_t rsnxe_len, const u8 *rsnxe, size_t rsnxe_len,
const u8 link_addr[MAX_NUM_MLO_LINKS][ETH_ALEN], const struct wpabuf *extra,
u8 *mic) u8 *mic)
{ {
const u8 *addr[10 + MAX_NUM_MLO_LINKS]; const u8 *addr[11];
size_t len[10 + MAX_NUM_MLO_LINKS]; size_t len[11];
size_t i, num_elem = 0; size_t i, num_elem = 0;
u8 zero_mic[32]; u8 zero_mic[32];
size_t mic_len, fte_fixed_len; 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++; num_elem++;
} }
if (link_addr) { if (extra) {
for (i = 0; i < MAX_NUM_MLO_LINKS; i++) { addr[num_elem] = wpabuf_head(extra);
if (is_zero_ether_addr(link_addr[i])) len[num_elem] = wpabuf_len(extra);
continue; num_elem++;
addr[num_elem] = link_addr[i];
len[num_elem] = ETH_ALEN;
num_elem++;
}
} }
for (i = 0; i < num_elem; i++) for (i = 0; i < num_elem; i++)

View file

@ -452,7 +452,6 @@ struct rsn_rdie {
#pragma pack(pop) #pragma pack(pop)
#endif /* _MSC_VER */ #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, int wpa_eapol_key_mic(const u8 *key, size_t key_len, int akmp, int ver,
const u8 *buf, size_t len, u8 *mic); 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 *rsnie, size_t rsnie_len,
const u8 *ric, size_t ric_len, const u8 *ric, size_t ric_len,
const u8 *rsnxe, size_t rsnxe_len, const u8 *rsnxe, size_t rsnxe_len,
const u8 link_addr[MAX_NUM_MLO_LINKS][ETH_ALEN], const struct wpabuf *extra,
u8 *mic); u8 *mic);
int wpa_derive_pmk_r0(const u8 *xxkey, size_t xxkey_len, int wpa_derive_pmk_r0(const u8 *xxkey, size_t xxkey_len,
const u8 *ssid, size_t ssid_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); const u8 *ie2, size_t ie2len);
int wpa_insert_pmkid(u8 *ies, size_t *ies_len, const u8 *pmkid); int wpa_insert_pmkid(u8 *ies, size_t *ies_len, const u8 *pmkid);
#define MAX_NUM_MLO_LINKS 15
struct wpa_ft_ies { struct wpa_ft_ies {
const u8 *mdie; const u8 *mdie;
size_t mdie_len; size_t mdie_len;

View file

@ -1290,6 +1290,7 @@ static void rx_mgmt_reassoc_req(struct wlantest *wt, const u8 *data,
const u8 *kck; const u8 *kck;
size_t kck_len; size_t kck_len;
const u8 *aa, *spa; const u8 *aa, *spa;
struct wpabuf *extra = NULL;
if (elems.basic_mle) { if (elems.basic_mle) {
aa = bss->mld_mac_addr; 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 = sta->ptk.kck;
kck_len = sta->ptk.kck_len; 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, if (wpa_ft_mic(sta->key_mgmt, kck, kck_len,
spa, aa, 5, spa, aa, 5,
parse.mdie - 2, parse.mdie_len + 2, 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.ric, parse.ric_len,
parse.rsnxe ? parse.rsnxe - 2 : NULL, parse.rsnxe ? parse.rsnxe - 2 : NULL,
parse.rsnxe ? parse.rsnxe_len + 2 : 0, parse.rsnxe ? parse.rsnxe_len + 2 : 0,
elems.basic_mle ? sta->link_addr : NULL, extra,
mic) < 0) { mic) < 0) {
wpabuf_free(extra);
add_note(wt, MSG_INFO, "FT: Failed to calculate MIC"); add_note(wt, MSG_INFO, "FT: Failed to calculate MIC");
return; return;
} }
wpabuf_free(extra);
if (os_memcmp_const(mic, fte_mic, mic_len) != 0) { if (os_memcmp_const(mic, fte_mic, mic_len) != 0) {
int link_id; int link_id;