[PATCH 1/1] dbus: add a new property SAEConfirmMismatch

xinpeng wang wangxinpeng at uniontech.com
Wed Dec 25 03:23:43 PST 2024


Add a new dbus property SAEConfirmMismatch to notify the desktop
that a password dialog needs to pop up for the user to enter the
correct password

Signed-off-by: xinpeng wang <wangxinpeng at uniontech.com>
---
 src/common/sae.c                        |  1 +
 src/common/sae.h                        |  1 +
 wpa_supplicant/dbus/dbus_new.c          | 10 ++++++++++
 wpa_supplicant/dbus/dbus_new.h          |  1 +
 wpa_supplicant/dbus/dbus_new_handlers.c | 21 +++++++++++++++++++++
 wpa_supplicant/dbus/dbus_new_handlers.h |  1 +
 wpa_supplicant/notify.c                 | 10 ++++++++++
 wpa_supplicant/notify.h                 |  1 +
 wpa_supplicant/sme.c                    | 18 +++++++++++++++++-
 9 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/src/common/sae.c b/src/common/sae.c
index ce282db6b..8eb1183ff 100644
--- a/src/common/sae.c
+++ b/src/common/sae.c
@@ -2454,6 +2454,7 @@ int sae_check_confirm(struct sae_data *sae, const u8 *data, size_t len,
 			    data + 2, hash_len);
 		wpa_hexdump(MSG_DEBUG, "SAE: Calculated verifier",
 			    verifier, hash_len);
+		sae->sae_confirm_mismatch = 1;
 		return -1;
 	}
 
diff --git a/src/common/sae.h b/src/common/sae.h
index 8f74353be..ae5f5fde3 100644
--- a/src/common/sae.h
+++ b/src/common/sae.h
@@ -122,6 +122,7 @@ struct sae_data {
 	unsigned int h2e:1;
 	unsigned int pk:1;
 	unsigned int no_pw_id:1;
+	unsigned int sae_confirm_mismatch:1;
 	struct sae_temporary_data *tmp;
 };
 
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index ff7e003cb..add8d62f0 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -2519,6 +2519,9 @@ void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
 	case WPAS_DBUS_PROP_SIGNAL_CHANGE:
 		prop = "SignalChange";
 		break;
+	case WPAS_DBUS_PROP_SAE_CONFIRM_MISMATCH:
+		prop = "SAEConfirmMismatch";
+		break;
 	default:
 		wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
 			   __func__, property);
@@ -4191,6 +4194,13 @@ static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
 	  NULL,
 	  NULL
 	},
+#if defined(CONFIG_SAE) && defined(CONFIG_SME)
+	{ "SAEConfirmMismatch", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
+	  wpas_dbus_getter_sae_confirm_mismatch,
+	  NULL,
+	  NULL
+	},
+#endif /* CONFIG_SME && CONFIG_SAE */
 	{ NULL, NULL, NULL, NULL, NULL, NULL }
 };
 
diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h
index f9ff63642..66c5a0b9c 100644
--- a/wpa_supplicant/dbus/dbus_new.h
+++ b/wpa_supplicant/dbus/dbus_new.h
@@ -42,6 +42,7 @@ enum wpas_dbus_prop {
 	WPAS_DBUS_PROP_BSS_TM_STATUS,
 	WPAS_DBUS_PROP_MAC_ADDRESS,
 	WPAS_DBUS_PROP_SIGNAL_CHANGE,
+	WPAS_DBUS_PROP_SAE_CONFIRM_MISMATCH,
 };
 
 enum wpas_dbus_bss_prop {
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index 2fad8dd59..65ef99805 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -3631,6 +3631,27 @@ dbus_bool_t wpas_dbus_getter_scanning(
 						&scanning, error);
 }
 
