diff options
author | Johannes Berg <johannes.berg@intel.com> | 2012-03-12 08:49:13 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-03-13 14:54:16 -0400 |
commit | 617bbde878604adfcd557fc2a8952f77ab4ebd95 (patch) | |
tree | aa98cf7d59427f9d0fb06f33b26e1d096bcb8e6f | |
parent | 6b6fa5868eec26bdc6a83543cebb8cf832a2645a (diff) |
mac80211: move RX WEP weak IV counting
This is better done inside the WEP decrypt
function where it doesn't have to check all
the conditions any more since they've been
tested already.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | net/mac80211/rx.c | 7 | ||||
-rw-r--r-- | net/mac80211/wep.c | 10 | ||||
-rw-r--r-- | net/mac80211/wep.h | 1 |
3 files changed, 6 insertions, 12 deletions
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 5f6e32ca0858..b38da13e2a88 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -1070,13 +1070,6 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) | |||
1070 | switch (rx->key->conf.cipher) { | 1070 | switch (rx->key->conf.cipher) { |
1071 | case WLAN_CIPHER_SUITE_WEP40: | 1071 | case WLAN_CIPHER_SUITE_WEP40: |
1072 | case WLAN_CIPHER_SUITE_WEP104: | 1072 | case WLAN_CIPHER_SUITE_WEP104: |
1073 | /* Check for weak IVs if possible */ | ||
1074 | if (rx->sta && ieee80211_is_data(fc) && | ||
1075 | (!(status->flag & RX_FLAG_IV_STRIPPED) || | ||
1076 | !(status->flag & RX_FLAG_DECRYPTED)) && | ||
1077 | ieee80211_wep_is_weak_iv(rx->skb, rx->key)) | ||
1078 | rx->sta->wep_weak_iv_count++; | ||
1079 | |||
1080 | result = ieee80211_crypto_wep_decrypt(rx); | 1073 | result = ieee80211_crypto_wep_decrypt(rx); |
1081 | break; | 1074 | break; |
1082 | case WLAN_CIPHER_SUITE_TKIP: | 1075 | case WLAN_CIPHER_SUITE_TKIP: |
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c index 68ad351479df..5cd87ba11bb7 100644 --- a/net/mac80211/wep.c +++ b/net/mac80211/wep.c | |||
@@ -263,16 +263,14 @@ static int ieee80211_wep_decrypt(struct ieee80211_local *local, | |||
263 | } | 263 | } |
264 | 264 | ||
265 | 265 | ||
266 | bool ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key) | 266 | static bool ieee80211_wep_is_weak_iv(struct sk_buff *skb, |
267 | struct ieee80211_key *key) | ||
267 | { | 268 | { |
268 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | 269 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
269 | unsigned int hdrlen; | 270 | unsigned int hdrlen; |
270 | u8 *ivpos; | 271 | u8 *ivpos; |
271 | u32 iv; | 272 | u32 iv; |
272 | 273 | ||
273 | if (!ieee80211_has_protected(hdr->frame_control)) | ||
274 | return false; | ||
275 | |||
276 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | 274 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
277 | ivpos = skb->data + hdrlen; | 275 | ivpos = skb->data + hdrlen; |
278 | iv = (ivpos[0] << 16) | (ivpos[1] << 8) | ivpos[2]; | 276 | iv = (ivpos[0] << 16) | (ivpos[1] << 8) | ivpos[2]; |
@@ -292,9 +290,13 @@ ieee80211_crypto_wep_decrypt(struct ieee80211_rx_data *rx) | |||
292 | return RX_CONTINUE; | 290 | return RX_CONTINUE; |
293 | 291 | ||
294 | if (!(status->flag & RX_FLAG_DECRYPTED)) { | 292 | if (!(status->flag & RX_FLAG_DECRYPTED)) { |
293 | if (rx->sta && ieee80211_wep_is_weak_iv(rx->skb, rx->key)) | ||
294 | rx->sta->wep_weak_iv_count++; | ||
295 | if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key)) | 295 | if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key)) |
296 | return RX_DROP_UNUSABLE; | 296 | return RX_DROP_UNUSABLE; |
297 | } else if (!(status->flag & RX_FLAG_IV_STRIPPED)) { | 297 | } else if (!(status->flag & RX_FLAG_IV_STRIPPED)) { |
298 | if (rx->sta && ieee80211_wep_is_weak_iv(rx->skb, rx->key)) | ||
299 | rx->sta->wep_weak_iv_count++; | ||
298 | ieee80211_wep_remove_iv(rx->local, rx->skb, rx->key); | 300 | ieee80211_wep_remove_iv(rx->local, rx->skb, rx->key); |
299 | /* remove ICV */ | 301 | /* remove ICV */ |
300 | skb_trim(rx->skb, rx->skb->len - WEP_ICV_LEN); | 302 | skb_trim(rx->skb, rx->skb->len - WEP_ICV_LEN); |
diff --git a/net/mac80211/wep.h b/net/mac80211/wep.h index 01e54840a628..9615749d1f65 100644 --- a/net/mac80211/wep.h +++ b/net/mac80211/wep.h | |||
@@ -25,7 +25,6 @@ int ieee80211_wep_encrypt(struct ieee80211_local *local, | |||
25 | const u8 *key, int keylen, int keyidx); | 25 | const u8 *key, int keylen, int keyidx); |
26 | int ieee80211_wep_decrypt_data(struct crypto_cipher *tfm, u8 *rc4key, | 26 | int ieee80211_wep_decrypt_data(struct crypto_cipher *tfm, u8 *rc4key, |
27 | size_t klen, u8 *data, size_t data_len); | 27 | size_t klen, u8 *data, size_t data_len); |
28 | bool ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key); | ||
29 | 28 | ||
30 | ieee80211_rx_result | 29 | ieee80211_rx_result |
31 | ieee80211_crypto_wep_decrypt(struct ieee80211_rx_data *rx); | 30 | ieee80211_crypto_wep_decrypt(struct ieee80211_rx_data *rx); |