WEP Key Interface[patch], was 40-bit keys
- From: j bootlab org
- To: networkmanager-list gnome org
- Subject: WEP Key Interface[patch], was 40-bit keys
- Date: Mon, 01 Nov 2004 23:53:45 +0100
this patch adds support for Ascii/Hex 40-Bit keys and changes the
interface for key type to:
WEP Passphrase
WEP 40/128-bit Ascii Key
WEP 40/128-bit Hex Key
adding WEP to the options, mainly is with WPA in mind.
j
Index: NetworkManager.h
===================================================================
RCS file: /cvs/gnome/NetworkManager/NetworkManager.h,v
retrieving revision 1.1
diff -u -r1.1 NetworkManager.h
--- NetworkManager.h 21 Oct 2004 17:42:14 -0000 1.1
+++ NetworkManager.h 1 Nov 2004 22:35:54 -0000
@@ -75,9 +75,8 @@
{
NM_ENC_TYPE_UNKNOWN = 0,
NM_ENC_TYPE_NONE,
- NM_ENC_TYPE_40_BIT_HEX_KEY,
- NM_ENC_TYPE_40_BIT_PASSPHRASE,
- NM_ENC_TYPE_128_BIT_HEX_KEY,
+ NM_ENC_TYPE_HEX_KEY,
+ NM_ENC_TYPE_ASCII_KEY,
NM_ENC_TYPE_128_BIT_PASSPHRASE
/* FIXME: WPA and 802.1x support */
} NMEncKeyType;
Index: info-daemon/NetworkManagerInfoPassphraseDialog.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/info-daemon/NetworkManagerInfoPassphraseDialog.c,v
retrieving revision 1.7
diff -u -r1.7 NetworkManagerInfoPassphraseDialog.c
--- info-daemon/NetworkManagerInfoPassphraseDialog.c 27 Oct 2004 19:02:07 -0000 1.7
+++ info-daemon/NetworkManagerInfoPassphraseDialog.c 1 Nov 2004 22:35:55 -0000
@@ -40,8 +40,9 @@
enum NMIPassphraseDialogKeyTypes
{
- KEY_TYPE_128_BIT_PASSPHRASE = 0,
- KEY_TYPE_128_BIT_RAW_HEX_KEY = 1
+ KEY_TYPE_PASSPHRASE = 0,
+ KEY_TYPE_ASCII_KEY = 1,
+ KEY_TYPE_HEX_KEY = 2
};
@@ -96,11 +97,14 @@
entry_label = GTK_LABEL (glade_xml_get_widget (info->passphrase_dialog, "passphrase_entry_label"));
switch ((combo_choice = gtk_combo_box_get_active (GTK_COMBO_BOX (key_type_combo))))
{
- case KEY_TYPE_128_BIT_PASSPHRASE:
+ case KEY_TYPE_PASSPHRASE:
gtk_label_set_label (entry_label, _("Passphrase:"));
break;
- case KEY_TYPE_128_BIT_RAW_HEX_KEY:
- gtk_label_set_label (entry_label, _("Key:"));
+ case KEY_TYPE_ASCII_KEY:
+ gtk_label_set_label (entry_label, _("Ascii Key:"));
+ break;
+ case KEY_TYPE_HEX_KEY:
+ gtk_label_set_label (entry_label, _("Hex Key:"));
break;
default:
break;
@@ -137,11 +141,14 @@
switch (key_type)
{
- case KEY_TYPE_128_BIT_PASSPHRASE:
+ case KEY_TYPE_PASSPHRASE:
key_type_return = NM_ENC_TYPE_128_BIT_PASSPHRASE;
break;
- case KEY_TYPE_128_BIT_RAW_HEX_KEY:
- key_type_return = NM_ENC_TYPE_128_BIT_HEX_KEY;
+ case KEY_TYPE_ASCII_KEY:
+ key_type_return = NM_ENC_TYPE_ASCII_KEY;
+ break;
+ case KEY_TYPE_HEX_KEY:
+ key_type_return = NM_ENC_TYPE_HEX_KEY;
break;
default:
key_type_return = NM_ENC_TYPE_UNKNOWN;
Index: info-daemon/passphrase.glade
===================================================================
RCS file: /cvs/gnome/NetworkManager/info-daemon/passphrase.glade,v
retrieving revision 1.7
diff -u -r1.7 passphrase.glade
--- info-daemon/passphrase.glade 8 Oct 2004 05:22:17 -0000 1.7
+++ info-daemon/passphrase.glade 1 Nov 2004 22:35:55 -0000
@@ -147,8 +147,9 @@
<child>
<widget class="GtkComboBox" id="key_type_combo">
<property name="visible">True</property>
- <property name="items" translatable="yes">128-bit Passphrase
-128-bit Raw Hex Key</property>
+ <property name="items" translatable="yes">WEP Passphrase
+WEP 40/128-bit Ascii Key
+WEP 40/128-bit Hex Key</property>
</widget>
<packing>
<property name="padding">0</property>
Index: panel-applet/NMWirelessAppletOtherNetworkDialog.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/panel-applet/NMWirelessAppletOtherNetworkDialog.c,v
retrieving revision 1.1
diff -u -r1.1 NMWirelessAppletOtherNetworkDialog.c
--- panel-applet/NMWirelessAppletOtherNetworkDialog.c 29 Oct 2004 16:37:43 -0000 1.1
+++ panel-applet/NMWirelessAppletOtherNetworkDialog.c 1 Nov 2004 22:36:00 -0000
@@ -42,8 +42,9 @@
enum NMWAEncryptionKeyTypes
{
- KEY_TYPE_128_BIT_PASSPHRASE = 0,
- KEY_TYPE_128_BIT_HEX_KEY = 1
+ KEY_TYPE_PASSPHRASE = 0,
+ KEY_TYPE_ASCII_KEY = 1,
+ KEY_TYPE_HEX_KEY = 2
};
@@ -105,11 +106,14 @@
entry_label = GTK_LABEL (glade_xml_get_widget (xml, "passphrase_entry_label"));
switch ((combo_choice = gtk_combo_box_get_active (GTK_COMBO_BOX (key_type_combo))))
{
- case KEY_TYPE_128_BIT_PASSPHRASE:
+ case KEY_TYPE_PASSPHRASE:
gtk_label_set_label (entry_label, _("Passphrase:"));
break;
- case KEY_TYPE_128_BIT_HEX_KEY:
- gtk_label_set_label (entry_label, _("Key:"));
+ case KEY_TYPE_ASCII_KEY:
+ gtk_label_set_label (entry_label, _("Ascii Key:"));
+ break;
+ case KEY_TYPE_HEX_KEY:
+ gtk_label_set_label (entry_label, _("Hex Key:"));
break;
default:
break;
@@ -311,17 +315,19 @@
switch (key_type)
{
- case KEY_TYPE_128_BIT_PASSPHRASE:
+ case KEY_TYPE_PASSPHRASE:
nm_key_type = NM_ENC_TYPE_128_BIT_PASSPHRASE;
break;
- case KEY_TYPE_128_BIT_HEX_KEY:
- nm_key_type = NM_ENC_TYPE_128_BIT_HEX_KEY;
+ case KEY_TYPE_ASCII_KEY:
+ nm_key_type = NM_ENC_TYPE_ASCII_KEY;
+ break;
+ case KEY_TYPE_HEX_KEY:
+ nm_key_type = NM_ENC_TYPE_HEX_KEY;
break;
default:
nm_key_type = NM_ENC_TYPE_UNKNOWN;
break;
}
-
applet->applet_state = APPLET_STATE_WIRELESS_CONNECTING;
applet->forcing_device = TRUE;
nmwa_dbus_set_device (applet->connection, def_dev, net, nm_key_type, passphrase);
Index: panel-applet/essid.glade
===================================================================
RCS file: /cvs/gnome/NetworkManager/panel-applet/essid.glade,v
retrieving revision 1.3
diff -u -r1.3 essid.glade
--- panel-applet/essid.glade 29 Oct 2004 16:37:43 -0000 1.3
+++ panel-applet/essid.glade 1 Nov 2004 22:36:00 -0000
@@ -312,8 +312,9 @@
<child>
<widget class="GtkComboBox" id="key_type_combo">
<property name="visible">True</property>
- <property name="items" translatable="yes">128-bit Passphrase
-128-bit Raw Hex Key</property>
+ <property name="items" translatable="yes">WEP Passphrase
+WEP 40/128-bit Ascii Key
+WEP 40/128-bit Hex Key</property>
</widget>
<packing>
<property name="left_attach">1</property>
Index: src/NetworkManagerAP.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerAP.c,v
retrieving revision 1.17
diff -u -r1.17 NetworkManagerAP.c
--- src/NetworkManagerAP.c 27 Oct 2004 19:02:07 -0000 1.17
+++ src/NetworkManagerAP.c 1 Nov 2004 22:36:00 -0000
@@ -223,10 +223,15 @@
if (source_key)
hashed = nm_wireless_128bit_key_from_passphrase (source_key);
break;
-
- case (NM_ENC_TYPE_128_BIT_HEX_KEY):
- case (NM_ENC_TYPE_40_BIT_PASSPHRASE):
- case (NM_ENC_TYPE_40_BIT_HEX_KEY):
+ case (NM_ENC_TYPE_ASCII_KEY):
+ if (source_key){
+ if(strlen(source_key)<=5)
+ hashed = nm_wireless_40bit_ascii_to_hex (source_key);
+ else
+ hashed = nm_wireless_128bit_ascii_to_hex (source_key);
+ }
+ break;
+ case (NM_ENC_TYPE_HEX_KEY):
case (NM_ENC_TYPE_UNKNOWN):
if (source_key)
hashed = g_strdup (source_key);
Index: src/NetworkManagerDevice.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerDevice.c,v
retrieving revision 1.56
diff -u -r1.56 NetworkManagerDevice.c
--- src/NetworkManagerDevice.c 29 Oct 2004 19:52:35 -0000 1.56
+++ src/NetworkManagerDevice.c 1 Nov 2004 22:36:02 -0000
@@ -2149,12 +2149,17 @@
char *hashed_key = NULL;
switch (key_type)
{
+
case (NM_ENC_TYPE_128_BIT_PASSPHRASE):
hashed_key = nm_wireless_128bit_key_from_passphrase (key);
break;
- case (NM_ENC_TYPE_128_BIT_HEX_KEY):
- case (NM_ENC_TYPE_40_BIT_PASSPHRASE):
- case (NM_ENC_TYPE_40_BIT_HEX_KEY):
+ case (NM_ENC_TYPE_ASCII_KEY):
+ if(strlen(key)<=5)
+ hashed_key = nm_wireless_40bit_ascii_to_hex (key);
+ else
+ hashed_key = nm_wireless_128bit_ascii_to_hex (key);
+ break;
+ case (NM_ENC_TYPE_HEX_KEY):
case (NM_ENC_TYPE_UNKNOWN):
hashed_key = g_strdup (key);
break;
Index: src/NetworkManagerWireless.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerWireless.c,v
retrieving revision 1.16
diff -u -r1.16 NetworkManagerWireless.c
--- src/NetworkManagerWireless.c 13 Sep 2004 17:43:16 -0000 1.16
+++ src/NetworkManagerWireless.c 1 Nov 2004 22:36:02 -0000
@@ -33,18 +33,42 @@
#include "NetworkManagerPolicy.h"
#include "NetworkManagerUtils.h"
+/*
+ * nm_wireless_40bit_ascii_to_hex
+ *
+ * Convert an ASCII string into a suitable WEP key.
+ *
+ */
+char *nm_wireless_40bit_ascii_to_hex (char *ascii)
+{
+ static char hex_digits[] = "0123456789abcdef";
+ unsigned char *res;
+ int i;
+
+ res = g_malloc (33);
+ for (i = 0; i < 16; i++)
+ {
+ res[2*i] = hex_digits[ascii[i] >> 4];
+ res[2*i+1] = hex_digits[ascii[i] & 0xf];
+ }
+
+ /* We chomp it at byte 10, since WEP keys only use 40 bits */
+ res[10] = 0;
+ return (res);
+}
+
/*
- * nm_wireless_md5_digest_to_ascii
+ * nm_wireless_128bit_ascii_to_hex
*
- * Convert an MD5 digest into an ascii string suitable for use
+ * Convert an ascii string into a suitable string for use
* as a WEP key.
*
* Code originally by Alex Larsson <alexl redhat com> and
* copyright Red Hat, Inc. under terms of the LGPL.
*
*/
-static char *nm_wireless_md5_digest_to_ascii (unsigned char digest[16])
+char *nm_wireless_128bit_ascii_to_hex (char *ascii)
{
static char hex_digits[] = "0123456789abcdef";
unsigned char *res;
@@ -53,8 +77,8 @@
res = g_malloc (33);
for (i = 0; i < 16; i++)
{
- res[2*i] = hex_digits[digest[i] >> 4];
- res[2*i+1] = hex_digits[digest[i] & 0xf];
+ res[2*i] = hex_digits[ascii[i] >> 4];
+ res[2*i+1] = hex_digits[ascii[i] & 0xf];
}
/* We chomp it at byte 26, since WEP keys only use 104 bits */
@@ -96,7 +120,7 @@
gnome_keyring_md5_string (md5_data, digest);
#endif
- return (nm_wireless_md5_digest_to_ascii (digest));
+ return (nm_wireless_128bit_ascii_to_hex (digest));
}
Index: src/NetworkManagerWireless.h
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerWireless.h,v
retrieving revision 1.7
diff -u -r1.7 NetworkManagerWireless.h
--- src/NetworkManagerWireless.h 13 Sep 2004 17:43:16 -0000 1.7
+++ src/NetworkManagerWireless.h 1 Nov 2004 22:36:02 -0000
@@ -27,6 +27,8 @@
#include "NetworkManagerDevice.h"
#include "NetworkManagerAPList.h"
+char * nm_wireless_40bit_ascii_to_hex (char *ascii);
+char * nm_wireless_128bit_ascii_to_hex (char *ascii);
char * nm_wireless_128bit_key_from_passphrase (char *passphrase);
gboolean nm_wireless_scan_monitor (gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]