+#if defined(CONFIG_SAE) && defined(CONFIG_SME)
+/**
+ * wpas_dbus_getter_sae_confirm_mismatch - Get interface sae_confirm_mismatch
+ * @iter: Pointer to incoming dbus message iter
+ * @error: Location to store error on failure
+ * @user_data: Function specific data
+ * Returns: TRUE on success, FALSE on failure
+ *
+ * Getter for "SAEConfirmMismatch" property.
+ */
+dbus_bool_t wpas_dbus_getter_sae_confirm_mismatch(
+	const struct wpa_dbus_property_desc *property_desc,
+	DBusMessageIter *iter, DBusError *error, void *user_data)
+{
+	struct wpa_supplicant *wpa_s = user_data;
+	dbus_bool_t sae_confirm_mismatch = wpa_s->sme.sae.sae_confirm_mismatch ? TRUE : FALSE;
+
+	return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BOOLEAN,
+						&sae_confirm_mismatch, error);
+}
+#endif /* CONFIG_SME && CONFIG_SAE*/
 
 /**
  * wpas_dbus_getter_ap_scan - Control roaming mode
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h
index a5260907a..e67071752 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers.h
@@ -225,6 +225,7 @@ DECLARE_ACCESSOR(wpas_dbus_getter_enabled);
 DECLARE_ACCESSOR(wpas_dbus_setter_enabled);
 DECLARE_ACCESSOR(wpas_dbus_getter_network_properties);
 DECLARE_ACCESSOR(wpas_dbus_setter_network_properties);
+DECLARE_ACCESSOR(wpas_dbus_getter_sae_confirm_mismatch);
 
 DBusMessage * wpas_dbus_handler_wps_start(DBusMessage *message,
 					  struct wpa_supplicant *wpa_s);
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index 06e006963..7cb38f192 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -290,6 +290,16 @@ void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
 }
 
 
+void wpas_notify_sae_confirm_mismatch(struct wpa_supplicant *wpa_s)
+{
+	if (wpa_s->p2p_mgmt)
+		return;
+
+	/* notify the new DBus API */
+	wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SAE_CONFIRM_MISMATCH);
+}
+
+
 void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
 {
 	if (wpa_s->p2p_mgmt)
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
index 7f6c345d2..c572f1661 100644
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -49,6 +49,7 @@ void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
 				 enum wpa_ctrl_req_type rtype,
 				 const char *default_txt);
 void wpas_notify_scanning(struct wpa_supplicant *wpa_s);
+void wpas_notify_sae_confirm_mismatch(struct wpa_supplicant *wpa_s);
 void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success);
 void wpas_notify_scan_results(struct wpa_supplicant *wpa_s);
 void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c
index 2b758939d..17205f70a 100644
--- a/wpa_supplicant/sme.c
+++ b/wpa_supplicant/sme.c
@@ -1820,6 +1820,17 @@ static int sme_sae_auth(struct wpa_supplicant *wpa_s, u16 auth_transaction,
 		return -1;
 	}
 
+	if (auth_transaction == 2 &&
+	    status_code == WLAN_REASON_UNSPECIFIED) {
+		/* Some APs will only send confirmation after receiving the correct confirmation
+		   sent by STA, otherwise they will send status_code=WLAN_REASON_UNSPECIFIED.
+		   In order to allow the desktop to pop up the password dialog in this case,here
+		   also notify SAEConfirmMismatch */
+		wpa_s->sme.sae.sae_confirm_mismatch = 1;
+		wpa_dbg(wpa_s, MSG_DEBUG, "SME: Notifying SAEConfirmMismatch attribute changes");
+		wpas_notify_sae_confirm_mismatch(wpa_s);
+	}
+
 	if (status_code != WLAN_STATUS_SUCCESS &&
 	    status_code != WLAN_STATUS_SAE_HASH_TO_ELEMENT &&
 	    status_code != WLAN_STATUS_SAE_PK) {
@@ -1913,8 +1924,13 @@ static int sme_sae_auth(struct wpa_supplicant *wpa_s, u16 auth_transaction,
 		if (wpa_s->sme.sae.state != SAE_CONFIRMED)
 			return -1;
 		if (sae_check_confirm(&wpa_s->sme.sae, data, len,
-				      ie_offset) < 0)
+				      ie_offset) < 0) {
+			if (wpa_s->sme.sae.sae_confirm_mismatch) {
+				wpa_dbg(wpa_s, MSG_DEBUG, "SME: Notifying SAEConfirmMismatch attribute changes");
+				wpas_notify_sae_confirm_mismatch(wpa_s);
+			}
 			return -1;
+		}
 		if (external && wpa_s->sme.ext_ml_auth &&
 		    sme_external_ml_auth(wpa_s, data, len, *ie_offset,
 					 status_code))
-- 
2.20.1




More information about the Hostap mailing list