Discussion:
[PATCH] read out all 4 keys with wext
Tormod Volden
2008-01-29 22:36:48 UTC
Permalink
If you try to read out the encryption keys with "iwlist enc" you
actually get the default key listed 4 times, instead of the 4
different keys. This is because the key number part of erq->flags in
p80211wext_giwencode() gets zeroed out before the key number is read
out. The attached patch make this work better.

Further discussion: IW_ENCODE_ENABLED is 0000, so OR'ing with it is
kind of pointless, although consistent with the other bit masking.

Somewhat better would be to avoid using IW_ENCODE_ENABLED:

if (wlandev->hostwep & HOSTWEP_PRIVACYINVOKED)
erq->flags &= ~IW_ENCODE_DISABLED;
else
erq->flags |= IW_ENCODE_DISABLED;

Tormod
Richard Kennedy
2008-01-30 12:51:02 UTC
Permalink
Post by Tormod Volden
If you try to read out the encryption keys with "iwlist enc" you
actually get the default key listed 4 times, instead of the 4
different keys. This is because the key number part of erq->flags in
p80211wext_giwencode() gets zeroed out before the key number is read
out. The attached patch make this work better.
Further discussion: IW_ENCODE_ENABLED is 0000, so OR'ing with it is
kind of pointless, although consistent with the other bit masking.
if (wlandev->hostwep & HOSTWEP_PRIVACYINVOKED)
erq->flags &= ~IW_ENCODE_DISABLED;
else
erq->flags |= IW_ENCODE_DISABLED;
Tormod
Hi Tormod,

Good catch :) , that's been broken for a long time by the looks of it.

Its interesting that IW_ENCODE_ENABLED is 0. I've had a quick look to
check where we've used it, but fortunately there's nothing broken. Just
a bit of redundant code

Might it be easier to understand if we get the index first, then reset
the flags ?

something like this :-

diff --git a/src/p80211/p80211wext.c b/src/p80211/p80211wext.c
index 6fac5d3..704411a 100644
--- a/src/p80211/p80211wext.c
+++ b/src/p80211/p80211wext.c
@@ -572,18 +572,18 @@ static int p80211wext_giwencode(netdevice_t *dev,

DBFENTER;

+ i = (erq->flags & IW_ENCODE_INDEX) - 1;
+ erq->flags = 0;
if (wlandev->hostwep & HOSTWEP_PRIVACYINVOKED)
- erq->flags = IW_ENCODE_ENABLED;
+ erq->flags |= IW_ENCODE_ENABLED;
else
- erq->flags = IW_ENCODE_DISABLED;
+ erq->flags |= IW_ENCODE_DISABLED;

if (wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED)
erq->flags |= IW_ENCODE_RESTRICTED;
else
erq->flags |= IW_ENCODE_OPEN;

- i = (erq->flags & IW_ENCODE_INDEX) - 1;
-
if (i == -1)
i = wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK;
Tormod Volden
2008-01-30 19:05:51 UTC
Permalink
Post by Richard Kennedy
Might it be easier to understand if we get the index first, then reset
the flags ?
Yes, that looks better. I just didn't understand whether the flags
should be reset or preserved with the old code.

Tormod
Solomon Peachy
2008-01-30 22:00:50 UTC
Permalink
Post by Richard Kennedy
Good catch :) , that's been broken for a long time by the looks of it.
Indeed it has.
Post by Richard Kennedy
diff --git a/src/p80211/p80211wext.c b/src/p80211/p80211wext.c
index 6fac5d3..704411a 100644
--- a/src/p80211/p80211wext.c
+++ b/src/p80211/p80211wext.c
I've applied this patch.

- Solomon
--
Solomon Peachy ***@linux-wlan.com
AbsoluteValue Systems http://www.linux-wlan.com
721-D North Drive +1 (321) 259-0737 (office)
Melbourne, FL 32934 +1 (321) 259-0286 (fax)
Tormod Volden
2008-01-30 23:43:57 UTC
Permalink
Post by Solomon Peachy
I've applied this patch.
The patch was not completely applied, this part seems to be lost:

erq->flags |= IW_ENCODE_OPEN;

- i = (erq->flags & IW_ENCODE_INDEX) - 1;
-
if (i =

Tormod
Solomon Peachy
2008-01-31 14:31:25 UTC
Permalink
Applied. r1843.

- Solomon
--
Solomon Peachy ***@linux-wlan.com
AbsoluteValue Systems http://www.linux-wlan.com
721-D North Drive +1 (321) 259-0737 (office)
Melbourne, FL 32934 +1 (321) 259-0286 (fax)
Tormod Volden
2008-01-31 15:33:20 UTC
Permalink
Post by Solomon Peachy
Applied. r1843.
It seems that you also added the below, which was not in the patch
from Richard or me. It breaks listing the current key number with
"iwlist".

Tormod

@@ -592,8 +595,6 @@
goto exit;
}

- erq->flags |= i + 1;
-
/* copy the key from the driver cache as the keys are read-only MIBs */
erq->length = wlandev->wep_keylens[i];
memcpy(key, wlandev->wep_keys[i], erq->length);

Loading...