From 0cd2bfc8a40283f1a0ddf552b437e58723ce78f8 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 1 Sep 2023 00:03:16 +0300 Subject: [PATCH] wlantest: Fix FTE MIC calculation for MLO Reassociation Response frames The AP's RSNE needs to be modified by inserting the PMKR1Name in the PMKID List field for each affiliated link. Fixes: 8cf919ffd5c4 ("wlantest: FTE MIC calculation for MLO Reassociation Response frame") Signed-off-by: Jouni Malinen --- wlantest/rx_mgmt.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/wlantest/rx_mgmt.c b/wlantest/rx_mgmt.c index 990c09914..77993c929 100644 --- a/wlantest/rx_mgmt.c +++ b/wlantest/rx_mgmt.c @@ -2031,6 +2031,8 @@ static void rx_mgmt_reassoc_resp(struct wlantest *wt, const u8 *data, if (ml) { int link_id; struct wlantest_bss *l_bss; + u8 rsne_buf[257]; + size_t rsne_len; extra = wpabuf_alloc(MAX_NUM_MLO_LINKS * ETH_ALEN); rsne = wpabuf_alloc(MAX_NUM_MLO_LINKS * 256); @@ -2040,6 +2042,8 @@ static void rx_mgmt_reassoc_resp(struct wlantest *wt, const u8 *data, for (link_id = 0; link_id < MAX_NUM_MLO_LINKS; link_id++) { + struct wpa_ie_data ie_data; + if (is_zero_ether_addr(sta->link_addr[link_id])) continue; @@ -2054,9 +2058,29 @@ static void rx_mgmt_reassoc_resp(struct wlantest *wt, const u8 *data, continue; } + /* Insert PMKID=PMKR1Name into each RSNE */ + rsne_len = 2 + l_bss->rsnie[1]; + if (wpa_parse_wpa_ie_rsn(l_bss->rsnie, + rsne_len, &ie_data) < + 0 || + rsne_len > 200) { + wpa_printf(MSG_DEBUG, + "FT: Could not parse AP RSNE (or too long element) for link ID %u ", + link_id); + continue; + } + + os_memcpy(rsne_buf, l_bss->rsnie, rsne_len); + if (wpa_insert_pmkid(rsne_buf, &rsne_len, + sta->pmk_r1_name) < 0) { + wpa_printf(MSG_DEBUG, + "FT: Could not insert PMKR1Name into AP RSNE for link ID %u ", + link_id); + continue; + } + count++; /* RSNE */ - wpabuf_put_data(rsne, l_bss->rsnie, - 2 + l_bss->rsnie[1]); + wpabuf_put_data(rsne, rsne_buf, rsne_len); if (l_bss->rsnxe_len) { count++;