Ethereal-users: Re: [Ethereal-users] 802.11 in Preferences (WEP key entry)

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Motonori Shindo <mshindo@xxxxxxxxxxx>
Date: Tue, 24 Jun 2003 00:18:33 +0900 (JST)
I guess some people had trouble with decrypting WEP-encrypted packets
because current code has a bug. It parses the WEP key only once and
the key you entered in the preference afterward will not be reflected
at all. Attached is a patch to correct this anomaly.

I also changed the balloon help message that appears in the preference
to make it less confusing about the format in which the WEP key should
be entered. WEP key is typically either 40 bits (5 bytes) or 104 bits
(13 bytes) while some modern systems can use longer key like 128 bits
and even more. The code itself is in fact able to handle arbitrary key
length. Anyway, the current help message "(A:B:C:D:E:F)" is a little
bit confusing.

Regards,
 
From: Chris Waters <chris.waters@xxxxxxxxxxxxxxxxxxxx>
Subject: Re: [Ethereal-users] 802.11 in Preferences (WEP key entry)
Date: Wed, 18 Jun 2003 13:13:11 -0700

> Hi,
> 
> The WEP key needs to be in A:B:C:D:E hex format. I have had it working, but
> it was a while ago so I can't remember exactly how this works, but you
> should try something like:
> 
> 0A:B1:C2:D3:E4:F5
> 
> Regards,
> 
> Chris.
> 
> ----- Original Message -----
> From: "Brandon Applegate" <brandon@xxxxxxxx>
> To: <ethereal-users@xxxxxxxxxxxx>
> Sent: Wednesday, June 18, 2003 11:54 AM
> Subject: [Ethereal-users] 802.11 in Preferences (WEP key entry)
> 
> 
> > I sniff my own net, have WEPed traffic dump.  Fire up Ethereal and enter
> > my WEP key in the Preferences tab.  Nothing happens.  Normal behavior ?
> > Is there a strict syntax for the WEP key ?  Some other option to make it
> > get decoded ?
> >
> > --
> > Brandon Applegate - CCIE 10273
> > PGP Key fingerprint:
> > 7407 DC86 AA7B A57F 62D1 A715 3C63 66A1 181E 6996
> > "SH1-0151.  This is the serial number, of our orbital gun."
> >
> >
> > _______________________________________________
> > Ethereal-users mailing list
> > Ethereal-users@xxxxxxxxxxxx
> > http://www.ethereal.com/mailman/listinfo/ethereal-users
> >
> 
> _______________________________________________
> Ethereal-users mailing list
> Ethereal-users@xxxxxxxxxxxx
> http://www.ethereal.com/mailman/listinfo/ethereal-users
> 

Index: packet-ieee80211.c
===================================================================
RCS file: /cvsroot/ethereal/packet-ieee80211.c,v
retrieving revision 1.91
diff -u -r1.91 packet-ieee80211.c
--- packet-ieee80211.c	5 Jun 2003 22:10:49 -0000	1.91
+++ packet-ieee80211.c	23 Jun 2003 15:14:44 -0000
@@ -2526,7 +2526,7 @@
   register_init_routine(wlan_defragment_init);
 
   /* Register configuration options */
-  wlan_module = prefs_register_protocol(proto_wlan, NULL);
+  wlan_module = prefs_register_protocol(proto_wlan, init_wepkeys);
   prefs_register_bool_preference(wlan_module, "defragment",
 	"Reassemble fragmented 802.11 datagrams",
 	"Whether fragmented 802.11 datagrams should be reassembled",
@@ -2550,19 +2550,19 @@
 
   prefs_register_string_preference(wlan_module, "wep_key1",
 				   "WEP key #1",
-				   "First WEP key (A:B:C:D:E:F)",
+				   "First WEP key (A:B:C:D:E) [40bit], (A:B:C:D:E:F:G:H:I:J:K:L:M) [104bit], or whatever key length you're using",
 				   &wep_keystr[0]);
   prefs_register_string_preference(wlan_module, "wep_key2",
 				   "WEP key #2",
-				   "Second WEP key (A:B:C:D:E:F)",
+				   "Second WEP key (A:B:C:D:E) [40bit], (A:B:C:D:E:F:G:H:I:J:K:L:M) [104bit], or whatever key length you're using",
 				   &wep_keystr[1]);
   prefs_register_string_preference(wlan_module, "wep_key3",
 				   "WEP key #3",
-				   "Third WEP key (A:B:C:D:E:F)",
+				   "Third WEP key (A:B:C:D:E) [40bit], (A:B:C:D:E:F:G:H:I:J:K:L:M) [104bit], or whatever key length you're using",
 				   &wep_keystr[2]);
   prefs_register_string_preference(wlan_module, "wep_key4",
 				   "WEP key #4",
-				   "Fourth WEP key (A:B:C:D:E:F)",
+				   "Fourth WEP key (A:B:C:D:E) [40bit] (A:B:C:D:E:F:G:H:I:J:K:L:M) [104bit], or whatever key length you're using",
 				   &wep_keystr[3]);
 #endif
 }
@@ -2650,8 +2650,6 @@
 
   if (num_wepkeys < 1)
     return NULL;
-  if (wep_keylens == NULL)
-    init_wepkeys();
 
   if ((tmp = g_malloc(len)) == NULL)
     return NULL;  /* krap! */
@@ -2794,8 +2792,11 @@
   if (num_wepkeys < 1)
     return;
 
-  if (wep_keylens != NULL)
-    return;
+  if (wep_keys)
+    g_free(wep_keys);
+
+  if (wep_keylens)
+    g_free(wep_keylens);
 
   wep_keys = g_malloc(num_wepkeys * sizeof(guint8*));
   wep_keylens = g_malloc(num_wepkeys * sizeof(int));
@@ -2821,6 +2822,8 @@
 #endif
 #endif
 
+      if (wep_keys[i])
+	g_free(wep_keys[i]);
       wep_keys[i] = g_malloc(32 * sizeof(guint8));
       memset(wep_keys[i], 0, 32 * sizeof(guint8));
       tmp3 = wep_keys[i];