[PATCH 5/7] wpa_supplicant: Retry 802.1X authentication with another group

Andrei Otcheretianski andrei.otcheretianski at intel.com
Tue Nov 24 06:30:26 PST 2026


From: Ilan Peer <ilan.peer at intel.com>

When the first 802.1X authentication over authentication frame is
rejected by the AP status FINITE_CYCLIC_GROUP_NOT_SUPPORTED, and
there is another group configured that is supported by the AP,
retry the connection with the new group. This applies only to non-PQC
AKMs, as with PQC AKMs the group is defined by the PQC security profile.

Verify that the Supported Groups element in the last Authentication
frame (which is MIC protected) does not list any of the more
preferred groups that were skipped, and fail the authentication
otherwise.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
 wpa_supplicant/config.h            |   5 +-
 wpa_supplicant/sme.c               | 134 ++++++++++++++++++++++++++---
 wpa_supplicant/wpa_supplicant.conf |   3 +-
 wpa_supplicant/wpa_supplicant_i.h  |   3 +
 4 files changed, 132 insertions(+), 13 deletions(-)

diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index d45bb9b444..f91fac1d2e 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -1839,8 +1839,9 @@ struct wpa_config {
 	 * authentication utilizing Authentication frames. This is a
 	 * zero-terminated array.
 	 *
-	 * The first group is used. If not set, group 19 is used. The
-	 * per-network parameter takes precedence. Not used with PQC AKMs.
+	 * The first group is used, and the next one the AP supports when the AP
+	 * rejects it. If not set, group 19 is used. The per-network parameter
+	 * takes precedence. Not used with PQC AKMs.
 	 */
 	int *ieee8021x_auth_groups;
 #endif /* CONFIG_IEEE8021X_AUTH */
diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c
index d7d4407c1b..517b752df5 100644
--- a/wpa_supplicant/sme.c
+++ b/wpa_supplicant/sme.c
@@ -184,8 +184,7 @@ static int sme_get_pmk_for_1x_auth(struct wpa_supplicant *wpa_s,
 #endif /* CONFIG_IEEE8021X_AUTH */
 
 
-#ifdef CONFIG_SAE
-
+#if defined(CONFIG_SAE) || defined(CONFIG_IEEE8021X_AUTH)
 static int index_within_array(const int *array, int idx)
 {
 	int i;
@@ -195,7 +194,10 @@ static int index_within_array(const int *array, int idx)
 	}
 	return 1;
 }
+#endif /* CONFIG_SAE || CONFIG_IEEE8021X_AUTH */
+
 
+#ifdef CONFIG_SAE
 
 static int sme_set_sae_group(struct wpa_supplicant *wpa_s, bool external)
 {
@@ -536,8 +538,10 @@ static void sme_802_1x_auth_data_free(struct wpa_supplicant *wpa_s)
 }
 
 
-static int sme_802_1x_dh_group(struct wpa_supplicant *wpa_s, bool external)
+static const int * sme_802_1x_groups(struct wpa_supplicant *wpa_s,
+				     bool external)
 {
+	static const int default_groups[] = { 19, 0 };
 	struct wpa_ssid *ssid = external ? wpa_s->sme.ext_auth_wpa_ssid :
 		wpa_s->current_ssid;
 	const int *groups = ssid && ssid->ieee8021x_auth_groups ?
@@ -545,9 +549,20 @@ static int sme_802_1x_dh_group(struct wpa_supplicant *wpa_s, bool external)
 		wpa_s->conf->ieee8021x_auth_groups;
 
 	if (groups && groups[0] > 0)
-		return groups[0];
+		return groups;
 
-	return 19;
+	return default_groups;
+}
+
+
+static int sme_802_1x_dh_group(struct wpa_supplicant *wpa_s, bool external)
+{
+	const int *groups = sme_802_1x_groups(wpa_s, external);
+
+	if (!index_within_array(groups, wpa_s->sme.auth_1x_group_index))
+		wpa_s->sme.auth_1x_group_index = 0;
+
+	return groups[wpa_s->sme.auth_1x_group_index];
 }
 
 
@@ -2866,6 +2881,9 @@ void sme_authenticate(struct wpa_supplicant *wpa_s,
 	wpa_s->sme.sae.send_confirm = 0;
 	wpa_s->sme.sae_group_index = 0;
 #endif /* CONFIG_SAE */
+#ifdef CONFIG_IEEE8021X_AUTH
+	wpa_s->sme.auth_1x_group_index = 0;
+#endif /* CONFIG_IEEE8021X_AUTH */
 
 	if (!radio_add_work(wpa_s, bss->freq, "sme-connect", 1,
 			    sme_auth_start_cb, cwork))
@@ -3337,6 +3355,7 @@ static int sme_external_auth_start_802_1x(struct wpa_supplicant *wpa_s,
 		wpa_s->sme.ext_rsnxe_len = ext_auth->rsnxe_data_len;
 	}
 
+	wpa_s->sme.auth_1x_group_index = 0;
 	if (sme_external_auth_send_802_1x(wpa_s, ssid, 1) < 0)
 		return -1;
 
@@ -4582,10 +4601,73 @@ static size_t wpas_get_kdk_len(struct wpa_supplicant *wpa_s)
 }
 
 
-static int sme_802_1x_derive_ptk_and_install(struct wpa_supplicant *wpa_s,
-					     const u8 *frame_body,
-					     size_t frame_body_len,
-					     bool external)
+static bool sme_supported_groups_includes(const struct ieee802_11_elems *elems,
+					  int group)
+{
+	size_t i;
+
+	for (i = 0; i + 1 < elems->supported_groups_len; i += 2) {
+		if (WPA_GET_LE16(&elems->supported_groups[i]) == group)
+			return true;
+	}
+
+	return false;
+}
+
+
+static bool sme_802_1x_next_group(struct wpa_supplicant *wpa_s,
+				  const struct auth_info *auth, bool external)
+{
+	const int *groups = sme_802_1x_groups(wpa_s, external);
+	struct ieee802_11_elems elems;
+	struct wpabuf *pdu;
+	int i;
+
+	if (sme_parse_802_1x_auth_frame(wpa_s, auth->ies, auth->ies_len,
+					&elems, &pdu) < 0)
+		return false;
+
+	wpabuf_free(pdu);
+
+	for (i = wpa_s->sme.auth_1x_group_index + 1; groups[i] > 0; i++) {
+		if (!elems.supported_groups ||
+		    sme_supported_groups_includes(&elems, groups[i])) {
+			wpa_s->sme.auth_1x_group_index = i;
+			return true;
+		}
+	}
+
+	return false;
+}
+
+
+static bool sme_802_1x_group_downgrade(struct wpa_supplicant *wpa_s,
+				       const struct ieee802_11_elems *elems,
+				       bool external)
+{
+	const int *groups = sme_802_1x_groups(wpa_s, external);
+	int i;
+
+	if (!wpa_s->sme.auth_1x_group_index)
+		return false;
+
+	if (!elems->supported_groups)
+		return true;
+
+	/* A skipped group means the rejection was likely forged */
+	for (i = 0; i < wpa_s->sme.auth_1x_group_index && groups[i] > 0; i++) {
+		if (sme_supported_groups_includes(elems, groups[i]))
+			return true;
+	}
+
+	return false;
+}
+
+
+static int sme_802_1x_derive_ptk_and_install(
+	struct wpa_supplicant *wpa_s, const u8 *frame_body,
+	size_t frame_body_len, const struct ieee802_11_elems *elems,
+	bool external)
 {
 	struct auth_802_1x_data *auth_1x = wpa_s->auth_1x;
 	const u8 *peer_addr = sme_get_peer_addr(wpa_s, external);
@@ -4688,6 +4770,13 @@ ptk_derived:
 		return -1;
 	}
 
+	if (sme_802_1x_group_downgrade(wpa_s, elems, external)) {
+		wpa_msg(wpa_s, MSG_INFO,
+			"IEEE 802.1X: Group downgrade detected");
+		forced_memzero(&ptk, sizeof(ptk));
+		return -1;
+	}
+
 	alg = wpa_cipher_to_alg(pairwise_cipher);
 	if (wpa_drv_set_key(wpa_s, -1, alg, peer_addr, 0, 1, zero, sizeof(zero),
 			    ptk.tk, ptk.tk_len, KEY_FLAG_PAIRWISE_RX_TX) < 0) {
@@ -4722,6 +4811,31 @@ static void sme_process_802_1x_auth_response(struct wpa_supplicant *wpa_s,
 		return;
 	}
 
+	if (auth->status_code ==
+	    WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED &&
+	    auth->auth_transaction == 2 && wpa_s->auth_1x->auth_trans == 1 &&
+	    wpa_s->auth_1x->derive_ptk &&
+	    !wpa_key_mgmt_pqc(sme_get_key_mgmt(wpa_s, external)) &&
+	    sme_802_1x_next_group(wpa_s, auth, external)) {
+		wpa_msg(wpa_s, MSG_INFO,
+			"IEEE 802.1X: Group %u not supported by the AP, retry with group %d",
+			wpa_s->auth_1x->dh_group,
+			sme_802_1x_dh_group(wpa_s, external));
+
+		if (!external) {
+			sme_send_authentication(wpa_s, wpa_s->current_bss,
+						wpa_s->current_ssid, 1);
+			return;
+		}
+
+		if (sme_external_auth_send_802_1x(wpa_s,
+						  wpa_s->sme.ext_auth_wpa_ssid,
+						  1) == 0)
+			return;
+
+		goto fail;
+	}
+
 	if (auth->status_code != WLAN_STATUS_SUCCESS &&
 	    auth->status_code != WLAN_STATUS_802_1_X_AUTH_SUCCESS) {
 		wpa_msg(wpa_s, MSG_INFO,
@@ -4904,7 +5018,7 @@ static void sme_process_802_1x_auth_response(struct wpa_supplicant *wpa_s,
 		if (wpa_s->auth_1x->derive_ptk &&
 		    sme_802_1x_derive_ptk_and_install(wpa_s, auth->frame_body,
 						      auth->frame_body_len,
-						      external) < 0)
+						      &elems, external) < 0)
 			goto fail;
 
 		wpa_msg(wpa_s, MSG_INFO,
diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf
index 4032f9c9da..eb4f41e85f 100644
--- a/wpa_supplicant/wpa_supplicant.conf
+++ b/wpa_supplicant/wpa_supplicant.conf
@@ -511,7 +511,8 @@ fast_reauth=1
 
 # Finite cyclic groups for IEEE 802.1X authentication utilizing Authentication
 # frames as a space separated list in order of preference. The first group is
-# used for the Diffie-Hellman Parameter element. The default is group 19.
+# used for the Diffie-Hellman Parameter element, and the next one the AP
+# supports when the AP rejects it. The default is group 19.
 # A network block parameter with the same name takes precedence.
 # Only the ECC groups 19, 20 and 21 are supported. Not used with PQC AKMs, for
 # which the PQC security profile defines the group.
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index a1d8029b67..b835029a52 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -1157,6 +1157,9 @@ struct wpa_supplicant {
 		u16 seq_num;
 		int *sae_rejected_groups;
 #endif /* CONFIG_SAE */
+#ifdef CONFIG_IEEE8021X_AUTH
+		int auth_1x_group_index;
+#endif /* CONFIG_IEEE8021X_AUTH */
 		u8 ext_auth_bssid[ETH_ALEN];
 		unsigned int ext_auth_freq;
 		struct wpa_ssid *ext_auth_wpa_ssid;
-- 
2.56.1




More information about the Hostap mailing list