summaryrefslogtreecommitdiff
path: root/gsupplicant
diff options
context:
space:
mode:
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>2011-06-11 08:07:39 (GMT)
committerSamuel Ortiz <sameo@linux.intel.com>2011-06-14 09:27:38 (GMT)
commit0f37827d4eaa59f0c793225c3723adc16941ef40 (patch)
treebc06ed4bff18de39a3e42c32ef452002ba42b709 /gsupplicant
parent21d9a77c6568f22839ae745e21847d69837b9be6 (diff)
downloadconnman-0f37827d4eaa59f0c793225c3723adc16941ef40.zip
connman-0f37827d4eaa59f0c793225c3723adc16941ef40.tar.gz
connman-0f37827d4eaa59f0c793225c3723adc16941ef40.tar.bz2
gsupplicant: Fix how raw key as psk are provided.
Diffstat (limited to 'gsupplicant')
-rw-r--r--gsupplicant/supplicant.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 2c3e5dd..485b671 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -29,6 +29,7 @@
#include <string.h>
#include <stdint.h>
#include <syslog.h>
+#include <ctype.h>
#include <glib.h>
#include <gdbus.h>
@@ -2554,13 +2555,36 @@ static void add_network_security_wep(DBusMessageIter *dict,
}
}
+static dbus_bool_t is_psk_raw_key(const char *psk)
+{
+ int i;
+
+ /* A raw key is always 64 bytes length... */
+ if (strlen(psk) != 64)
+ return FALSE;
+
+ /* ... and its content is in hex representation */
+ for (i = 0; i < 64; i++)
+ if (!isxdigit((unsigned char) psk[i]))
+ return FALSE;
+
+ return TRUE;
+}
+
static void add_network_security_psk(DBusMessageIter *dict,
GSupplicantSSID *ssid)
{
- if (ssid->passphrase && strlen(ssid->passphrase) > 0)
+ if (ssid->passphrase && strlen(ssid->passphrase) > 0) {
+
+ if (is_psk_raw_key(ssid->passphrase) == TRUE)
+ supplicant_dbus_property_append_fixed_array(dict,
+ "psk", DBUS_TYPE_BYTE,
+ &ssid->passphrase, 64);
+ else
supplicant_dbus_dict_append_basic(dict, "psk",
- DBUS_TYPE_STRING,
+ DBUS_TYPE_STRING,
&ssid->passphrase);
+ }
}
static void add_network_security_tls(DBusMessageIter *dict,