Use helper functions to access RSNE/RSNXE from BSS entries

This is a step towards allowing the contents of RSNE/RSNXE to be
overridden.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
This commit is contained in:
Jouni Malinen 2023-10-11 12:50:05 +03:00 committed by Jouni Malinen
parent 341bcb2b5c
commit 5488e120d3
14 changed files with 63 additions and 40 deletions

View file

@ -1866,3 +1866,19 @@ out:
wpabuf_free(mlbuf);
return removed_links;
}
const u8 * wpa_bss_get_rsne(struct wpa_supplicant *wpa_s,
const struct wpa_bss *bss, struct wpa_ssid *ssid,
bool mlo)
{
return wpa_bss_get_ie(bss, WLAN_EID_RSN);
}
const u8 * wpa_bss_get_rsnxe(struct wpa_supplicant *wpa_s,
const struct wpa_bss *bss, struct wpa_ssid *ssid,
bool mlo)
{
return wpa_bss_get_ie(bss, WLAN_EID_RSNX);
}

View file

@ -226,4 +226,11 @@ int wpa_bss_parse_basic_ml_element(struct wpa_supplicant *wpa_s,
u16 wpa_bss_parse_reconf_ml_element(struct wpa_supplicant *wpa_s,
struct wpa_bss *bss);
const u8 * wpa_bss_get_rsne(struct wpa_supplicant *wpa_s,
const struct wpa_bss *bss, struct wpa_ssid *ssid,
bool mlo);
const u8 * wpa_bss_get_rsnxe(struct wpa_supplicant *wpa_s,
const struct wpa_bss *bss, struct wpa_ssid *ssid,
bool mlo);
#endif /* BSS_H */

View file

@ -3119,12 +3119,12 @@ static int wpa_supplicant_ctrl_iface_scan_result(
ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
if (ie)
pos = wpa_supplicant_ie_txt(pos, end, "WPA", ie, 2 + ie[1]);
ie2 = wpa_bss_get_ie(bss, WLAN_EID_RSN);
ie2 = wpa_bss_get_rsne(wpa_s, bss, NULL, false);
if (ie2) {
pos = wpa_supplicant_ie_txt(pos, end, mesh ? "RSN" : "WPA2",
ie2, 2 + ie2[1]);
}
rsnxe = wpa_bss_get_ie(bss, WLAN_EID_RSNX);
rsnxe = wpa_bss_get_rsnxe(wpa_s, bss, NULL, false);
if (ieee802_11_rsnx_capab(rsnxe, WLAN_RSNX_CAPAB_SAE_H2E)) {
ret = os_snprintf(pos, end - pos, "[SAE-H2E]");
if (os_snprintf_error(end - pos, ret))
@ -5444,12 +5444,12 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
if (ie)
pos = wpa_supplicant_ie_txt(pos, end, "WPA", ie,
2 + ie[1]);
ie2 = wpa_bss_get_ie(bss, WLAN_EID_RSN);
ie2 = wpa_bss_get_rsne(wpa_s, bss, NULL, false);
if (ie2)
pos = wpa_supplicant_ie_txt(pos, end,
mesh ? "RSN" : "WPA2", ie2,
2 + ie2[1]);
rsnxe = wpa_bss_get_ie(bss, WLAN_EID_RSNX);
rsnxe = wpa_bss_get_rsnxe(wpa_s, bss, NULL, false);
if (ieee802_11_rsnx_capab(rsnxe, WLAN_RSNX_CAPAB_SAE_H2E)) {
ret = os_snprintf(pos, end - pos, "[SAE-H2E]");
if (os_snprintf_error(end - pos, ret))

View file

@ -5635,7 +5635,7 @@ dbus_bool_t wpas_dbus_getter_bss_rsn(
return FALSE;
os_memset(&wpa_data, 0, sizeof(wpa_data));
ie = wpa_bss_get_ie(res, WLAN_EID_RSN);
ie = wpa_bss_get_rsne(args->wpa_s, res, NULL, false);
if (ie && wpa_parse_wpa_ie(ie, 2 + ie[1], &wpa_data) < 0) {
dbus_set_error_const(error, DBUS_ERROR_FAILED,
"failed to parse RSN IE");

View file

@ -4500,7 +4500,7 @@ int wpas_dpp_check_connect(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
if (!(ssid->key_mgmt & WPA_KEY_MGMT_DPP) || !bss)
return 0; /* Not using DPP AKM - continue */
rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
rsn = wpa_bss_get_rsne(wpa_s, bss, ssid, false);
if (rsn && wpa_parse_wpa_ie(rsn, 2 + rsn[1], &ied) == 0 &&
!(ied.key_mgmt & WPA_KEY_MGMT_DPP))
return 0; /* AP does not support DPP AKM - continue */

View file

@ -670,7 +670,7 @@ static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s,
(ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA));
#endif /* CONFIG_WEP */
rsn_ie = wpa_bss_get_ie(bss, WLAN_EID_RSN);
rsn_ie = wpa_bss_get_rsne(wpa_s, bss, ssid, false);
if (is_6ghz_bss && !rsn_ie) {
if (debug_print)
wpa_dbg(wpa_s, MSG_DEBUG,
@ -1143,7 +1143,7 @@ static void owe_trans_ssid(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
u8 ssid_len;
owe = wpa_bss_get_vendor_ie(bss, OWE_IE_VENDOR_TYPE);
if (!owe || !wpa_bss_get_ie(bss, WLAN_EID_RSN))
if (!owe || !wpa_bss_get_rsne(wpa_s, bss, NULL, false))
return;
pos = owe + 6;
@ -1247,7 +1247,7 @@ static bool sae_pk_acceptable_bss_with_pk(struct wpa_supplicant *wpa_s,
if (bss == orig_bss)
continue;
ie = wpa_bss_get_ie(bss, WLAN_EID_RSNX);
ie = wpa_bss_get_rsnxe(wpa_s, bss, ssid, false);
if (!(ieee802_11_rsnx_capab(ie, WLAN_RSNX_CAPAB_SAE_PK)))
continue;
@ -1286,7 +1286,7 @@ static bool wpa_scan_res_ok(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
wpa = ie && ie[1];
ie = wpa_bss_get_ie(bss, WLAN_EID_RSN);
ie = wpa_bss_get_rsne(wpa_s, bss, ssid, false);
wpa |= ie && ie[1];
if (ie && wpa_parse_wpa_ie_rsn(ie, 2 + ie[1], &data) == 0 &&
(data.key_mgmt & WPA_KEY_MGMT_OSEN))
@ -1295,7 +1295,7 @@ static bool wpa_scan_res_ok(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
osen = ie != NULL;
#ifdef CONFIG_SAE
ie = wpa_bss_get_ie(bss, WLAN_EID_RSNX);
ie = wpa_bss_get_rsnxe(wpa_s, bss, ssid, false);
if (ie && ie[1] >= 1)
rsnxe_capa = ie[2];
#endif /* CONFIG_SAE */
@ -1650,7 +1650,7 @@ struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
wpa_ie_len = ie ? ie[1] : 0;
ie = wpa_bss_get_ie(bss, WLAN_EID_RSN);
ie = wpa_bss_get_rsne(wpa_s, bss, NULL, false);
rsn_ie_len = ie ? ie[1] : 0;
ie = wpa_bss_get_vendor_ie(bss, OSEN_IE_VENDOR_TYPE);
@ -2117,7 +2117,7 @@ static void wpa_supplicant_rsn_preauth_scan_results(
if (ssid == NULL)
continue;
rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
rsn = wpa_bss_get_rsne(wpa_s, bss, NULL, false);
if (rsn == NULL)
continue;
@ -3267,7 +3267,7 @@ static int wpa_supplicant_use_own_rsne_params(struct wpa_supplicant *wpa_s,
if (wpa_s->wpa_proto & (WPA_PROTO_RSN | WPA_PROTO_OSEN)) {
const u8 *bss_rsn;
bss_rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
bss_rsn = wpa_bss_get_rsne(wpa_s, bss, ssid, false);
if (bss_rsn) {
p = bss_rsn;
len = 2 + bss_rsn[1];
@ -3721,8 +3721,8 @@ static int wpa_supplicant_assoc_update_ie(struct wpa_supplicant *wpa_s)
bss_wpa = wpa_bss_get_vendor_ie(wpa_s->current_bss,
WPA_IE_VENDOR_TYPE);
bss_rsn = wpa_bss_get_ie(wpa_s->current_bss, WLAN_EID_RSN);
bss_rsnx = wpa_bss_get_ie(wpa_s->current_bss, WLAN_EID_RSNX);
bss_rsn = wpa_bss_get_rsne(wpa_s, wpa_s->current_bss, NULL, false);
bss_rsnx = wpa_bss_get_rsnxe(wpa_s, wpa_s->current_bss, NULL, false);
if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, bss_wpa,
bss_wpa ? 2 + bss_wpa[1] : 0) ||
@ -4110,8 +4110,8 @@ static int wpa_sm_set_ml_info(struct wpa_supplicant *wpa_s)
return -1;
}
bss_rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
bss_rsnx = wpa_bss_get_ie(bss, WLAN_EID_RSNX);
bss_rsn = wpa_bss_get_rsne(wpa_s, bss, NULL, true);
bss_rsnx = wpa_bss_get_rsnxe(wpa_s, bss, NULL, true);
wpa_mlo.links[i].ap_rsne = bss_rsn ? (u8 *) bss_rsn : NULL;
wpa_mlo.links[i].ap_rsne_len = bss_rsn ? 2 + bss_rsn[1] : 0;

View file

@ -1087,7 +1087,7 @@ void hs20_osu_icon_fetch(struct wpa_supplicant *wpa_s)
prov_anqp = bss->anqp->hs20_osu_providers_list;
if (prov_anqp == NULL)
continue;
ie = wpa_bss_get_ie(bss, WLAN_EID_RSN);
ie = wpa_bss_get_rsne(wpa_s, bss, NULL, false);
if (ie && wpa_parse_wpa_ie(ie, 2 + ie[1], &data) == 0 &&
(data.key_mgmt & WPA_KEY_MGMT_OSEN)) {
osu_ssid2 = bss->ssid;

View file

@ -1726,7 +1726,7 @@ int interworking_connect(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
" for connection",
MAC2STR(bss->bssid));
if (!wpa_bss_get_ie(bss, WLAN_EID_RSN)) {
if (!wpa_bss_get_rsne(wpa_s, bss, NULL, false)) {
/*
* We currently support only HS 2.0 networks and those are
* required to use WPA2-Enterprise.
@ -2459,7 +2459,7 @@ static struct wpa_bss * pick_best_roaming_partner(struct wpa_supplicant *wpa_s,
cred2 = interworking_credentials_available(wpa_s, bss, NULL);
if (!cred2)
continue;
if (!wpa_bss_get_ie(bss, WLAN_EID_RSN))
if (!wpa_bss_get_rsne(wpa_s, bss, NULL, false))
continue;
prio = roaming_prio(wpa_s, cred2, bss);
wpa_printf(MSG_DEBUG, "Interworking: roaming_prio=%u for BSS "
@ -2511,7 +2511,7 @@ static void interworking_select_network(struct wpa_supplicant *wpa_s)
if (!cred)
continue;
if (!wpa_bss_get_ie(bss, WLAN_EID_RSN)) {
if (!wpa_bss_get_rsne(wpa_s, bss, NULL, false)) {
/*
* We currently support only HS 2.0 networks and those
* are required to use WPA2-Enterprise.

View file

@ -115,7 +115,7 @@ void wpas_mbo_check_pmf(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
return;
if (oce && oce[1] >= 1 && (oce[2] & OCE_IS_STA_CFON))
return; /* STA-CFON is not required to enable PMF */
rsne = wpa_bss_get_ie(bss, WLAN_EID_RSN);
rsne = wpa_bss_get_rsne(wpa_s, bss, ssid, false);
if (!rsne || wpa_parse_wpa_ie(rsne, 2 + rsne[1], &ie) < 0)
return; /* AP is not using RSN */

View file

@ -174,7 +174,7 @@ static int wpas_pasn_get_params_from_bss(struct wpa_supplicant *wpa_s,
}
}
rsne = wpa_bss_get_ie(bss, WLAN_EID_RSN);
rsne = wpa_bss_get_rsne(wpa_s, bss, NULL, false);
if (!rsne) {
wpa_printf(MSG_DEBUG, "PASN: BSS without RSNE");
return -1;
@ -186,7 +186,7 @@ static int wpas_pasn_get_params_from_bss(struct wpa_supplicant *wpa_s,
return -1;
}
rsnxe = wpa_bss_get_ie(bss, WLAN_EID_RSNX);
rsnxe = wpa_bss_get_rsnxe(wpa_s, bss, NULL, false);
ssid_str_len = bss->ssid_len;
ssid_str = bss->ssid;
@ -480,7 +480,7 @@ static struct wpa_bss * wpas_pasn_allowed(struct wpa_supplicant *wpa_s,
return NULL;
}
rsne = wpa_bss_get_ie(bss, WLAN_EID_RSN);
rsne = wpa_bss_get_rsne(wpa_s, bss, NULL, false);
if (!rsne) {
wpa_printf(MSG_DEBUG, "PASN: BSS without RSNE");
return NULL;
@ -544,13 +544,13 @@ static void wpas_pasn_auth_start_cb(struct wpa_radio_work *work, int deinit)
goto fail;
}
rsne = wpa_bss_get_ie(bss, WLAN_EID_RSN);
rsne = wpa_bss_get_rsne(wpa_s, bss, NULL, false);
if (!rsne) {
wpa_printf(MSG_DEBUG, "PASN: BSS without RSNE");
goto fail;
}
rsnxe = wpa_bss_get_ie(bss, WLAN_EID_RSNX);
rsnxe = wpa_bss_get_rsnxe(wpa_s, bss, NULL, false);
derive_kdk = (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_SEC_LTF_STA) &&
ieee802_11_rsnx_capab(rsnxe,

View file

@ -190,7 +190,7 @@ static struct wpabuf * sme_auth_build_sae_commit(struct wpa_supplicant *wpa_s,
if (bss) {
const u8 *rsnxe;
rsnxe = wpa_bss_get_ie(bss, WLAN_EID_RSNX);
rsnxe = wpa_bss_get_rsnxe(wpa_s, bss, ssid, false);
if (rsnxe && rsnxe[1] >= 1)
rsnxe_capa = rsnxe[2];
}
@ -643,7 +643,7 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s,
const u8 *rsn;
struct wpa_ie_data ied;
rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
rsn = wpa_bss_get_rsne(wpa_s, bss, ssid, false);
if (!rsn) {
wpa_dbg(wpa_s, MSG_DEBUG,
"SAE enabled, but target BSS does not advertise RSN");
@ -683,7 +683,7 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s,
#endif /* CONFIG_WEP */
if ((wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE) ||
wpa_bss_get_ie(bss, WLAN_EID_RSN)) &&
wpa_bss_get_rsne(wpa_s, bss, ssid, false)) &&
wpa_key_mgmt_wpa(ssid->key_mgmt)) {
int try_opportunistic;
const u8 *cache_id = NULL;
@ -807,7 +807,7 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s,
wpa_dbg(wpa_s, MSG_DEBUG, "SME: FT mobility domain %02x%02x",
md[0], md[1]);
omit_rsnxe = !wpa_bss_get_ie(bss, WLAN_EID_RSNX);
omit_rsnxe = !wpa_bss_get_rsnxe(wpa_s, bss, ssid, false);
if (wpa_s->sme.assoc_req_ie_len + 5 <
sizeof(wpa_s->sme.assoc_req_ie)) {
struct rsn_mdie *mdie;
@ -836,7 +836,7 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s,
wpa_s->sme.mfp = wpas_get_ssid_pmf(wpa_s, ssid);
if (wpa_s->sme.mfp != NO_MGMT_FRAME_PROTECTION) {
const u8 *rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
const u8 *rsn = wpa_bss_get_rsne(wpa_s, bss, ssid, false);
struct wpa_ie_data _ie;
if (rsn && wpa_parse_wpa_ie(rsn, 2 + rsn[1], &_ie) == 0 &&
_ie.capabilities &

View file

@ -1700,8 +1700,8 @@ int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
if (bss) {
bss_wpa = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
bss_rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
bss_rsnx = wpa_bss_get_ie(bss, WLAN_EID_RSNX);
bss_rsn = wpa_bss_get_rsne(wpa_s, bss, ssid, false);
bss_rsnx = wpa_bss_get_rsnxe(wpa_s, bss, ssid, false);
bss_osen = wpa_bss_get_vendor_ie(bss, OSEN_IE_VENDOR_TYPE);
} else {
bss_wpa = bss_rsn = bss_rsnx = bss_osen = NULL;
@ -3456,7 +3456,7 @@ static u8 * wpas_populate_assoc_ies(
}
if (bss && (wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE) ||
wpa_bss_get_ie(bss, WLAN_EID_RSN)) &&
wpa_bss_get_rsne(wpa_s, bss, ssid, false)) &&
wpa_key_mgmt_wpa(ssid->key_mgmt)) {
int try_opportunistic;
const u8 *cache_id = NULL;
@ -4497,7 +4497,7 @@ static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit)
params.mgmt_frame_protection = wpas_get_ssid_pmf(wpa_s, ssid);
if (params.mgmt_frame_protection != NO_MGMT_FRAME_PROTECTION && bss) {
const u8 *rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
const u8 *rsn = wpa_bss_get_rsne(wpa_s, bss, ssid, false);
struct wpa_ie_data ie;
if (!wpas_driver_bss_selection(wpa_s) && rsn &&
wpa_parse_wpa_ie(rsn, 2 + rsn[1], &ie) == 0 &&

View file

@ -425,11 +425,11 @@ static int wpa_get_beacon_ie(struct wpa_supplicant *wpa_s)
if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0))
ret = -1;
ie = wpa_bss_get_ie(curr, WLAN_EID_RSN);
ie = wpa_bss_get_rsne(wpa_s, curr, ssid, false);
if (wpa_sm_set_ap_rsn_ie(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0))
ret = -1;
ie = wpa_bss_get_ie(curr, WLAN_EID_RSNX);
ie = wpa_bss_get_rsnxe(wpa_s, curr, ssid, false);
if (wpa_sm_set_ap_rsnxe(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0))
ret = -1;
} else {

View file

@ -226,7 +226,7 @@ static void wpas_wps_security_workaround(struct wpa_supplicant *wpa_s,
wpa_printf(MSG_DEBUG, "WPS: AP found from BSS table");
ie = wpa_bss_get_ie(bss, WLAN_EID_RSN);
ie = wpa_bss_get_rsne(wpa_s, bss, ssid, false);
if (ie && wpa_parse_wpa_ie(ie, 2 + ie[1], &adv) == 0) {
wpa2 = 1;
if (adv.pairwise_cipher & WPA_CIPHER_CCMP)