aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/wep.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2007-08-28 17:01:54 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:48:51 -0400
commit8f20fc24986a083228823d9b68adca20714b254e (patch)
treeb5d7638b913649c7a181d6703ccd72e35ca06de9 /net/mac80211/wep.c
parent13262ffd4902805acad2618c12b41fcaa6c50791 (diff)
[MAC80211]: embed key conf in key, fix driver interface
This patch embeds the struct ieee80211_key_conf into struct ieee80211_key and thus avoids allocations and having data present twice. This required some more changes: 1) The removal of the IEEE80211_KEY_DEFAULT_TX_KEY key flag. This flag isn't used by drivers nor should it be since we have a set_key_idx() callback. Maybe that callback needs to be extended to include the key conf, but only a driver that requires it will tell. 2) The removal of the IEEE80211_KEY_DEFAULT_WEP_ONLY key flag. This flag is global, so it shouldn't be passed in the key conf structure. Pass it to the function instead. Also, this patch removes the AID parameter to the set_key() callback because it is currently unused and the hardware currently cannot know about the AID anyway. I suspect this was used with some hardware that actually selected the AID itself, but that functionality was removed. Additionally, I've removed the ALG_NULL key algorithm since we have ALG_NONE. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Acked-by: Michael Wu <flamingice@sourmilk.net> Signed-off-by: John W. Linville <linville@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/mac80211/wep.c')
-rw-r--r--net/mac80211/wep.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c
index 1ad3d75281cc..0b19e89fcf6a 100644
--- a/net/mac80211/wep.c
+++ b/net/mac80211/wep.c
@@ -67,7 +67,7 @@ void ieee80211_wep_get_iv(struct ieee80211_local *local,
67 struct ieee80211_key *key, u8 *iv) 67 struct ieee80211_key *key, u8 *iv)
68{ 68{
69 local->wep_iv++; 69 local->wep_iv++;
70 if (ieee80211_wep_weak_iv(local->wep_iv, key->keylen)) 70 if (ieee80211_wep_weak_iv(local->wep_iv, key->conf.keylen))
71 local->wep_iv += 0x0100; 71 local->wep_iv += 0x0100;
72 72
73 if (!iv) 73 if (!iv)
@@ -76,7 +76,7 @@ void ieee80211_wep_get_iv(struct ieee80211_local *local,
76 *iv++ = (local->wep_iv >> 16) & 0xff; 76 *iv++ = (local->wep_iv >> 16) & 0xff;
77 *iv++ = (local->wep_iv >> 8) & 0xff; 77 *iv++ = (local->wep_iv >> 8) & 0xff;
78 *iv++ = local->wep_iv & 0xff; 78 *iv++ = local->wep_iv & 0xff;
79 *iv++ = key->keyidx << 6; 79 *iv++ = key->conf.keyidx << 6;
80} 80}
81 81
82 82
@@ -159,10 +159,10 @@ int ieee80211_wep_encrypt(struct ieee80211_local *local, struct sk_buff *skb,
159 u8 *rc4key, *iv; 159 u8 *rc4key, *iv;
160 size_t len; 160 size_t len;
161 161
162 if (!key || key->alg != ALG_WEP) 162 if (!key || key->conf.alg != ALG_WEP)
163 return -1; 163 return -1;
164 164
165 klen = 3 + key->keylen; 165 klen = 3 + key->conf.keylen;
166 rc4key = kmalloc(klen, GFP_ATOMIC); 166 rc4key = kmalloc(klen, GFP_ATOMIC);
167 if (!rc4key) 167 if (!rc4key)
168 return -1; 168 return -1;
@@ -179,7 +179,7 @@ int ieee80211_wep_encrypt(struct ieee80211_local *local, struct sk_buff *skb,
179 memcpy(rc4key, iv, 3); 179 memcpy(rc4key, iv, 3);
180 180
181 /* Copy rest of the WEP key (the secret part) */ 181 /* Copy rest of the WEP key (the secret part) */
182 memcpy(rc4key + 3, key->key, key->keylen); 182 memcpy(rc4key + 3, key->conf.key, key->conf.keylen);
183 183
184 /* Add room for ICV */ 184 /* Add room for ICV */
185 skb_put(skb, WEP_ICV_LEN); 185 skb_put(skb, WEP_ICV_LEN);
@@ -251,10 +251,10 @@ int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb,
251 251
252 keyidx = skb->data[hdrlen + 3] >> 6; 252 keyidx = skb->data[hdrlen + 3] >> 6;
253 253
254 if (!key || keyidx != key->keyidx || key->alg != ALG_WEP) 254 if (!key || keyidx != key->conf.keyidx || key->conf.alg != ALG_WEP)
255 return -1; 255 return -1;
256 256
257 klen = 3 + key->keylen; 257 klen = 3 + key->conf.keylen;
258 258
259 rc4key = kmalloc(klen, GFP_ATOMIC); 259 rc4key = kmalloc(klen, GFP_ATOMIC);
260 if (!rc4key) 260 if (!rc4key)
@@ -264,7 +264,7 @@ int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb,
264 memcpy(rc4key, skb->data + hdrlen, 3); 264 memcpy(rc4key, skb->data + hdrlen, 3);
265 265
266 /* Copy rest of the WEP key (the secret part) */ 266 /* Copy rest of the WEP key (the secret part) */
267 memcpy(rc4key + 3, key->key, key->keylen); 267 memcpy(rc4key + 3, key->conf.key, key->conf.keylen);
268 268
269 if (ieee80211_wep_decrypt_data(local->wep_rx_tfm, rc4key, klen, 269 if (ieee80211_wep_decrypt_data(local->wep_rx_tfm, rc4key, klen,
270 skb->data + hdrlen + WEP_IV_LEN, 270 skb->data + hdrlen + WEP_IV_LEN,
@@ -321,7 +321,7 @@ u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key)
321 ivpos = skb->data + hdrlen; 321 ivpos = skb->data + hdrlen;
322 iv = (ivpos[0] << 16) | (ivpos[1] << 8) | ivpos[2]; 322 iv = (ivpos[0] << 16) | (ivpos[1] << 8) | ivpos[2];
323 323
324 if (ieee80211_wep_weak_iv(iv, key->keylen)) 324 if (ieee80211_wep_weak_iv(iv, key->conf.keylen))
325 return ivpos; 325 return ivpos;
326 326
327 return NULL; 327 return NULL;