Skip to contentSkip to conversation

ft: check authenticator_ie from ft_ds_info, not handshake

PATCH In review James Prestwood 2 participants 6 messages Sep 28, 2021

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH v3 1/5 ft: check authenticator_ie from ft_ds_info, not handshake

The handshake contains the current BSS's RSNE/WPA which may differ from the FT-over-DS target. When verifying the target BSS's RSNE/WPA IE needs to be checked, not the current BSS.

---
 src/ft.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
src/ft.c +6 -4
index fecb4c0e..7a4b16f3 100644
@@ -354,6 +354,7 @@ static bool ft_verify_rsne(const uint8_t *rsne, const uint8_t *pmk_r0_name,
 }
 
 static int ft_parse_ies(struct handshake_state *hs,
+			const uint8_t *authenticator_ie,
 			const uint8_t *ies, size_t ies_len,
 			const uint8_t **mde_out,
 			const uint8_t **fte_out)
@@ -394,8 +395,7 @@ static int ft_parse_ies(struct handshake_state *hs,
 	is_rsn = hs->supplicant_ie != NULL;
 
 	if (is_rsn) {
-		if (!ft_verify_rsne(rsne, hs->pmk_r0_name,
-					hs->authenticator_ie))
+		if (!ft_verify_rsne(rsne, hs->pmk_r0_name, authenticator_ie))
 			goto ft_error;
 	} else if (rsne)
 		goto ft_error;
@@ -485,7 +485,8 @@ bool ft_over_ds_parse_action_ies(struct ft_ds_info *info,
 	const uint8_t *fte = NULL;
 	bool is_rsn = hs->supplicant_ie != NULL;
 
-	if (ft_parse_ies(hs, ies, ies_len, &mde, &fte) < 0)
+	if (ft_parse_ies(hs, info->authenticator_ie, ies, ies_len,
+				&mde, &fte) < 0)
 		return false;
 
 	if (!mde_equal(info->mde, mde))
@@ -516,7 +517,8 @@ static int ft_process_ies(struct handshake_state *hs, const uint8_t *ies,
 	if (!ies)
 		goto ft_error;
 
-	if (ft_parse_ies(hs, ies, ies_len, &mde, &fte) < 0)
+	if (ft_parse_ies(hs, hs->authenticator_ie, ies, ies_len,
+				&mde, &fte) < 0)
 		goto ft_error;
 
 	if (!mde_equal(hs->mde, mde))
Signature · 1 line
2.31.1
author
#1 lore raw

PATCH v3 2/5 eapol: include OCI in GTK 2/2

---
 src/eapol.c | 24 +++++++++++++++++++++++-
 src/eapol.h |  2 ++
 2 files changed, 25 insertions(+), 1 deletion(-)
src/eapol.c +23 -1
index 3127e066..393b85a1 100644
@@ -762,6 +762,8 @@ struct eapol_key *eapol_create_gtk_2_of_2(
 				enum eapol_protocol_version protocol,
 				enum eapol_key_descriptor_version version,
 				uint64_t key_replay_counter,
+				size_t extra_len,
+				const uint8_t *extra_data,
 				bool is_wpa, uint8_t wpa_key_id, size_t mic_len)
 {
 	uint8_t snonce[32];
@@ -770,7 +772,8 @@ struct eapol_key *eapol_create_gtk_2_of_2(
 	memset(snonce, 0, sizeof(snonce));
 	step2 = eapol_create_common(protocol, version, true,
 					key_replay_counter, snonce,
-					0, NULL, 0, is_wpa, mic_len);
+					extra_len, extra_data, 0, is_wpa,
+					mic_len);
 
 	if (!step2)
 		return step2;
@@ -2010,6 +2013,8 @@ static void eapol_handle_gtk_1_of_2(struct eapol_sm *sm,
 	uint16_t igtk_key_index;
 	const uint8_t *oci = NULL;
 	size_t oci_len;
+	uint8_t oci_out[9];
+
 
 	l_debug("ifindex=%u", hs->ifindex);
 
@@ -2068,6 +2073,22 @@ static void eapol_handle_gtk_1_of_2(struct eapol_sm *sm,
 	} else
 		igtk = NULL;
 
+	/*
+	 * IEEE 802.11-2020 Section 12.7.7.3
+	 * "Key Data = OCI KDE when dot11RSNAOperatingChannelValidationActivated
+	 *  on the [Supplicant]"
+	 *
+	 * Note: The spec reads "Authenticator" but this is incorrect and
+	 * appears to be a copy-paste from a previous section. Above it has been
+	 * changed to Supplicant.
+	 */
+	if (sm->handshake->supplicant_ocvc && sm->handshake->chandef) {
+		oci_out[0] = IE_TYPE_VENDOR_SPECIFIC;
+		oci_out[1] = 4 + 3;
+		l_put_be32(HANDSHAKE_KDE_OCI, oci_out + 2);
+		oci_from_chandef(sm->handshake->chandef, oci_out + 6);
+	}
+
 	/*
 	 * 802.11-2016, Section 12.7.7.2:
 	 * "
@@ -2089,6 +2110,7 @@ static void eapol_handle_gtk_1_of_2(struct eapol_sm *sm,
 	step2 = eapol_create_gtk_2_of_2(sm->protocol_version,
 					ek->key_descriptor_version,
 					sm->replay_counter,
+					oci_out[1] + 2, oci_out,
 					hs->wpa_ie, ek->wpa_key_id,
 					sm->mic_len);
 
src/eapol.h +2 -0
index a948c018..53ae6e8f 100644
@@ -95,6 +95,8 @@ struct eapol_key *eapol_create_gtk_2_of_2(
 				enum eapol_protocol_version protocol,
 				enum eapol_key_descriptor_version version,
 				uint64_t key_replay_counter,
+				size_t extra_len,
+				const uint8_t *extra_data,
 				bool is_wpa, uint8_t wpa_key_id,
 				size_t mic_len);
 
Signature · 1 line
2.31.1
author
#2 lore raw

PATCH v3 3/5 unit: update test-eapol with GTK API change

In reply to James Prestwood
---
 unit/test-eapol.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
unit/test-eapol.c +3 -2
index 470e0e9f..e1b6c96e 100644
@@ -1940,6 +1940,7 @@ static void eapol_wpa2_handshake_test(const void *data)
 	frame = eapol_create_gtk_2_of_2(EAPOL_PROTOCOL_VERSION_2004,
 				EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_SHA1_AES,
 				eapol_key_test_12.key_replay_counter,
+				0, NULL,
 				false, 0, 16);
 	assert(frame);
 	assert(eapol_calculate_mic(IE_RSN_AKM_SUITE_PSK, ptk, frame,
@@ -2061,8 +2062,8 @@ static void eapol_wpa_handshake_test(const void *data)
 
 	frame = eapol_create_gtk_2_of_2(EAPOL_PROTOCOL_VERSION_2004,
 				EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_MD5_ARC4,
-				eapol_key_test_18.key_replay_counter, true,
-				gtk_step1->wpa_key_id, 16);
+				eapol_key_test_18.key_replay_counter, 0, NULL,
+				true, gtk_step1->wpa_key_id, 16);
 	assert(frame);
 	assert(eapol_calculate_mic(IE_RSN_AKM_SUITE_PSK, ptk, frame,
 					mic, 16));
Signature · 1 line
2.31.1
author
#3 lore raw

PATCH v3 4/5 eapol: don't enforce PMKID on 1/4 if require_handshake is false

In reply to James Prestwood

FT/FILS handle their own PMK derivation but rekeys still require using the 4-way handshake. There is some ambiguity in the spec whether or not the PMKID needs to be included in message 1/4 and it appears that when rekeying after FT/FILS hostapd does not include a PMKID.

---
 src/eapol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/eapol.c +2 -1
index 393b85a1..3c9581bc 100644
@@ -1147,7 +1147,8 @@ static void eapol_handle_ptk_1_of_4(struct eapol_sm *sm,
 	 * send no PMKID KDE.
 	 */
 	if (!sm->eap_exchanged && !sm->handshake->wpa_ie &&
-			rsn_info.num_pmkids) {
+			rsn_info.num_pmkids &&
+			sm->require_handshake) {
 		bool found = false;
 		int i;
 
Signature · 1 line
2.31.1
author
#4 lore raw

PATCH v3 5/5 eapol: netdev: allow rekeys using FT-FILS

In reply to James Prestwood

Rekeying was overlooked when implementing FT-FILS and there were many places where the AKM was never checked and the rekey was failing.

---
 src/eapol.c  | 17 ++++++++++++-----
 src/netdev.c |  5 +----
 2 files changed, 13 insertions(+), 9 deletions(-)
src/eapol.c +12 -5
index 3c9581bc..09883645 100644
@@ -231,6 +231,11 @@ static size_t eapol_get_mic_length(enum ie_rsn_akm_suite akm, size_t pmk_len)
 			l_error("Invalid PMK length of %zu for OWE", pmk_len);
 			return 0;
 		}
+	case IE_RSN_AKM_SUITE_FILS_SHA256:
+	case IE_RSN_AKM_SUITE_FILS_SHA384:
+	case IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA256:
+	case IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA384:
+		return 0;
 	default:
 		return 16;
 	}
@@ -254,6 +259,8 @@ uint8_t *eapol_decrypt_key_data(enum ie_rsn_akm_suite akm, const uint8_t *kek,
 		switch (akm) {
 		case IE_RSN_AKM_SUITE_FILS_SHA256:
 		case IE_RSN_AKM_SUITE_FILS_SHA384:
+		case IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA256:
+		case IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA384:
 			if (key_data_len < 16)
 				return NULL;
 
@@ -329,13 +336,16 @@ uint8_t *eapol_decrypt_key_data(enum ie_rsn_akm_suite akm, const uint8_t *kek,
 			break;
 		case IE_RSN_AKM_SUITE_FILS_SHA256:
 		case IE_RSN_AKM_SUITE_FILS_SHA384:
+		case IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA256:
+		case IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA384:
 		{
 			struct iovec ad[1];
 
 			ad[0].iov_base = (void *)frame;
 			ad[0].iov_len = key_data - (const uint8_t *)frame;
 
-			if (akm == IE_RSN_AKM_SUITE_FILS_SHA256)
+			if (akm == IE_RSN_AKM_SUITE_FILS_SHA256 || akm ==
+					IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA256)
 				kek_len = 32;
 			else
 				kek_len = 64;
@@ -1220,10 +1230,7 @@ static void eapol_handle_ptk_1_of_4(struct eapol_sm *sm,
 			goto error_unspecified;
 	}
 
-	if (sm->handshake->akm_suite &
-			(IE_RSN_AKM_SUITE_FT_OVER_8021X |
-			 IE_RSN_AKM_SUITE_FT_USING_PSK |
-			 IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256)) {
+	if (IE_AKM_IS_FT(sm->handshake->akm_suite)) {
 		/*
 		 * Rebuild the RSNE to include the PMKR1Name and append
 		 * MDE + FTE.
src/netdev.c +1 -4
index de6af614..c6867ce3 100644
@@ -2565,10 +2565,7 @@ process_resp_ies:
 			netdev->owe_sm = NULL;
 		}
 
-		/* FILS handles its own FT key derivation */
-		if (fte && !(netdev->handshake->akm_suite &
-				(IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA256 |
-				IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA384))) {
+		if (fte) {
 			uint32_t kck_len =
 				handshake_state_get_kck_len(netdev->handshake);
 			/*
Signature · 1 line
2.31.1
#5 lore raw
In reply to James Prestwood

Hi James,

Quoted 7 lines · James Prestwood

The handshake contains the current BSS's RSNE/WPA which may differ from the FT-over-DS target. When verifying the target BSS's RSNE/WPA IE needs to be checked, not the current BSS.

---
  src/ft.c | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)

All applied, thanks.

Regards,
-Denis