Add dbus method for getting wifi passphrase 53/308253/1
authorJaehyun Kim <jeik01.kim@samsung.com>
Wed, 20 Mar 2024 08:21:16 +0000 (17:21 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Wed, 20 Mar 2024 08:21:16 +0000 (17:21 +0900)
This is the dbus method only for the internal modules
with special privileges.

Change-Id: I17bc91d9e4b35eea76e9c2245b37ff1121aba87b
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
include/wifi-key-encryption.h
interfaces/netconfig-iface-wifi.xml
resources/etc/dbus-1/system.d/net-config.conf
src/wifi-config.c
src/wifi-key-encryption.c

index 3b604831aaf4d6dba0591e28c233b72ca3130d62..064bc768e6af5cc4e509c08548122cba3b33d653 100755 (executable)
@@ -33,6 +33,7 @@ gboolean handle_decrypt_conf_obj(Wifi *wifi, GDBusMethodInvocation *context,
                const gchar *enc_c_sign_key,
                const gchar *enc_net_access_key);
 gchar* _netconfig_encrypt_passphrase(const gchar *passphrase);
+gchar* _netconfig_decrypt_passphrase(const gchar *enc_data);
 
 #ifdef __cplusplus
 }
index ff272d11a1282238e48a1b1372ab4b7589e9616c..85fc86ce3af080a599ebcfc6443c81ba98467a88 100755 (executable)
                        <arg type="s" name="value" direction="in"/>
                </method>
                <method name="GetConfigPassphrase">
+                       <arg type="s" name="ifname" direction="in"/>
                        <arg type="s" name="config_id" direction="in"/>
                        <arg type="s" name="passphrase" direction="out"/>
                </method>
index f815a381dc507af9b86aff4d58dc2fed0e44f528..bbbca1a8c103b6b67750cab7e4617d5a923346ff 100755 (executable)
@@ -71,6 +71,7 @@
                <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="NetlinkScan" privilege="http://tizen.org/privilege/network.set" />
                <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="RequestWpsCancel" privilege="http://tizen.org/privilege/network.set" />
                <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="RequestWpsConnect" privilege="http://tizen.org/privilege/network.set" />
+               <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="GetConfigPassphrase" privilege="http://tizen.org/privilege/wifi.secureinfo" />
                <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="CreateEapConfig" privilege="http://tizen.org/privilege/network.profile" />
                <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="LoadDriver" privilege="http://tizen.org/privilege/network.set" />
                <check send_destination="net.netconfig" send_interface="net.netconfig.wifi" send_member="GetBssidList" privilege="http://tizen.org/privilege/network.get" />
index a00ba502abfad6bd19e0128d88b8fcc68b54f51f..99c6903e6f7bbdad7b6da47aa58175ddb8cefdef 100755 (executable)
@@ -654,7 +654,14 @@ static gboolean _get_field(const gchar *interface_name,
        if (g_strcmp0(key, WIFI_CONFIG_NAME) == 0) {
                val = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_NAME, NULL);
        } else if (g_strcmp0(key, WIFI_CONFIG_PASSPHRASE) == 0) {
-               val = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_PASSPHRASE, NULL);
+               gchar *enc_pass = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_PASSPHRASE, NULL);
+               if (enc_pass) {
+                       val = _netconfig_decrypt_passphrase(enc_pass);
+                       g_free(enc_pass);
+
+                       if (!val)
+                               ERR("Failed to decrypt the passphrase");
+               }
        } else if (g_strcmp0(key, WIFI_CONFIG_PROXY_SERVER) == 0) {
                val = g_key_file_get_string(keyfile, group_name, WIFI_CONFIG_PROXY_SERVER, NULL);
        } else if (g_strcmp0(key, WIFI_CONFIG_HIDDEN) == 0) {
@@ -1967,7 +1974,7 @@ gboolean handle_get_config_passphrase(Wifi *wifi, GDBusMethodInvocation *context
        gboolean ret = FALSE;
        gchar *passphrase = NULL;
 
-       if ((wifi == NULL) || (config_id == NULL)) {
+       if ((wifi == NULL) || (ifname == NULL) || (config_id == NULL)) {
                ERR("Invalid parameter");
                netconfig_error_invalid_parameter(context);
                return TRUE;
index 13391d314dd82cfe9007faae95ba0b5041b9f73b..33c8f5a5eba253148f838bd102703ada29f71105 100755 (executable)
@@ -240,7 +240,7 @@ gchar* _netconfig_encrypt_passphrase(const gchar *passphrase)
        return encrypted_value;
 }
 
-static gchar* _netconfig_decrypt_passphrase(const gchar *enc_data)
+gchar* _netconfig_decrypt_passphrase(const gchar *enc_data)
 {
        gchar *ehexstr = NULL;
        gchar *encrypted_value = NULL;