aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/wep.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac80211/wep.c')
-rw-r--r--net/mac80211/wep.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c
index f0e2d3ecb5c4..7bbb98e846a3 100644
--- a/net/mac80211/wep.c
+++ b/net/mac80211/wep.c
@@ -49,17 +49,19 @@ void ieee80211_wep_free(struct ieee80211_local *local)
49 crypto_free_blkcipher(local->wep_rx_tfm); 49 crypto_free_blkcipher(local->wep_rx_tfm);
50} 50}
51 51
52static inline int ieee80211_wep_weak_iv(u32 iv, int keylen) 52static inline bool ieee80211_wep_weak_iv(u32 iv, int keylen)
53{ 53{
54 /* Fluhrer, Mantin, and Shamir have reported weaknesses in the 54 /*
55 * Fluhrer, Mantin, and Shamir have reported weaknesses in the
55 * key scheduling algorithm of RC4. At least IVs (KeyByte + 3, 56 * key scheduling algorithm of RC4. At least IVs (KeyByte + 3,
56 * 0xff, N) can be used to speedup attacks, so avoid using them. */ 57 * 0xff, N) can be used to speedup attacks, so avoid using them.
58 */
57 if ((iv & 0xff00) == 0xff00) { 59 if ((iv & 0xff00) == 0xff00) {
58 u8 B = (iv >> 16) & 0xff; 60 u8 B = (iv >> 16) & 0xff;
59 if (B >= 3 && B < 3 + keylen) 61 if (B >= 3 && B < 3 + keylen)
60 return 1; 62 return true;
61 } 63 }
62 return 0; 64 return false;
63} 65}
64 66
65 67
@@ -268,7 +270,7 @@ int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb,
268} 270}
269 271
270 272
271u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key) 273bool ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key)
272{ 274{
273 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 275 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
274 unsigned int hdrlen; 276 unsigned int hdrlen;
@@ -276,16 +278,13 @@ u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key)
276 u32 iv; 278 u32 iv;
277 279
278 if (!ieee80211_has_protected(hdr->frame_control)) 280 if (!ieee80211_has_protected(hdr->frame_control))
279 return NULL; 281 return false;
280 282
281 hdrlen = ieee80211_hdrlen(hdr->frame_control); 283 hdrlen = ieee80211_hdrlen(hdr->frame_control);
282 ivpos = skb->data + hdrlen; 284 ivpos = skb->data + hdrlen;
283 iv = (ivpos[0] << 16) | (ivpos[1] << 8) | ivpos[2]; 285 iv = (ivpos[0] << 16) | (ivpos[1] << 8) | ivpos[2];
284 286
285 if (ieee80211_wep_weak_iv(iv, key->conf.keylen)) 287 return ieee80211_wep_weak_iv(iv, key->conf.keylen);
286 return ivpos;
287
288 return NULL;
289} 288}
290 289
291ieee80211_rx_result 290ieee80211_rx_result
@@ -329,6 +328,8 @@ static int wep_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
329ieee80211_tx_result 328ieee80211_tx_result
330ieee80211_crypto_wep_encrypt(struct ieee80211_tx_data *tx) 329ieee80211_crypto_wep_encrypt(struct ieee80211_tx_data *tx)
331{ 330{
331 int i;
332
332 ieee80211_tx_set_protected(tx); 333 ieee80211_tx_set_protected(tx);
333 334
334 if (wep_encrypt_skb(tx, tx->skb) < 0) { 335 if (wep_encrypt_skb(tx, tx->skb) < 0) {
@@ -337,9 +338,8 @@ ieee80211_crypto_wep_encrypt(struct ieee80211_tx_data *tx)
337 } 338 }
338 339
339 if (tx->extra_frag) { 340 if (tx->extra_frag) {
340 int i;
341 for (i = 0; i < tx->num_extra_frag; i++) { 341 for (i = 0; i < tx->num_extra_frag; i++) {
342 if (wep_encrypt_skb(tx, tx->extra_frag[i]) < 0) { 342 if (wep_encrypt_skb(tx, tx->extra_frag[i])) {
343 I802_DEBUG_INC(tx->local-> 343 I802_DEBUG_INC(tx->local->
344 tx_handlers_drop_wep); 344 tx_handlers_drop_wep);
345 return TX_DROP; 345 return TX_DROP;