diff options
-rw-r--r-- | drivers/net/wireless/iwlegacy/commands.h | 8 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/dvm/commands.h | 8 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/pcie/tx.c | 6 | ||||
-rw-r--r-- | include/linux/ieee80211.h | 9 | ||||
-rw-r--r-- | net/mac80211/aes_ccm.c | 6 | ||||
-rw-r--r-- | net/mac80211/key.c | 24 | ||||
-rw-r--r-- | net/mac80211/key.h | 15 | ||||
-rw-r--r-- | net/mac80211/rx.c | 12 | ||||
-rw-r--r-- | net/mac80211/wep.c | 48 | ||||
-rw-r--r-- | net/mac80211/wpa.c | 68 |
10 files changed, 96 insertions, 108 deletions
diff --git a/drivers/net/wireless/iwlegacy/commands.h b/drivers/net/wireless/iwlegacy/commands.h index 3b6c99400892..048421511988 100644 --- a/drivers/net/wireless/iwlegacy/commands.h +++ b/drivers/net/wireless/iwlegacy/commands.h | |||
@@ -1348,14 +1348,6 @@ struct il_rx_mpdu_res_start { | |||
1348 | #define TX_CMD_SEC_KEY128 0x08 | 1348 | #define TX_CMD_SEC_KEY128 0x08 |
1349 | 1349 | ||
1350 | /* | 1350 | /* |
1351 | * security overhead sizes | ||
1352 | */ | ||
1353 | #define WEP_IV_LEN 4 | ||
1354 | #define WEP_ICV_LEN 4 | ||
1355 | #define CCMP_MIC_LEN 8 | ||
1356 | #define TKIP_ICV_LEN 4 | ||
1357 | |||
1358 | /* | ||
1359 | * C_TX = 0x1c (command) | 1351 | * C_TX = 0x1c (command) |
1360 | */ | 1352 | */ |
1361 | 1353 | ||
diff --git a/drivers/net/wireless/iwlwifi/dvm/commands.h b/drivers/net/wireless/iwlwifi/dvm/commands.h index 95ca026ecc9d..174b0f169497 100644 --- a/drivers/net/wireless/iwlwifi/dvm/commands.h +++ b/drivers/net/wireless/iwlwifi/dvm/commands.h | |||
@@ -1225,14 +1225,6 @@ struct iwl_rx_mpdu_res_start { | |||
1225 | #define TX_CMD_SEC_KEY128 0x08 | 1225 | #define TX_CMD_SEC_KEY128 0x08 |
1226 | 1226 | ||
1227 | /* | 1227 | /* |
1228 | * security overhead sizes | ||
1229 | */ | ||
1230 | #define WEP_IV_LEN 4 | ||
1231 | #define WEP_ICV_LEN 4 | ||
1232 | #define CCMP_MIC_LEN 8 | ||
1233 | #define TKIP_ICV_LEN 4 | ||
1234 | |||
1235 | /* | ||
1236 | * REPLY_TX = 0x1c (command) | 1228 | * REPLY_TX = 0x1c (command) |
1237 | */ | 1229 | */ |
1238 | 1230 | ||
diff --git a/drivers/net/wireless/iwlwifi/pcie/tx.c b/drivers/net/wireless/iwlwifi/pcie/tx.c index c5e30294c5ac..2878ee99a668 100644 --- a/drivers/net/wireless/iwlwifi/pcie/tx.c +++ b/drivers/net/wireless/iwlwifi/pcie/tx.c | |||
@@ -224,13 +224,13 @@ static void iwl_pcie_txq_update_byte_cnt_tbl(struct iwl_trans *trans, | |||
224 | 224 | ||
225 | switch (sec_ctl & TX_CMD_SEC_MSK) { | 225 | switch (sec_ctl & TX_CMD_SEC_MSK) { |
226 | case TX_CMD_SEC_CCM: | 226 | case TX_CMD_SEC_CCM: |
227 | len += CCMP_MIC_LEN; | 227 | len += IEEE80211_CCMP_MIC_LEN; |
228 | break; | 228 | break; |
229 | case TX_CMD_SEC_TKIP: | 229 | case TX_CMD_SEC_TKIP: |
230 | len += TKIP_ICV_LEN; | 230 | len += IEEE80211_TKIP_ICV_LEN; |
231 | break; | 231 | break; |
232 | case TX_CMD_SEC_WEP: | 232 | case TX_CMD_SEC_WEP: |
233 | len += WEP_IV_LEN + WEP_ICV_LEN; | 233 | len += IEEE80211_WEP_IV_LEN + IEEE80211_WEP_ICV_LEN; |
234 | break; | 234 | break; |
235 | } | 235 | } |
236 | 236 | ||
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index 06b0ed0154a4..d826e5a84af0 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h | |||
@@ -1829,6 +1829,15 @@ enum ieee80211_key_len { | |||
1829 | WLAN_KEY_LEN_AES_CMAC = 16, | 1829 | WLAN_KEY_LEN_AES_CMAC = 16, |
1830 | }; | 1830 | }; |
1831 | 1831 | ||
1832 | #define IEEE80211_WEP_IV_LEN 4 | ||
1833 | #define IEEE80211_WEP_ICV_LEN 4 | ||
1834 | #define IEEE80211_CCMP_HDR_LEN 8 | ||
1835 | #define IEEE80211_CCMP_MIC_LEN 8 | ||
1836 | #define IEEE80211_CCMP_PN_LEN 6 | ||
1837 | #define IEEE80211_TKIP_IV_LEN 8 | ||
1838 | #define IEEE80211_TKIP_ICV_LEN 4 | ||
1839 | #define IEEE80211_CMAC_PN_LEN 6 | ||
1840 | |||
1832 | /* Public action codes */ | 1841 | /* Public action codes */ |
1833 | enum ieee80211_pub_actioncode { | 1842 | enum ieee80211_pub_actioncode { |
1834 | WLAN_PUB_ACTION_EXT_CHANSW_ANN = 4, | 1843 | WLAN_PUB_ACTION_EXT_CHANSW_ANN = 4, |
diff --git a/net/mac80211/aes_ccm.c b/net/mac80211/aes_ccm.c index 0785e95c9924..be7614b9ed27 100644 --- a/net/mac80211/aes_ccm.c +++ b/net/mac80211/aes_ccm.c | |||
@@ -85,7 +85,7 @@ void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *scratch, | |||
85 | *cpos++ = *pos++ ^ e[i]; | 85 | *cpos++ = *pos++ ^ e[i]; |
86 | } | 86 | } |
87 | 87 | ||
88 | for (i = 0; i < CCMP_MIC_LEN; i++) | 88 | for (i = 0; i < IEEE80211_CCMP_MIC_LEN; i++) |
89 | mic[i] = b[i] ^ s_0[i]; | 89 | mic[i] = b[i] ^ s_0[i]; |
90 | } | 90 | } |
91 | 91 | ||
@@ -123,7 +123,7 @@ int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *scratch, | |||
123 | crypto_cipher_encrypt_one(tfm, a, a); | 123 | crypto_cipher_encrypt_one(tfm, a, a); |
124 | } | 124 | } |
125 | 125 | ||
126 | for (i = 0; i < CCMP_MIC_LEN; i++) { | 126 | for (i = 0; i < IEEE80211_CCMP_MIC_LEN; i++) { |
127 | if ((mic[i] ^ s_0[i]) != a[i]) | 127 | if ((mic[i] ^ s_0[i]) != a[i]) |
128 | return -1; | 128 | return -1; |
129 | } | 129 | } |
@@ -138,7 +138,7 @@ struct crypto_cipher *ieee80211_aes_key_setup_encrypt(const u8 key[]) | |||
138 | 138 | ||
139 | tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); | 139 | tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); |
140 | if (!IS_ERR(tfm)) | 140 | if (!IS_ERR(tfm)) |
141 | crypto_cipher_setkey(tfm, key, ALG_CCMP_KEY_LEN); | 141 | crypto_cipher_setkey(tfm, key, WLAN_KEY_LEN_CCMP); |
142 | 142 | ||
143 | return tfm; | 143 | return tfm; |
144 | } | 144 | } |
diff --git a/net/mac80211/key.c b/net/mac80211/key.c index 67059b88fea5..e39cc91d0cf1 100644 --- a/net/mac80211/key.c +++ b/net/mac80211/key.c | |||
@@ -335,12 +335,12 @@ struct ieee80211_key *ieee80211_key_alloc(u32 cipher, int idx, size_t key_len, | |||
335 | switch (cipher) { | 335 | switch (cipher) { |
336 | case WLAN_CIPHER_SUITE_WEP40: | 336 | case WLAN_CIPHER_SUITE_WEP40: |
337 | case WLAN_CIPHER_SUITE_WEP104: | 337 | case WLAN_CIPHER_SUITE_WEP104: |
338 | key->conf.iv_len = WEP_IV_LEN; | 338 | key->conf.iv_len = IEEE80211_WEP_IV_LEN; |
339 | key->conf.icv_len = WEP_ICV_LEN; | 339 | key->conf.icv_len = IEEE80211_WEP_ICV_LEN; |
340 | break; | 340 | break; |
341 | case WLAN_CIPHER_SUITE_TKIP: | 341 | case WLAN_CIPHER_SUITE_TKIP: |
342 | key->conf.iv_len = TKIP_IV_LEN; | 342 | key->conf.iv_len = IEEE80211_TKIP_IV_LEN; |
343 | key->conf.icv_len = TKIP_ICV_LEN; | 343 | key->conf.icv_len = IEEE80211_TKIP_ICV_LEN; |
344 | if (seq) { | 344 | if (seq) { |
345 | for (i = 0; i < IEEE80211_NUM_TIDS; i++) { | 345 | for (i = 0; i < IEEE80211_NUM_TIDS; i++) { |
346 | key->u.tkip.rx[i].iv32 = | 346 | key->u.tkip.rx[i].iv32 = |
@@ -352,13 +352,13 @@ struct ieee80211_key *ieee80211_key_alloc(u32 cipher, int idx, size_t key_len, | |||
352 | spin_lock_init(&key->u.tkip.txlock); | 352 | spin_lock_init(&key->u.tkip.txlock); |
353 | break; | 353 | break; |
354 | case WLAN_CIPHER_SUITE_CCMP: | 354 | case WLAN_CIPHER_SUITE_CCMP: |
355 | key->conf.iv_len = CCMP_HDR_LEN; | 355 | key->conf.iv_len = IEEE80211_CCMP_HDR_LEN; |
356 | key->conf.icv_len = CCMP_MIC_LEN; | 356 | key->conf.icv_len = IEEE80211_CCMP_MIC_LEN; |
357 | if (seq) { | 357 | if (seq) { |
358 | for (i = 0; i < IEEE80211_NUM_TIDS + 1; i++) | 358 | for (i = 0; i < IEEE80211_NUM_TIDS + 1; i++) |
359 | for (j = 0; j < CCMP_PN_LEN; j++) | 359 | for (j = 0; j < IEEE80211_CCMP_PN_LEN; j++) |
360 | key->u.ccmp.rx_pn[i][j] = | 360 | key->u.ccmp.rx_pn[i][j] = |
361 | seq[CCMP_PN_LEN - j - 1]; | 361 | seq[IEEE80211_CCMP_PN_LEN - j - 1]; |
362 | } | 362 | } |
363 | /* | 363 | /* |
364 | * Initialize AES key state here as an optimization so that | 364 | * Initialize AES key state here as an optimization so that |
@@ -375,9 +375,9 @@ struct ieee80211_key *ieee80211_key_alloc(u32 cipher, int idx, size_t key_len, | |||
375 | key->conf.iv_len = 0; | 375 | key->conf.iv_len = 0; |
376 | key->conf.icv_len = sizeof(struct ieee80211_mmie); | 376 | key->conf.icv_len = sizeof(struct ieee80211_mmie); |
377 | if (seq) | 377 | if (seq) |
378 | for (j = 0; j < CMAC_PN_LEN; j++) | 378 | for (j = 0; j < IEEE80211_CMAC_PN_LEN; j++) |
379 | key->u.aes_cmac.rx_pn[j] = | 379 | key->u.aes_cmac.rx_pn[j] = |
380 | seq[CMAC_PN_LEN - j - 1]; | 380 | seq[IEEE80211_CMAC_PN_LEN - j - 1]; |
381 | /* | 381 | /* |
382 | * Initialize AES key state here as an optimization so that | 382 | * Initialize AES key state here as an optimization so that |
383 | * it does not need to be initialized for every packet. | 383 | * it does not need to be initialized for every packet. |
@@ -740,13 +740,13 @@ void ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf, | |||
740 | pn = key->u.ccmp.rx_pn[IEEE80211_NUM_TIDS]; | 740 | pn = key->u.ccmp.rx_pn[IEEE80211_NUM_TIDS]; |
741 | else | 741 | else |
742 | pn = key->u.ccmp.rx_pn[tid]; | 742 | pn = key->u.ccmp.rx_pn[tid]; |
743 | memcpy(seq->ccmp.pn, pn, CCMP_PN_LEN); | 743 | memcpy(seq->ccmp.pn, pn, IEEE80211_CCMP_PN_LEN); |
744 | break; | 744 | break; |
745 | case WLAN_CIPHER_SUITE_AES_CMAC: | 745 | case WLAN_CIPHER_SUITE_AES_CMAC: |
746 | if (WARN_ON(tid != 0)) | 746 | if (WARN_ON(tid != 0)) |
747 | return; | 747 | return; |
748 | pn = key->u.aes_cmac.rx_pn; | 748 | pn = key->u.aes_cmac.rx_pn; |
749 | memcpy(seq->aes_cmac.pn, pn, CMAC_PN_LEN); | 749 | memcpy(seq->aes_cmac.pn, pn, IEEE80211_CMAC_PN_LEN); |
750 | break; | 750 | break; |
751 | } | 751 | } |
752 | } | 752 | } |
diff --git a/net/mac80211/key.h b/net/mac80211/key.h index e8de3e6d7804..036d57e76a5e 100644 --- a/net/mac80211/key.h +++ b/net/mac80211/key.h | |||
@@ -19,17 +19,6 @@ | |||
19 | #define NUM_DEFAULT_KEYS 4 | 19 | #define NUM_DEFAULT_KEYS 4 |
20 | #define NUM_DEFAULT_MGMT_KEYS 2 | 20 | #define NUM_DEFAULT_MGMT_KEYS 2 |
21 | 21 | ||
22 | #define WEP_IV_LEN 4 | ||
23 | #define WEP_ICV_LEN 4 | ||
24 | #define ALG_CCMP_KEY_LEN 16 | ||
25 | #define CCMP_HDR_LEN 8 | ||
26 | #define CCMP_MIC_LEN 8 | ||
27 | #define CCMP_TK_LEN 16 | ||
28 | #define CCMP_PN_LEN 6 | ||
29 | #define TKIP_IV_LEN 8 | ||
30 | #define TKIP_ICV_LEN 4 | ||
31 | #define CMAC_PN_LEN 6 | ||
32 | |||
33 | struct ieee80211_local; | 22 | struct ieee80211_local; |
34 | struct ieee80211_sub_if_data; | 23 | struct ieee80211_sub_if_data; |
35 | struct sta_info; | 24 | struct sta_info; |
@@ -93,13 +82,13 @@ struct ieee80211_key { | |||
93 | * frames and the last counter is used with Robust | 82 | * frames and the last counter is used with Robust |
94 | * Management frames. | 83 | * Management frames. |
95 | */ | 84 | */ |
96 | u8 rx_pn[IEEE80211_NUM_TIDS + 1][CCMP_PN_LEN]; | 85 | u8 rx_pn[IEEE80211_NUM_TIDS + 1][IEEE80211_CCMP_PN_LEN]; |
97 | struct crypto_cipher *tfm; | 86 | struct crypto_cipher *tfm; |
98 | u32 replays; /* dot11RSNAStatsCCMPReplays */ | 87 | u32 replays; /* dot11RSNAStatsCCMPReplays */ |
99 | } ccmp; | 88 | } ccmp; |
100 | struct { | 89 | struct { |
101 | atomic64_t tx_pn; | 90 | atomic64_t tx_pn; |
102 | u8 rx_pn[CMAC_PN_LEN]; | 91 | u8 rx_pn[IEEE80211_CMAC_PN_LEN]; |
103 | struct crypto_cipher *tfm; | 92 | struct crypto_cipher *tfm; |
104 | u32 replays; /* dot11RSNAStatsCMACReplays */ | 93 | u32 replays; /* dot11RSNAStatsCMACReplays */ |
105 | u32 icverrors; /* dot11RSNAStatsCMACICVErrors */ | 94 | u32 icverrors; /* dot11RSNAStatsCMACICVErrors */ |
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 22e412b0767f..6e2c8c5236c4 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -1622,7 +1622,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) | |||
1622 | entry->ccmp = 1; | 1622 | entry->ccmp = 1; |
1623 | memcpy(entry->last_pn, | 1623 | memcpy(entry->last_pn, |
1624 | rx->key->u.ccmp.rx_pn[queue], | 1624 | rx->key->u.ccmp.rx_pn[queue], |
1625 | CCMP_PN_LEN); | 1625 | IEEE80211_CCMP_PN_LEN); |
1626 | } | 1626 | } |
1627 | return RX_QUEUED; | 1627 | return RX_QUEUED; |
1628 | } | 1628 | } |
@@ -1641,21 +1641,21 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) | |||
1641 | * (IEEE 802.11i, 8.3.3.4.5) */ | 1641 | * (IEEE 802.11i, 8.3.3.4.5) */ |
1642 | if (entry->ccmp) { | 1642 | if (entry->ccmp) { |
1643 | int i; | 1643 | int i; |
1644 | u8 pn[CCMP_PN_LEN], *rpn; | 1644 | u8 pn[IEEE80211_CCMP_PN_LEN], *rpn; |
1645 | int queue; | 1645 | int queue; |
1646 | if (!rx->key || rx->key->conf.cipher != WLAN_CIPHER_SUITE_CCMP) | 1646 | if (!rx->key || rx->key->conf.cipher != WLAN_CIPHER_SUITE_CCMP) |
1647 | return RX_DROP_UNUSABLE; | 1647 | return RX_DROP_UNUSABLE; |
1648 | memcpy(pn, entry->last_pn, CCMP_PN_LEN); | 1648 | memcpy(pn, entry->last_pn, IEEE80211_CCMP_PN_LEN); |
1649 | for (i = CCMP_PN_LEN - 1; i >= 0; i--) { | 1649 | for (i = IEEE80211_CCMP_PN_LEN - 1; i >= 0; i--) { |
1650 | pn[i]++; | 1650 | pn[i]++; |
1651 | if (pn[i]) | 1651 | if (pn[i]) |
1652 | break; | 1652 | break; |
1653 | } | 1653 | } |
1654 | queue = rx->security_idx; | 1654 | queue = rx->security_idx; |
1655 | rpn = rx->key->u.ccmp.rx_pn[queue]; | 1655 | rpn = rx->key->u.ccmp.rx_pn[queue]; |
1656 | if (memcmp(pn, rpn, CCMP_PN_LEN)) | 1656 | if (memcmp(pn, rpn, IEEE80211_CCMP_PN_LEN)) |
1657 | return RX_DROP_UNUSABLE; | 1657 | return RX_DROP_UNUSABLE; |
1658 | memcpy(entry->last_pn, pn, CCMP_PN_LEN); | 1658 | memcpy(entry->last_pn, pn, IEEE80211_CCMP_PN_LEN); |
1659 | } | 1659 | } |
1660 | 1660 | ||
1661 | skb_pull(rx->skb, ieee80211_hdrlen(fc)); | 1661 | skb_pull(rx->skb, ieee80211_hdrlen(fc)); |
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c index c04d401dae92..6ee2b5863572 100644 --- a/net/mac80211/wep.c +++ b/net/mac80211/wep.c | |||
@@ -28,7 +28,7 @@ | |||
28 | int ieee80211_wep_init(struct ieee80211_local *local) | 28 | int ieee80211_wep_init(struct ieee80211_local *local) |
29 | { | 29 | { |
30 | /* start WEP IV from a random value */ | 30 | /* start WEP IV from a random value */ |
31 | get_random_bytes(&local->wep_iv, WEP_IV_LEN); | 31 | get_random_bytes(&local->wep_iv, IEEE80211_WEP_IV_LEN); |
32 | 32 | ||
33 | local->wep_tx_tfm = crypto_alloc_cipher("arc4", 0, CRYPTO_ALG_ASYNC); | 33 | local->wep_tx_tfm = crypto_alloc_cipher("arc4", 0, CRYPTO_ALG_ASYNC); |
34 | if (IS_ERR(local->wep_tx_tfm)) { | 34 | if (IS_ERR(local->wep_tx_tfm)) { |
@@ -98,20 +98,21 @@ static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local, | |||
98 | 98 | ||
99 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); | 99 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); |
100 | 100 | ||
101 | if (WARN_ON(skb_tailroom(skb) < WEP_ICV_LEN || | 101 | if (WARN_ON(skb_tailroom(skb) < IEEE80211_WEP_ICV_LEN || |
102 | skb_headroom(skb) < WEP_IV_LEN)) | 102 | skb_headroom(skb) < IEEE80211_WEP_IV_LEN)) |
103 | return NULL; | 103 | return NULL; |
104 | 104 | ||
105 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | 105 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
106 | newhdr = skb_push(skb, WEP_IV_LEN); | 106 | newhdr = skb_push(skb, IEEE80211_WEP_IV_LEN); |
107 | memmove(newhdr, newhdr + WEP_IV_LEN, hdrlen); | 107 | memmove(newhdr, newhdr + IEEE80211_WEP_IV_LEN, hdrlen); |
108 | 108 | ||
109 | /* the HW only needs room for the IV, but not the actual IV */ | 109 | /* the HW only needs room for the IV, but not the actual IV */ |
110 | if (info->control.hw_key && | 110 | if (info->control.hw_key && |
111 | (info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) | 111 | (info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) |
112 | return newhdr + hdrlen; | 112 | return newhdr + hdrlen; |
113 | 113 | ||
114 | skb_set_network_header(skb, skb_network_offset(skb) + WEP_IV_LEN); | 114 | skb_set_network_header(skb, skb_network_offset(skb) + |
115 | IEEE80211_WEP_IV_LEN); | ||
115 | ieee80211_wep_get_iv(local, keylen, keyidx, newhdr + hdrlen); | 116 | ieee80211_wep_get_iv(local, keylen, keyidx, newhdr + hdrlen); |
116 | return newhdr + hdrlen; | 117 | return newhdr + hdrlen; |
117 | } | 118 | } |
@@ -125,8 +126,8 @@ static void ieee80211_wep_remove_iv(struct ieee80211_local *local, | |||
125 | unsigned int hdrlen; | 126 | unsigned int hdrlen; |
126 | 127 | ||
127 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | 128 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
128 | memmove(skb->data + WEP_IV_LEN, skb->data, hdrlen); | 129 | memmove(skb->data + IEEE80211_WEP_IV_LEN, skb->data, hdrlen); |
129 | skb_pull(skb, WEP_IV_LEN); | 130 | skb_pull(skb, IEEE80211_WEP_IV_LEN); |
130 | } | 131 | } |
131 | 132 | ||
132 | 133 | ||
@@ -146,7 +147,7 @@ int ieee80211_wep_encrypt_data(struct crypto_cipher *tfm, u8 *rc4key, | |||
146 | put_unaligned(icv, (__le32 *)(data + data_len)); | 147 | put_unaligned(icv, (__le32 *)(data + data_len)); |
147 | 148 | ||
148 | crypto_cipher_setkey(tfm, rc4key, klen); | 149 | crypto_cipher_setkey(tfm, rc4key, klen); |
149 | for (i = 0; i < data_len + WEP_ICV_LEN; i++) | 150 | for (i = 0; i < data_len + IEEE80211_WEP_ICV_LEN; i++) |
150 | crypto_cipher_encrypt_one(tfm, data + i, data + i); | 151 | crypto_cipher_encrypt_one(tfm, data + i, data + i); |
151 | 152 | ||
152 | return 0; | 153 | return 0; |
@@ -172,7 +173,7 @@ int ieee80211_wep_encrypt(struct ieee80211_local *local, | |||
172 | if (!iv) | 173 | if (!iv) |
173 | return -1; | 174 | return -1; |
174 | 175 | ||
175 | len = skb->len - (iv + WEP_IV_LEN - skb->data); | 176 | len = skb->len - (iv + IEEE80211_WEP_IV_LEN - skb->data); |
176 | 177 | ||
177 | /* Prepend 24-bit IV to RC4 key */ | 178 | /* Prepend 24-bit IV to RC4 key */ |
178 | memcpy(rc4key, iv, 3); | 179 | memcpy(rc4key, iv, 3); |
@@ -181,10 +182,10 @@ int ieee80211_wep_encrypt(struct ieee80211_local *local, | |||
181 | memcpy(rc4key + 3, key, keylen); | 182 | memcpy(rc4key + 3, key, keylen); |
182 | 183 | ||
183 | /* Add room for ICV */ | 184 | /* Add room for ICV */ |
184 | skb_put(skb, WEP_ICV_LEN); | 185 | skb_put(skb, IEEE80211_WEP_ICV_LEN); |
185 | 186 | ||
186 | return ieee80211_wep_encrypt_data(local->wep_tx_tfm, rc4key, keylen + 3, | 187 | return ieee80211_wep_encrypt_data(local->wep_tx_tfm, rc4key, keylen + 3, |
187 | iv + WEP_IV_LEN, len); | 188 | iv + IEEE80211_WEP_IV_LEN, len); |
188 | } | 189 | } |
189 | 190 | ||
190 | 191 | ||
@@ -201,11 +202,11 @@ int ieee80211_wep_decrypt_data(struct crypto_cipher *tfm, u8 *rc4key, | |||
201 | return -1; | 202 | return -1; |
202 | 203 | ||
203 | crypto_cipher_setkey(tfm, rc4key, klen); | 204 | crypto_cipher_setkey(tfm, rc4key, klen); |
204 | for (i = 0; i < data_len + WEP_ICV_LEN; i++) | 205 | for (i = 0; i < data_len + IEEE80211_WEP_ICV_LEN; i++) |
205 | crypto_cipher_decrypt_one(tfm, data + i, data + i); | 206 | crypto_cipher_decrypt_one(tfm, data + i, data + i); |
206 | 207 | ||
207 | crc = cpu_to_le32(~crc32_le(~0, data, data_len)); | 208 | crc = cpu_to_le32(~crc32_le(~0, data, data_len)); |
208 | if (memcmp(&crc, data + data_len, WEP_ICV_LEN) != 0) | 209 | if (memcmp(&crc, data + data_len, IEEE80211_WEP_ICV_LEN) != 0) |
209 | /* ICV mismatch */ | 210 | /* ICV mismatch */ |
210 | return -1; | 211 | return -1; |
211 | 212 | ||
@@ -237,10 +238,10 @@ static int ieee80211_wep_decrypt(struct ieee80211_local *local, | |||
237 | return -1; | 238 | return -1; |
238 | 239 | ||
239 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | 240 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
240 | if (skb->len < hdrlen + WEP_IV_LEN + WEP_ICV_LEN) | 241 | if (skb->len < hdrlen + IEEE80211_WEP_IV_LEN + IEEE80211_WEP_ICV_LEN) |
241 | return -1; | 242 | return -1; |
242 | 243 | ||
243 | len = skb->len - hdrlen - WEP_IV_LEN - WEP_ICV_LEN; | 244 | len = skb->len - hdrlen - IEEE80211_WEP_IV_LEN - IEEE80211_WEP_ICV_LEN; |
244 | 245 | ||
245 | keyidx = skb->data[hdrlen + 3] >> 6; | 246 | keyidx = skb->data[hdrlen + 3] >> 6; |
246 | 247 | ||
@@ -256,16 +257,16 @@ static int ieee80211_wep_decrypt(struct ieee80211_local *local, | |||
256 | memcpy(rc4key + 3, key->conf.key, key->conf.keylen); | 257 | memcpy(rc4key + 3, key->conf.key, key->conf.keylen); |
257 | 258 | ||
258 | if (ieee80211_wep_decrypt_data(local->wep_rx_tfm, rc4key, klen, | 259 | if (ieee80211_wep_decrypt_data(local->wep_rx_tfm, rc4key, klen, |
259 | skb->data + hdrlen + WEP_IV_LEN, | 260 | skb->data + hdrlen + |
260 | len)) | 261 | IEEE80211_WEP_IV_LEN, len)) |
261 | ret = -1; | 262 | ret = -1; |
262 | 263 | ||
263 | /* Trim ICV */ | 264 | /* Trim ICV */ |
264 | skb_trim(skb, skb->len - WEP_ICV_LEN); | 265 | skb_trim(skb, skb->len - IEEE80211_WEP_ICV_LEN); |
265 | 266 | ||
266 | /* Remove IV */ | 267 | /* Remove IV */ |
267 | memmove(skb->data + WEP_IV_LEN, skb->data, hdrlen); | 268 | memmove(skb->data + IEEE80211_WEP_IV_LEN, skb->data, hdrlen); |
268 | skb_pull(skb, WEP_IV_LEN); | 269 | skb_pull(skb, IEEE80211_WEP_IV_LEN); |
269 | 270 | ||
270 | return ret; | 271 | return ret; |
271 | } | 272 | } |
@@ -305,13 +306,14 @@ ieee80211_crypto_wep_decrypt(struct ieee80211_rx_data *rx) | |||
305 | if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key)) | 306 | if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key)) |
306 | return RX_DROP_UNUSABLE; | 307 | return RX_DROP_UNUSABLE; |
307 | } else if (!(status->flag & RX_FLAG_IV_STRIPPED)) { | 308 | } else if (!(status->flag & RX_FLAG_IV_STRIPPED)) { |
308 | if (!pskb_may_pull(rx->skb, ieee80211_hdrlen(fc) + WEP_IV_LEN)) | 309 | if (!pskb_may_pull(rx->skb, ieee80211_hdrlen(fc) + |
310 | IEEE80211_WEP_IV_LEN)) | ||
309 | return RX_DROP_UNUSABLE; | 311 | return RX_DROP_UNUSABLE; |
310 | if (rx->sta && ieee80211_wep_is_weak_iv(rx->skb, rx->key)) | 312 | if (rx->sta && ieee80211_wep_is_weak_iv(rx->skb, rx->key)) |
311 | rx->sta->wep_weak_iv_count++; | 313 | rx->sta->wep_weak_iv_count++; |
312 | ieee80211_wep_remove_iv(rx->local, rx->skb, rx->key); | 314 | ieee80211_wep_remove_iv(rx->local, rx->skb, rx->key); |
313 | /* remove ICV */ | 315 | /* remove ICV */ |
314 | if (pskb_trim(rx->skb, rx->skb->len - WEP_ICV_LEN)) | 316 | if (pskb_trim(rx->skb, rx->skb->len - IEEE80211_WEP_ICV_LEN)) |
315 | return RX_DROP_UNUSABLE; | 317 | return RX_DROP_UNUSABLE; |
316 | } | 318 | } |
317 | 319 | ||
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c index c7c6d644486f..c9edfcb7a13b 100644 --- a/net/mac80211/wpa.c +++ b/net/mac80211/wpa.c | |||
@@ -62,10 +62,10 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_tx_data *tx) | |||
62 | 62 | ||
63 | tail = MICHAEL_MIC_LEN; | 63 | tail = MICHAEL_MIC_LEN; |
64 | if (!info->control.hw_key) | 64 | if (!info->control.hw_key) |
65 | tail += TKIP_ICV_LEN; | 65 | tail += IEEE80211_TKIP_ICV_LEN; |
66 | 66 | ||
67 | if (WARN_ON(skb_tailroom(skb) < tail || | 67 | if (WARN_ON(skb_tailroom(skb) < tail || |
68 | skb_headroom(skb) < TKIP_IV_LEN)) | 68 | skb_headroom(skb) < IEEE80211_TKIP_IV_LEN)) |
69 | return TX_DROP; | 69 | return TX_DROP; |
70 | 70 | ||
71 | key = &tx->key->conf.key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY]; | 71 | key = &tx->key->conf.key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY]; |
@@ -198,15 +198,16 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) | |||
198 | if (info->control.hw_key) | 198 | if (info->control.hw_key) |
199 | tail = 0; | 199 | tail = 0; |
200 | else | 200 | else |
201 | tail = TKIP_ICV_LEN; | 201 | tail = IEEE80211_TKIP_ICV_LEN; |
202 | 202 | ||
203 | if (WARN_ON(skb_tailroom(skb) < tail || | 203 | if (WARN_ON(skb_tailroom(skb) < tail || |
204 | skb_headroom(skb) < TKIP_IV_LEN)) | 204 | skb_headroom(skb) < IEEE80211_TKIP_IV_LEN)) |
205 | return -1; | 205 | return -1; |
206 | 206 | ||
207 | pos = skb_push(skb, TKIP_IV_LEN); | 207 | pos = skb_push(skb, IEEE80211_TKIP_IV_LEN); |
208 | memmove(pos, pos + TKIP_IV_LEN, hdrlen); | 208 | memmove(pos, pos + IEEE80211_TKIP_IV_LEN, hdrlen); |
209 | skb_set_network_header(skb, skb_network_offset(skb) + TKIP_IV_LEN); | 209 | skb_set_network_header(skb, skb_network_offset(skb) + |
210 | IEEE80211_TKIP_IV_LEN); | ||
210 | pos += hdrlen; | 211 | pos += hdrlen; |
211 | 212 | ||
212 | /* the HW only needs room for the IV, but not the actual IV */ | 213 | /* the HW only needs room for the IV, but not the actual IV */ |
@@ -227,7 +228,7 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) | |||
227 | return 0; | 228 | return 0; |
228 | 229 | ||
229 | /* Add room for ICV */ | 230 | /* Add room for ICV */ |
230 | skb_put(skb, TKIP_ICV_LEN); | 231 | skb_put(skb, IEEE80211_TKIP_ICV_LEN); |
231 | 232 | ||
232 | return ieee80211_tkip_encrypt_data(tx->local->wep_tx_tfm, | 233 | return ieee80211_tkip_encrypt_data(tx->local->wep_tx_tfm, |
233 | key, skb, pos, len); | 234 | key, skb, pos, len); |
@@ -290,11 +291,11 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_rx_data *rx) | |||
290 | return RX_DROP_UNUSABLE; | 291 | return RX_DROP_UNUSABLE; |
291 | 292 | ||
292 | /* Trim ICV */ | 293 | /* Trim ICV */ |
293 | skb_trim(skb, skb->len - TKIP_ICV_LEN); | 294 | skb_trim(skb, skb->len - IEEE80211_TKIP_ICV_LEN); |
294 | 295 | ||
295 | /* Remove IV */ | 296 | /* Remove IV */ |
296 | memmove(skb->data + TKIP_IV_LEN, skb->data, hdrlen); | 297 | memmove(skb->data + IEEE80211_TKIP_IV_LEN, skb->data, hdrlen); |
297 | skb_pull(skb, TKIP_IV_LEN); | 298 | skb_pull(skb, IEEE80211_TKIP_IV_LEN); |
298 | 299 | ||
299 | return RX_CONTINUE; | 300 | return RX_CONTINUE; |
300 | } | 301 | } |
@@ -337,9 +338,9 @@ static void ccmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *scratch, | |||
337 | else | 338 | else |
338 | qos_tid = 0; | 339 | qos_tid = 0; |
339 | 340 | ||
340 | data_len = skb->len - hdrlen - CCMP_HDR_LEN; | 341 | data_len = skb->len - hdrlen - IEEE80211_CCMP_HDR_LEN; |
341 | if (encrypted) | 342 | if (encrypted) |
342 | data_len -= CCMP_MIC_LEN; | 343 | data_len -= IEEE80211_CCMP_MIC_LEN; |
343 | 344 | ||
344 | /* First block, b_0 */ | 345 | /* First block, b_0 */ |
345 | b_0[0] = 0x59; /* flags: Adata: 1, M: 011, L: 001 */ | 346 | b_0[0] = 0x59; /* flags: Adata: 1, M: 011, L: 001 */ |
@@ -348,7 +349,7 @@ static void ccmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *scratch, | |||
348 | */ | 349 | */ |
349 | b_0[1] = qos_tid | (mgmt << 4); | 350 | b_0[1] = qos_tid | (mgmt << 4); |
350 | memcpy(&b_0[2], hdr->addr2, ETH_ALEN); | 351 | memcpy(&b_0[2], hdr->addr2, ETH_ALEN); |
351 | memcpy(&b_0[8], pn, CCMP_PN_LEN); | 352 | memcpy(&b_0[8], pn, IEEE80211_CCMP_PN_LEN); |
352 | /* l(m) */ | 353 | /* l(m) */ |
353 | put_unaligned_be16(data_len, &b_0[14]); | 354 | put_unaligned_be16(data_len, &b_0[14]); |
354 | 355 | ||
@@ -424,15 +425,16 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) | |||
424 | if (info->control.hw_key) | 425 | if (info->control.hw_key) |
425 | tail = 0; | 426 | tail = 0; |
426 | else | 427 | else |
427 | tail = CCMP_MIC_LEN; | 428 | tail = IEEE80211_CCMP_MIC_LEN; |
428 | 429 | ||
429 | if (WARN_ON(skb_tailroom(skb) < tail || | 430 | if (WARN_ON(skb_tailroom(skb) < tail || |
430 | skb_headroom(skb) < CCMP_HDR_LEN)) | 431 | skb_headroom(skb) < IEEE80211_CCMP_HDR_LEN)) |
431 | return -1; | 432 | return -1; |
432 | 433 | ||
433 | pos = skb_push(skb, CCMP_HDR_LEN); | 434 | pos = skb_push(skb, IEEE80211_CCMP_HDR_LEN); |
434 | memmove(pos, pos + CCMP_HDR_LEN, hdrlen); | 435 | memmove(pos, pos + IEEE80211_CCMP_HDR_LEN, hdrlen); |
435 | skb_set_network_header(skb, skb_network_offset(skb) + CCMP_HDR_LEN); | 436 | skb_set_network_header(skb, skb_network_offset(skb) + |
437 | IEEE80211_CCMP_HDR_LEN); | ||
436 | 438 | ||
437 | /* the HW only needs room for the IV, but not the actual IV */ | 439 | /* the HW only needs room for the IV, but not the actual IV */ |
438 | if (info->control.hw_key && | 440 | if (info->control.hw_key && |
@@ -457,10 +459,10 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) | |||
457 | if (info->control.hw_key) | 459 | if (info->control.hw_key) |
458 | return 0; | 460 | return 0; |
459 | 461 | ||
460 | pos += CCMP_HDR_LEN; | 462 | pos += IEEE80211_CCMP_HDR_LEN; |
461 | ccmp_special_blocks(skb, pn, scratch, 0); | 463 | ccmp_special_blocks(skb, pn, scratch, 0); |
462 | ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, scratch, pos, len, | 464 | ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, scratch, pos, len, |
463 | pos, skb_put(skb, CCMP_MIC_LEN)); | 465 | pos, skb_put(skb, IEEE80211_CCMP_MIC_LEN)); |
464 | 466 | ||
465 | return 0; | 467 | return 0; |
466 | } | 468 | } |
@@ -490,7 +492,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx) | |||
490 | struct ieee80211_key *key = rx->key; | 492 | struct ieee80211_key *key = rx->key; |
491 | struct sk_buff *skb = rx->skb; | 493 | struct sk_buff *skb = rx->skb; |
492 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); | 494 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); |
493 | u8 pn[CCMP_PN_LEN]; | 495 | u8 pn[IEEE80211_CCMP_PN_LEN]; |
494 | int data_len; | 496 | int data_len; |
495 | int queue; | 497 | int queue; |
496 | 498 | ||
@@ -500,12 +502,13 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx) | |||
500 | !ieee80211_is_robust_mgmt_frame(hdr)) | 502 | !ieee80211_is_robust_mgmt_frame(hdr)) |
501 | return RX_CONTINUE; | 503 | return RX_CONTINUE; |
502 | 504 | ||
503 | data_len = skb->len - hdrlen - CCMP_HDR_LEN - CCMP_MIC_LEN; | 505 | data_len = skb->len - hdrlen - IEEE80211_CCMP_HDR_LEN - |
506 | IEEE80211_CCMP_MIC_LEN; | ||
504 | if (!rx->sta || data_len < 0) | 507 | if (!rx->sta || data_len < 0) |
505 | return RX_DROP_UNUSABLE; | 508 | return RX_DROP_UNUSABLE; |
506 | 509 | ||
507 | if (status->flag & RX_FLAG_DECRYPTED) { | 510 | if (status->flag & RX_FLAG_DECRYPTED) { |
508 | if (!pskb_may_pull(rx->skb, hdrlen + CCMP_HDR_LEN)) | 511 | if (!pskb_may_pull(rx->skb, hdrlen + IEEE80211_CCMP_HDR_LEN)) |
509 | return RX_DROP_UNUSABLE; | 512 | return RX_DROP_UNUSABLE; |
510 | } else { | 513 | } else { |
511 | if (skb_linearize(rx->skb)) | 514 | if (skb_linearize(rx->skb)) |
@@ -516,7 +519,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx) | |||
516 | 519 | ||
517 | queue = rx->security_idx; | 520 | queue = rx->security_idx; |
518 | 521 | ||
519 | if (memcmp(pn, key->u.ccmp.rx_pn[queue], CCMP_PN_LEN) <= 0) { | 522 | if (memcmp(pn, key->u.ccmp.rx_pn[queue], IEEE80211_CCMP_PN_LEN) <= 0) { |
520 | key->u.ccmp.replays++; | 523 | key->u.ccmp.replays++; |
521 | return RX_DROP_UNUSABLE; | 524 | return RX_DROP_UNUSABLE; |
522 | } | 525 | } |
@@ -528,19 +531,20 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx) | |||
528 | 531 | ||
529 | if (ieee80211_aes_ccm_decrypt( | 532 | if (ieee80211_aes_ccm_decrypt( |
530 | key->u.ccmp.tfm, scratch, | 533 | key->u.ccmp.tfm, scratch, |
531 | skb->data + hdrlen + CCMP_HDR_LEN, data_len, | 534 | skb->data + hdrlen + IEEE80211_CCMP_HDR_LEN, |
532 | skb->data + skb->len - CCMP_MIC_LEN, | 535 | data_len, |
533 | skb->data + hdrlen + CCMP_HDR_LEN)) | 536 | skb->data + skb->len - IEEE80211_CCMP_MIC_LEN, |
537 | skb->data + hdrlen + IEEE80211_CCMP_HDR_LEN)) | ||
534 | return RX_DROP_UNUSABLE; | 538 | return RX_DROP_UNUSABLE; |
535 | } | 539 | } |
536 | 540 | ||
537 | memcpy(key->u.ccmp.rx_pn[queue], pn, CCMP_PN_LEN); | 541 | memcpy(key->u.ccmp.rx_pn[queue], pn, IEEE80211_CCMP_PN_LEN); |
538 | 542 | ||
539 | /* Remove CCMP header and MIC */ | 543 | /* Remove CCMP header and MIC */ |
540 | if (pskb_trim(skb, skb->len - CCMP_MIC_LEN)) | 544 | if (pskb_trim(skb, skb->len - IEEE80211_CCMP_MIC_LEN)) |
541 | return RX_DROP_UNUSABLE; | 545 | return RX_DROP_UNUSABLE; |
542 | memmove(skb->data + CCMP_HDR_LEN, skb->data, hdrlen); | 546 | memmove(skb->data + IEEE80211_CCMP_HDR_LEN, skb->data, hdrlen); |
543 | skb_pull(skb, CCMP_HDR_LEN); | 547 | skb_pull(skb, IEEE80211_CCMP_HDR_LEN); |
544 | 548 | ||
545 | return RX_CONTINUE; | 549 | return RX_CONTINUE; |
546 | } | 550 | } |