diff options
Diffstat (limited to 'net/ieee80211/ieee80211_crypt_tkip.c')
-rw-r--r-- | net/ieee80211/ieee80211_crypt_tkip.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/net/ieee80211/ieee80211_crypt_tkip.c b/net/ieee80211/ieee80211_crypt_tkip.c index dca380e57454..0c495f07e718 100644 --- a/net/ieee80211/ieee80211_crypt_tkip.c +++ b/net/ieee80211/ieee80211_crypt_tkip.c | |||
@@ -59,9 +59,11 @@ struct ieee80211_tkip_data { | |||
59 | 59 | ||
60 | /* scratch buffers for virt_to_page() (crypto API) */ | 60 | /* scratch buffers for virt_to_page() (crypto API) */ |
61 | u8 rx_hdr[16], tx_hdr[16]; | 61 | u8 rx_hdr[16], tx_hdr[16]; |
62 | |||
63 | struct ieee80211_device *ieee; | ||
62 | }; | 64 | }; |
63 | 65 | ||
64 | static void *ieee80211_tkip_init(int key_idx) | 66 | static void *ieee80211_tkip_init(struct ieee80211_device *ieee, int key_idx) |
65 | { | 67 | { |
66 | struct ieee80211_tkip_data *priv; | 68 | struct ieee80211_tkip_data *priv; |
67 | 69 | ||
@@ -69,6 +71,9 @@ static void *ieee80211_tkip_init(int key_idx) | |||
69 | if (priv == NULL) | 71 | if (priv == NULL) |
70 | goto fail; | 72 | goto fail; |
71 | memset(priv, 0, sizeof(*priv)); | 73 | memset(priv, 0, sizeof(*priv)); |
74 | |||
75 | priv->ieee = ieee; | ||
76 | |||
72 | priv->key_idx = key_idx; | 77 | priv->key_idx = key_idx; |
73 | 78 | ||
74 | priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0); | 79 | priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0); |
@@ -264,11 +269,21 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
264 | u32 crc; | 269 | u32 crc; |
265 | struct scatterlist sg; | 270 | struct scatterlist sg; |
266 | 271 | ||
272 | hdr = (struct ieee80211_hdr *)skb->data; | ||
273 | |||
274 | if (tkey->ieee->tkip_countermeasures) { | ||
275 | if (net_ratelimit()) { | ||
276 | printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " | ||
277 | "TX packet to " MAC_FMT "\n", | ||
278 | tkey->ieee->dev->name, MAC_ARG(hdr->addr1)); | ||
279 | } | ||
280 | return -1; | ||
281 | } | ||
282 | |||
267 | if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 || | 283 | if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 || |
268 | skb->len < hdr_len) | 284 | skb->len < hdr_len) |
269 | return -1; | 285 | return -1; |
270 | 286 | ||
271 | hdr = (struct ieee80211_hdr *)skb->data; | ||
272 | if (!tkey->tx_phase1_done) { | 287 | if (!tkey->tx_phase1_done) { |
273 | tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, | 288 | tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, |
274 | tkey->tx_iv32); | 289 | tkey->tx_iv32); |
@@ -325,10 +340,20 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
325 | struct scatterlist sg; | 340 | struct scatterlist sg; |
326 | int plen; | 341 | int plen; |
327 | 342 | ||
343 | hdr = (struct ieee80211_hdr *)skb->data; | ||
344 | |||
345 | if (tkey->ieee->tkip_countermeasures) { | ||
346 | if (net_ratelimit()) { | ||
347 | printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " | ||
348 | "received packet from " MAC_FMT "\n", | ||
349 | tkey->ieee->dev->name, MAC_ARG(hdr->addr2)); | ||
350 | } | ||
351 | return -1; | ||
352 | } | ||
353 | |||
328 | if (skb->len < hdr_len + 8 + 4) | 354 | if (skb->len < hdr_len + 8 + 4) |
329 | return -1; | 355 | return -1; |
330 | 356 | ||
331 | hdr = (struct ieee80211_hdr *)skb->data; | ||
332 | pos = skb->data + hdr_len; | 357 | pos = skb->data + hdr_len; |
333 | keyidx = pos[3]; | 358 | keyidx = pos[3]; |
334 | if (!(keyidx & (1 << 5))) { | 359 | if (!(keyidx & (1 << 5))) { |