Skip to contentSkip to conversation

handshake: add force_default_owe_group flag

PATCH Superseded James Prestwood 1 participant 4 messages Aug 8, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 handshake: add force_default_owe_group flag

Indicates the OWE SM should only use the default group

---
 src/handshake.h | 1 +
 1 file changed, 1 insertion(+)
src/handshake.h +1 -0
index 7f597b06..f2321634 100644
@@ -137,6 +137,7 @@ struct handshake_state {
 	bool authenticator_ocvc : 1;
 	bool supplicant_ocvc : 1;
 	bool ext_key_id_capable : 1;
+	bool force_default_owe_group : 1;
 	uint8_t ssid[32];
 	size_t ssid_len;
 	char *passphrase;
Signature · 1 line
2.34.3
#1 lore raw

PATCH 2/4 owe: allow OWE to force group 19

Similarly with SAE, some AP's either don't do group negotiations right, or specifically with OWE, incorrectly derive the PTK unless group 19 is used.

---
 src/owe.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
src/owe.c +19 -0
index eed3e266..c4808cf4 100644
@@ -41,10 +41,26 @@ struct owe_sm {
 	uint8_t retry;
 	uint16_t group;
 	const unsigned int *ecc_groups;
+
+	bool force_default_group : 1;
 };
 
 static bool owe_reset(struct owe_sm *owe)
 {
+	if (owe->force_default_group) {
+		if (owe->retry != 0) {
+			l_warn("Forced default OWE group but was rejected!");
+			return false;
+		}
+
+		l_debug("Forcing default OWE group 19");
+
+		owe->retry++;
+		owe->group = 19;
+
+		goto get_curve;
+	}
+
 	/*
 	 * Reset OWE with a different curve group and generate a new key pair
 	 */
@@ -52,6 +68,8 @@ static bool owe_reset(struct owe_sm *owe)
 		return false;
 
 	owe->group = owe->ecc_groups[owe->retry];
+
+get_curve:
 	owe->curve = l_ecc_curve_from_ike_group(owe->group);
 
 	if (owe->private)
@@ -222,6 +240,7 @@ struct owe_sm *owe_sm_new(struct handshake_state *hs)
 
 	owe->hs = hs;
 	owe->ecc_groups = l_ecc_supported_ike_groups();
+	owe->force_default_group = hs->force_default_owe_group;
 
 	if (!owe_reset(owe)) {
 		l_free(owe);
Signature · 1 line
2.34.3
#2 lore raw

PATCH 3/4 network: add setter/getter/flag for forcing default OWE group

In reply to James Prestwood

If a OWE network is buggy and requires the default group this info needs to be stored in network in order for it to set this into the handshake on future connect attempts.

---
 src/network.c | 14 ++++++++++++++
 src/network.h |  2 ++
 2 files changed, 16 insertions(+)
src/network.c +14 -0
index 70cb925c..c0befa42 100644
@@ -88,6 +88,7 @@ struct network {
 	bool provisioning_hidden:1;
 	uint8_t transition_disable; /* Temporary cache until info is set */
 	bool have_transition_disable:1;
+	bool force_default_owe_group:1;
 	int rank;
 	/* Holds DBus Connect() message if it comes in before ANQP finishes */
 	struct l_dbus_message *connect_after_anqp;
@@ -525,6 +526,9 @@ int network_handshake_setup(struct network *network, struct scan_bss *bss,
 		handshake_state_set_protocol_version(hs, eapol_proto_version);
 	}
 
+	if (hs->akm_suite == IE_RSN_AKM_SUITE_OWE)
+		hs->force_default_owe_group = network->force_default_owe_group;
+
 	/*
 	 * The randomization options in the provisioning file are dependent on
 	 * main.conf: [General].AddressRandomization=network. Any other value
@@ -764,6 +768,16 @@ void network_set_info(struct network *network, struct network_info *info)
 					IWD_NETWORK_INTERFACE, "KnownNetwork");
 }
 
+void network_set_force_default_owe_group(struct network *network)
+{
+	network->force_default_owe_group = true;
+}
+
+bool network_get_force_default_owe_group(struct network *network)
+{
+	return network->force_default_owe_group;
+}
+
 static inline bool __bss_is_sae(const struct scan_bss *bss,
 						const struct ie_rsn_info *rsn)
 {
src/network.h +2 -0
index d69d63b0..c6b99f6c 100644
@@ -58,6 +58,8 @@ void network_sync_settings(struct network *network);
 
 const struct network_info *network_get_info(const struct network *network);
 void network_set_info(struct network *network, struct network_info *info);
+void network_set_force_default_owe_group(struct network *network);
+bool network_get_force_default_owe_group(struct network *network);
 
 int network_can_connect_bss(struct network *network,
 						const struct scan_bss *bss);
Signature · 1 line
2.34.3
#3 lore raw

PATCH 4/4 station: re-try OWE if buggy AP is detected

In reply to James Prestwood

Some APs use an older hostapd OWE implementation which incorrectly derives the PTK. To work around this group 19 should be used for these APs. If there is a failure (reason=2) and the AKM is OWE set force default group into network and retry. If this has been done already the behavior is no different and the BSS will be blacklisted.

---
 src/station.c | 37 +++++++++++++++++++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)
src/station.c +35 -2
index c5dfc48e..40f9848f 100644
@@ -2815,6 +2815,31 @@ static bool station_try_next_bss(struct station *station)
 	return true;
 }
 
+static bool station_retry_owe_default_group(struct station *station)
+{
+	const uint8_t *rsne = station->connected_bss->rsne;
+	struct ie_rsn_info info;
+
+	if (!rsne)
+		return false;
+
+	if (ie_parse_rsne_from_data(rsne, rsne[1] + 2, &info))
+		return false;
+
+	if (!(info.akm_suites & IE_RSN_AKM_SUITE_OWE))
+		return false;
+
+	/* If we already forced group 19, allow the BSS to be blacklisted */
+	if (network_get_force_default_owe_group(station->connected_network))
+		return false;
+
+	l_debug("Buggy OWE AP detected, retrying by forcing group 19!");
+
+	network_set_force_default_owe_group(station->connected_network);
+
+	return true;
+}
+
 static bool station_retry_with_reason(struct station *station,
 					uint16_t reason_code)
 {
@@ -2825,12 +2850,20 @@ static bool station_retry_with_reason(struct station *station,
 	 * Other reason codes can be added here if its decided we want to
 	 * fail in those cases.
 	 */
-	if (reason_code == MMPDU_REASON_CODE_PREV_AUTH_NOT_VALID ||
-			reason_code == MMPDU_REASON_CODE_IEEE8021X_FAILED)
+	switch (reason_code) {
+	case MMPDU_REASON_CODE_PREV_AUTH_NOT_VALID:
+		if (station_retry_owe_default_group(station))
+			goto try_next;
+		/* fall through */
+	case MMPDU_REASON_CODE_IEEE8021X_FAILED:
 		return false;
+	default:
+		break;
+	}
 
 	blacklist_add_bss(station->connected_bss->addr);
 
+try_next:
 	return station_try_next_bss(station);
 }
 
Signature · 1 line
2.34.3