wlantest: Adjust kdk_len according to RSNX capability

This is needed to derive the PTK correct when Secure LTF support is used
and the additional KDK component needs to be taken into account.

Signed-off-by: Adil Saeed Musthafa <quic_adilm@quicinc.com>
This commit is contained in:
Adil Saeed Musthafa 2023-03-01 11:21:38 -08:00 committed by Jouni Malinen
parent 23ddb3ffee
commit 0660f31ba0
3 changed files with 31 additions and 1 deletions

View file

@ -179,12 +179,21 @@ static int try_pmk(struct wlantest *wt, struct wlantest_bss *bss,
struct wpa_ptk ptk; struct wpa_ptk ptk;
const u8 *sa, *aa; const u8 *sa, *aa;
bool mlo; bool mlo;
size_t kdk_len;
mlo = !is_zero_ether_addr(sta->mld_mac_addr) && mlo = !is_zero_ether_addr(sta->mld_mac_addr) &&
!is_zero_ether_addr(bss->mld_mac_addr); !is_zero_ether_addr(bss->mld_mac_addr);
sa = mlo ? sta->mld_mac_addr : sta->addr; sa = mlo ? sta->mld_mac_addr : sta->addr;
aa = mlo ? bss->mld_mac_addr : bss->bssid; aa = mlo ? bss->mld_mac_addr : bss->bssid;
if (ieee802_11_rsnx_capab_len(bss->rsnxe, bss->rsnxe_len,
WLAN_RSNX_CAPAB_SECURE_LTF) &&
ieee802_11_rsnx_capab_len(sta->rsnxe, sta->rsnxe_len,
WLAN_RSNX_CAPAB_SECURE_LTF))
kdk_len = WPA_KDK_MAX_LEN;
else
kdk_len = 0;
if (wpa_key_mgmt_ft(sta->key_mgmt)) { if (wpa_key_mgmt_ft(sta->key_mgmt)) {
u8 ptk_name[WPA_PMK_NAME_LEN]; u8 ptk_name[WPA_PMK_NAME_LEN];
int use_sha384 = wpa_key_mgmt_sha384(sta->key_mgmt); int use_sha384 = wpa_key_mgmt_sha384(sta->key_mgmt);
@ -217,7 +226,7 @@ static int try_pmk(struct wlantest *wt, struct wlantest_bss *bss,
"Pairwise key expansion", "Pairwise key expansion",
aa, sa, sta->anonce, aa, sa, sta->anonce,
sta->snonce, &ptk, sta->key_mgmt, sta->snonce, &ptk, sta->key_mgmt,
sta->pairwise_cipher, NULL, 0, 0) < 0 || sta->pairwise_cipher, NULL, 0, kdk_len) < 0 ||
check_mic(sta, ptk.kck, ptk.kck_len, ver, data, len) < 0) { check_mic(sta, ptk.kck, ptk.kck_len, ver, data, len) < 0) {
return -1; return -1;
} }

View file

@ -346,6 +346,13 @@ static void rx_mgmt_beacon(struct wlantest *wt, const u8 *data, size_t len)
return; return;
} }
if (elems.rsnxe) {
os_memcpy(bss->rsnxe, elems.rsnxe, elems.rsnxe_len);
bss->rsnxe_len = elems.rsnxe_len;
} else {
bss->rsnxe_len = 0;
}
if (!bss->proberesp_seen) if (!bss->proberesp_seen)
bss_update(wt, bss, &elems, 1); bss_update(wt, bss, &elems, 1);
@ -920,6 +927,11 @@ static void rx_mgmt_assoc_req(struct wlantest *wt, const u8 *data, size_t len)
return; return;
} }
if (elems.rsnxe) {
os_memcpy(sta->rsnxe, elems.rsnxe, elems.rsnxe_len);
sta->rsnxe_len = elems.rsnxe_len;
}
sta->assocreq_capab_info = le_to_host16(mgmt->u.assoc_req.capab_info); sta->assocreq_capab_info = le_to_host16(mgmt->u.assoc_req.capab_info);
sta->assocreq_listen_int = sta->assocreq_listen_int =
le_to_host16(mgmt->u.assoc_req.listen_interval); le_to_host16(mgmt->u.assoc_req.listen_interval);
@ -1162,6 +1174,11 @@ static void rx_mgmt_reassoc_req(struct wlantest *wt, const u8 *data,
return; return;
} }
if (elems.rsnxe) {
os_memcpy(sta->rsnxe, elems.rsnxe, elems.rsnxe_len);
sta->rsnxe_len = elems.rsnxe_len;
}
sta->assocreq_capab_info = sta->assocreq_capab_info =
le_to_host16(mgmt->u.reassoc_req.capab_info); le_to_host16(mgmt->u.reassoc_req.capab_info);
sta->assocreq_listen_int = sta->assocreq_listen_int =

View file

@ -66,6 +66,8 @@ struct wlantest_sta {
bool ft_over_ds; bool ft_over_ds;
u16 aid; u16 aid;
u8 rsnie[257]; /* WPA/RSN IE */ u8 rsnie[257]; /* WPA/RSN IE */
u8 rsnxe[254]; /* RSNXE data */
size_t rsnxe_len;
u8 osenie[257]; /* OSEN IE */ u8 osenie[257]; /* OSEN IE */
int proto; int proto;
int pairwise_cipher; int pairwise_cipher;
@ -151,6 +153,8 @@ struct wlantest_bss {
int parse_error_reported; int parse_error_reported;
u8 wpaie[257]; u8 wpaie[257];
u8 rsnie[257]; u8 rsnie[257];
u8 rsnxe[254]; /* RSNXE data */
size_t rsnxe_len;
u8 osenie[257]; u8 osenie[257];
int proto; int proto;
int pairwise_cipher; int pairwise_cipher;