aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/wpa.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac80211/wpa.c')
-rw-r--r--net/mac80211/wpa.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index 3a20b036ef4c..7aa63caf8d50 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -49,8 +49,7 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_tx_data *tx)
49 !(tx->flags & IEEE80211_TX_FRAGMENTED) && 49 !(tx->flags & IEEE80211_TX_FRAGMENTED) &&
50 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) && 50 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) &&
51 !wpa_test) { 51 !wpa_test) {
52 /* hwaccel - with no need for preallocated room for Michael MIC 52 /* hwaccel - with no need for preallocated room for MMIC */
53 */
54 return TX_CONTINUE; 53 return TX_CONTINUE;
55 } 54 }
56 55
@@ -67,8 +66,6 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_tx_data *tx)
67#else 66#else
68 authenticator = 1; 67 authenticator = 1;
69#endif 68#endif
70 /* At this point we know we're using ALG_TKIP. To get the MIC key
71 * we now will rely on the offset from the ieee80211_key_conf::key */
72 key_offset = authenticator ? 69 key_offset = authenticator ?
73 NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY : 70 NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY :
74 NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY; 71 NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY;
@@ -91,9 +88,7 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx)
91 struct sk_buff *skb = rx->skb; 88 struct sk_buff *skb = rx->skb;
92 int authenticator = 1, wpa_test = 0; 89 int authenticator = 1, wpa_test = 0;
93 90
94 /* 91 /* No way to verify the MIC if the hardware stripped it */
95 * No way to verify the MIC if the hardware stripped it
96 */
97 if (rx->status->flag & RX_FLAG_MMIC_STRIPPED) 92 if (rx->status->flag & RX_FLAG_MMIC_STRIPPED)
98 return RX_CONTINUE; 93 return RX_CONTINUE;
99 94
@@ -115,8 +110,6 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx)
115#else 110#else
116 authenticator = 1; 111 authenticator = 1;
117#endif 112#endif
118 /* At this point we know we're using ALG_TKIP. To get the MIC key
119 * we now will rely on the offset from the ieee80211_key_conf::key */
120 key_offset = authenticator ? 113 key_offset = authenticator ?
121 NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY : 114 NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY :
122 NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY; 115 NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY;
@@ -201,6 +194,7 @@ ieee80211_tx_result
201ieee80211_crypto_tkip_encrypt(struct ieee80211_tx_data *tx) 194ieee80211_crypto_tkip_encrypt(struct ieee80211_tx_data *tx)
202{ 195{
203 struct sk_buff *skb = tx->skb; 196 struct sk_buff *skb = tx->skb;
197 int i;
204 198
205 ieee80211_tx_set_protected(tx); 199 ieee80211_tx_set_protected(tx);
206 200
@@ -208,9 +202,8 @@ ieee80211_crypto_tkip_encrypt(struct ieee80211_tx_data *tx)
208 return TX_DROP; 202 return TX_DROP;
209 203
210 if (tx->extra_frag) { 204 if (tx->extra_frag) {
211 int i;
212 for (i = 0; i < tx->num_extra_frag; i++) { 205 for (i = 0; i < tx->num_extra_frag; i++) {
213 if (tkip_encrypt_skb(tx, tx->extra_frag[i]) < 0) 206 if (tkip_encrypt_skb(tx, tx->extra_frag[i]))
214 return TX_DROP; 207 return TX_DROP;
215 } 208 }
216 } 209 }
@@ -348,7 +341,7 @@ static inline void ccmp_pn2hdr(u8 *hdr, u8 *pn, int key_id)
348} 341}
349 342
350 343
351static inline int ccmp_hdr2pn(u8 *pn, u8 *hdr) 344static inline void ccmp_hdr2pn(u8 *pn, u8 *hdr)
352{ 345{
353 pn[0] = hdr[7]; 346 pn[0] = hdr[7];
354 pn[1] = hdr[6]; 347 pn[1] = hdr[6];
@@ -356,7 +349,6 @@ static inline int ccmp_hdr2pn(u8 *pn, u8 *hdr)
356 pn[3] = hdr[4]; 349 pn[3] = hdr[4];
357 pn[4] = hdr[1]; 350 pn[4] = hdr[1];
358 pn[5] = hdr[0]; 351 pn[5] = hdr[0];
359 return (hdr[3] >> 6) & 0x03;
360} 352}
361 353
362 354
@@ -371,7 +363,7 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
371 363
372 if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) && 364 if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) &&
373 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) { 365 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
374 /* hwaccel - with no need for preallocated room for CCMP " 366 /* hwaccel - with no need for preallocated room for CCMP
375 * header or MIC fields */ 367 * header or MIC fields */
376 info->control.hw_key = &tx->key->conf; 368 info->control.hw_key = &tx->key->conf;
377 return 0; 369 return 0;
@@ -424,6 +416,7 @@ ieee80211_tx_result
424ieee80211_crypto_ccmp_encrypt(struct ieee80211_tx_data *tx) 416ieee80211_crypto_ccmp_encrypt(struct ieee80211_tx_data *tx)
425{ 417{
426 struct sk_buff *skb = tx->skb; 418 struct sk_buff *skb = tx->skb;
419 int i;
427 420
428 ieee80211_tx_set_protected(tx); 421 ieee80211_tx_set_protected(tx);
429 422
@@ -431,9 +424,8 @@ ieee80211_crypto_ccmp_encrypt(struct ieee80211_tx_data *tx)
431 return TX_DROP; 424 return TX_DROP;
432 425
433 if (tx->extra_frag) { 426 if (tx->extra_frag) {
434 int i;
435 for (i = 0; i < tx->num_extra_frag; i++) { 427 for (i = 0; i < tx->num_extra_frag; i++) {
436 if (ccmp_encrypt_skb(tx, tx->extra_frag[i]) < 0) 428 if (ccmp_encrypt_skb(tx, tx->extra_frag[i]))
437 return TX_DROP; 429 return TX_DROP;
438 } 430 }
439 } 431 }
@@ -465,7 +457,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx)
465 (rx->status->flag & RX_FLAG_IV_STRIPPED)) 457 (rx->status->flag & RX_FLAG_IV_STRIPPED))
466 return RX_CONTINUE; 458 return RX_CONTINUE;
467 459
468 (void) ccmp_hdr2pn(pn, skb->data + hdrlen); 460 ccmp_hdr2pn(pn, skb->data + hdrlen);
469 461
470 if (memcmp(pn, key->u.ccmp.rx_pn[rx->queue], CCMP_PN_LEN) <= 0) { 462 if (memcmp(pn, key->u.ccmp.rx_pn[rx->queue], CCMP_PN_LEN) <= 0) {
471 key->u.ccmp.replays++; 463 key->u.ccmp.replays++;
@@ -480,9 +472,8 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx)
480 key->u.ccmp.tfm, key->u.ccmp.rx_crypto_buf, 472 key->u.ccmp.tfm, key->u.ccmp.rx_crypto_buf,
481 skb->data + hdrlen + CCMP_HDR_LEN, data_len, 473 skb->data + hdrlen + CCMP_HDR_LEN, data_len,
482 skb->data + skb->len - CCMP_MIC_LEN, 474 skb->data + skb->len - CCMP_MIC_LEN,
483 skb->data + hdrlen + CCMP_HDR_LEN)) { 475 skb->data + hdrlen + CCMP_HDR_LEN))
484 return RX_DROP_UNUSABLE; 476 return RX_DROP_UNUSABLE;
485 }
486 } 477 }
487 478
488 memcpy(key->u.ccmp.rx_pn[rx->queue], pn, CCMP_PN_LEN); 479 memcpy(key->u.ccmp.rx_pn[rx->queue], pn, CCMP_PN_LEN);