@@ -2714,7 +2714,21 @@ u8 * wpa_sm_write_assoc_resp_ies(struct wpa_state_machine *sm, u8 *pos,
anonce = NULL;
snonce = NULL;
}
- rsnxe_used = (auth_alg == WLAN_AUTH_FT) &&
+ if (omit_rsnxe) {
+ rsnxe_len = 0;
+ } else {
+ res = wpa_write_rsnxe(&sm->wpa_auth->conf, rsnxe,
+ sizeof(rsnxe_buf));
+ if (res < 0) {
+ os_free(subelem);
+ return NULL;
+ }
+ rsnxe_len = res;
+ }
+ /* RSNXE Used tells the STA that the MIC covers an RSNXE. Without one
+ * (e.g., FT-EAP or FT-PSK with sae_pwe set, but no SAE), the STA would
+ * reject the response for an RSNXE the AP does not advertise. */
+ rsnxe_used = (auth_alg == WLAN_AUTH_FT) && rsnxe_len &&
(conf->sae_pwe == SAE_PWE_HASH_TO_ELEMENT ||
conf->sae_pwe == SAE_PWE_BOTH);
#ifdef CONFIG_TESTING_OPTIONS
@@ -2782,17 +2796,6 @@ u8 * wpa_sm_write_assoc_resp_ies(struct wpa_state_machine *sm, u8 *pos,
if (ric_start == pos)
ric_start = NULL;
- if (omit_rsnxe) {
- rsnxe_len = 0;
- } else {
- res = wpa_write_rsnxe(&sm->wpa_auth->conf, rsnxe,
- sizeof(rsnxe_buf));
- if (res < 0) {
- pos = NULL;
- goto fail;
- }
- rsnxe_len = res;
- }
#ifdef CONFIG_TESTING_OPTIONS
if (auth_alg == WLAN_AUTH_FT &&
sm->wpa_auth->conf.rsnxe_override_ft_set) {