aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2010-08-10 03:46:38 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-08-16 16:45:11 -0400
commit97359d1235eaf634fe706c9faa6e40181cc95fb8 (patch)
tree5799455c94622eaa6a4fb065bd3b5c350bb705e0 /net/mac80211
parent915a824e30c503157c38115eb6a85f60bb653738 (diff)
mac80211: use cipher suite selectors
Currently, mac80211 translates the cfg80211 cipher suite selectors into ALG_* values. That isn't all too useful, and some drivers benefit from the distinction between WEP40 and WEP104 as well. Therefore, convert it all to use the cipher suite selectors. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Acked-by: Gertjan van Wingerde <gwingerde@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r--net/mac80211/cfg.c44
-rw-r--r--net/mac80211/debugfs_key.c55
-rw-r--r--net/mac80211/driver-trace.h4
-rw-r--r--net/mac80211/key.c25
-rw-r--r--net/mac80211/key.h4
-rw-r--r--net/mac80211/rx.c18
-rw-r--r--net/mac80211/tx.c22
-rw-r--r--net/mac80211/wep.c2
-rw-r--r--net/mac80211/wpa.c6
9 files changed, 75 insertions, 105 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 19c6146010b7..9a35d9e7efd7 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -116,7 +116,6 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
116{ 116{
117 struct ieee80211_sub_if_data *sdata; 117 struct ieee80211_sub_if_data *sdata;
118 struct sta_info *sta = NULL; 118 struct sta_info *sta = NULL;
119 enum ieee80211_key_alg alg;
120 struct ieee80211_key *key; 119 struct ieee80211_key *key;
121 int err; 120 int err;
122 121
@@ -125,31 +124,20 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
125 124
126 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 125 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
127 126
127 /* reject WEP and TKIP keys if WEP failed to initialize */
128 switch (params->cipher) { 128 switch (params->cipher) {
129 case WLAN_CIPHER_SUITE_WEP40: 129 case WLAN_CIPHER_SUITE_WEP40:
130 case WLAN_CIPHER_SUITE_WEP104:
131 alg = ALG_WEP;
132 break;
133 case WLAN_CIPHER_SUITE_TKIP: 130 case WLAN_CIPHER_SUITE_TKIP:
134 alg = ALG_TKIP; 131 case WLAN_CIPHER_SUITE_WEP104:
135 break; 132 if (IS_ERR(sdata->local->wep_tx_tfm))
136 case WLAN_CIPHER_SUITE_CCMP: 133 return -EINVAL;
137 alg = ALG_CCMP;
138 break;
139 case WLAN_CIPHER_SUITE_AES_CMAC:
140 alg = ALG_AES_CMAC;
141 break; 134 break;
142 default: 135 default:
143 return -EINVAL; 136 break;
144 } 137 }
145 138
146 /* reject WEP and TKIP keys if WEP failed to initialize */ 139 key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
147 if ((alg == ALG_WEP || alg == ALG_TKIP) && 140 params->key, params->seq_len, params->seq);
148 IS_ERR(sdata->local->wep_tx_tfm))
149 return -EINVAL;
150
151 key = ieee80211_key_alloc(alg, key_idx, params->key_len, params->key,
152 params->seq_len, params->seq);
153 if (IS_ERR(key)) 141 if (IS_ERR(key))
154 return PTR_ERR(key); 142 return PTR_ERR(key);
155 143
@@ -247,10 +235,10 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
247 235
248 memset(&params, 0, sizeof(params)); 236 memset(&params, 0, sizeof(params));
249 237
250 switch (key->conf.alg) { 238 params.cipher = key->conf.cipher;
251 case ALG_TKIP:
252 params.cipher = WLAN_CIPHER_SUITE_TKIP;
253 239
240 switch (key->conf.cipher) {
241 case WLAN_CIPHER_SUITE_TKIP:
254 iv32 = key->u.tkip.tx.iv32; 242 iv32 = key->u.tkip.tx.iv32;
255 iv16 = key->u.tkip.tx.iv16; 243 iv16 = key->u.tkip.tx.iv16;
256 244
@@ -268,8 +256,7 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
268 params.seq = seq; 256 params.seq = seq;
269 params.seq_len = 6; 257 params.seq_len = 6;
270 break; 258 break;
271 case ALG_CCMP: 259 case WLAN_CIPHER_SUITE_CCMP:
272 params.cipher = WLAN_CIPHER_SUITE_CCMP;
273 seq[0] = key->u.ccmp.tx_pn[5]; 260 seq[0] = key->u.ccmp.tx_pn[5];
274 seq[1] = key->u.ccmp.tx_pn[4]; 261 seq[1] = key->u.ccmp.tx_pn[4];
275 seq[2] = key->u.ccmp.tx_pn[3]; 262 seq[2] = key->u.ccmp.tx_pn[3];
@@ -279,14 +266,7 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
279 params.seq = seq; 266 params.seq = seq;
280 params.seq_len = 6; 267 params.seq_len = 6;
281 break; 268 break;
282 case ALG_WEP: 269 case WLAN_CIPHER_SUITE_AES_CMAC:
283 if (key->conf.keylen == 5)
284 params.cipher = WLAN_CIPHER_SUITE_WEP40;
285 else
286 params.cipher = WLAN_CIPHER_SUITE_WEP104;
287 break;
288 case ALG_AES_CMAC:
289 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
290 seq[0] = key->u.aes_cmac.tx_pn[5]; 270 seq[0] = key->u.aes_cmac.tx_pn[5];
291 seq[1] = key->u.aes_cmac.tx_pn[4]; 271 seq[1] = key->u.aes_cmac.tx_pn[4];
292 seq[2] = key->u.aes_cmac.tx_pn[3]; 272 seq[2] = key->u.aes_cmac.tx_pn[3];
diff --git a/net/mac80211/debugfs_key.c b/net/mac80211/debugfs_key.c
index fa5e76e658ef..1647f8dc5cda 100644
--- a/net/mac80211/debugfs_key.c
+++ b/net/mac80211/debugfs_key.c
@@ -64,26 +64,13 @@ static ssize_t key_algorithm_read(struct file *file,
64 char __user *userbuf, 64 char __user *userbuf,
65 size_t count, loff_t *ppos) 65 size_t count, loff_t *ppos)
66{ 66{
67 char *alg; 67 char buf[15];
68 struct ieee80211_key *key = file->private_data; 68 struct ieee80211_key *key = file->private_data;
69 u32 c = key->conf.cipher;
69 70
70 switch (key->conf.alg) { 71 sprintf(buf, "%.2x-%.2x-%.2x:%d\n",
71 case ALG_WEP: 72 c >> 24, (c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff);
72 alg = "WEP\n"; 73 return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
73 break;
74 case ALG_TKIP:
75 alg = "TKIP\n";
76 break;
77 case ALG_CCMP:
78 alg = "CCMP\n";
79 break;
80 case ALG_AES_CMAC:
81 alg = "AES-128-CMAC\n";
82 break;
83 default:
84 return 0;
85 }
86 return simple_read_from_buffer(userbuf, count, ppos, alg, strlen(alg));
87} 74}
88KEY_OPS(algorithm); 75KEY_OPS(algorithm);
89 76
@@ -95,21 +82,22 @@ static ssize_t key_tx_spec_read(struct file *file, char __user *userbuf,
95 int len; 82 int len;
96 struct ieee80211_key *key = file->private_data; 83 struct ieee80211_key *key = file->private_data;
97 84
98 switch (key->conf.alg) { 85 switch (key->conf.cipher) {
99 case ALG_WEP: 86 case WLAN_CIPHER_SUITE_WEP40:
87 case WLAN_CIPHER_SUITE_WEP104:
100 len = scnprintf(buf, sizeof(buf), "\n"); 88 len = scnprintf(buf, sizeof(buf), "\n");
101 break; 89 break;
102 case ALG_TKIP: 90 case WLAN_CIPHER_SUITE_TKIP:
103 len = scnprintf(buf, sizeof(buf), "%08x %04x\n", 91 len = scnprintf(buf, sizeof(buf), "%08x %04x\n",
104 key->u.tkip.tx.iv32, 92 key->u.tkip.tx.iv32,
105 key->u.tkip.tx.iv16); 93 key->u.tkip.tx.iv16);
106 break; 94 break;
107 case ALG_CCMP: 95 case WLAN_CIPHER_SUITE_CCMP:
108 tpn = key->u.ccmp.tx_pn; 96 tpn = key->u.ccmp.tx_pn;
109 len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n", 97 len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n",
110 tpn[0], tpn[1], tpn[2], tpn[3], tpn[4], tpn[5]); 98 tpn[0], tpn[1], tpn[2], tpn[3], tpn[4], tpn[5]);
111 break; 99 break;
112 case ALG_AES_CMAC: 100 case WLAN_CIPHER_SUITE_AES_CMAC:
113 tpn = key->u.aes_cmac.tx_pn; 101 tpn = key->u.aes_cmac.tx_pn;
114 len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n", 102 len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n",
115 tpn[0], tpn[1], tpn[2], tpn[3], tpn[4], 103 tpn[0], tpn[1], tpn[2], tpn[3], tpn[4],
@@ -130,11 +118,12 @@ static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
130 int i, len; 118 int i, len;
131 const u8 *rpn; 119 const u8 *rpn;
132 120
133 switch (key->conf.alg) { 121 switch (key->conf.cipher) {
134 case ALG_WEP: 122 case WLAN_CIPHER_SUITE_WEP40:
123 case WLAN_CIPHER_SUITE_WEP104:
135 len = scnprintf(buf, sizeof(buf), "\n"); 124 len = scnprintf(buf, sizeof(buf), "\n");
136 break; 125 break;
137 case ALG_TKIP: 126 case WLAN_CIPHER_SUITE_TKIP:
138 for (i = 0; i < NUM_RX_DATA_QUEUES; i++) 127 for (i = 0; i < NUM_RX_DATA_QUEUES; i++)
139 p += scnprintf(p, sizeof(buf)+buf-p, 128 p += scnprintf(p, sizeof(buf)+buf-p,
140 "%08x %04x\n", 129 "%08x %04x\n",
@@ -142,7 +131,7 @@ static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
142 key->u.tkip.rx[i].iv16); 131 key->u.tkip.rx[i].iv16);
143 len = p - buf; 132 len = p - buf;
144 break; 133 break;
145 case ALG_CCMP: 134 case WLAN_CIPHER_SUITE_CCMP:
146 for (i = 0; i < NUM_RX_DATA_QUEUES + 1; i++) { 135 for (i = 0; i < NUM_RX_DATA_QUEUES + 1; i++) {
147 rpn = key->u.ccmp.rx_pn[i]; 136 rpn = key->u.ccmp.rx_pn[i];
148 p += scnprintf(p, sizeof(buf)+buf-p, 137 p += scnprintf(p, sizeof(buf)+buf-p,
@@ -152,7 +141,7 @@ static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
152 } 141 }
153 len = p - buf; 142 len = p - buf;
154 break; 143 break;
155 case ALG_AES_CMAC: 144 case WLAN_CIPHER_SUITE_AES_CMAC:
156 rpn = key->u.aes_cmac.rx_pn; 145 rpn = key->u.aes_cmac.rx_pn;
157 p += scnprintf(p, sizeof(buf)+buf-p, 146 p += scnprintf(p, sizeof(buf)+buf-p,
158 "%02x%02x%02x%02x%02x%02x\n", 147 "%02x%02x%02x%02x%02x%02x\n",
@@ -174,11 +163,11 @@ static ssize_t key_replays_read(struct file *file, char __user *userbuf,
174 char buf[20]; 163 char buf[20];
175 int len; 164 int len;
176 165
177 switch (key->conf.alg) { 166 switch (key->conf.cipher) {
178 case ALG_CCMP: 167 case WLAN_CIPHER_SUITE_CCMP:
179 len = scnprintf(buf, sizeof(buf), "%u\n", key->u.ccmp.replays); 168 len = scnprintf(buf, sizeof(buf), "%u\n", key->u.ccmp.replays);
180 break; 169 break;
181 case ALG_AES_CMAC: 170 case WLAN_CIPHER_SUITE_AES_CMAC:
182 len = scnprintf(buf, sizeof(buf), "%u\n", 171 len = scnprintf(buf, sizeof(buf), "%u\n",
183 key->u.aes_cmac.replays); 172 key->u.aes_cmac.replays);
184 break; 173 break;
@@ -196,8 +185,8 @@ static ssize_t key_icverrors_read(struct file *file, char __user *userbuf,
196 char buf[20]; 185 char buf[20];
197 int len; 186 int len;
198 187
199 switch (key->conf.alg) { 188 switch (key->conf.cipher) {
200 case ALG_AES_CMAC: 189 case WLAN_CIPHER_SUITE_AES_CMAC:
201 len = scnprintf(buf, sizeof(buf), "%u\n", 190 len = scnprintf(buf, sizeof(buf), "%u\n",
202 key->u.aes_cmac.icverrors); 191 key->u.aes_cmac.icverrors);
203 break; 192 break;
diff --git a/net/mac80211/driver-trace.h b/net/mac80211/driver-trace.h
index 5d5d2a974668..b5a95582d816 100644
--- a/net/mac80211/driver-trace.h
+++ b/net/mac80211/driver-trace.h
@@ -336,7 +336,7 @@ TRACE_EVENT(drv_set_key,
336 LOCAL_ENTRY 336 LOCAL_ENTRY
337 VIF_ENTRY 337 VIF_ENTRY
338 STA_ENTRY 338 STA_ENTRY
339 __field(enum ieee80211_key_alg, alg) 339 __field(u32, cipher)
340 __field(u8, hw_key_idx) 340 __field(u8, hw_key_idx)
341 __field(u8, flags) 341 __field(u8, flags)
342 __field(s8, keyidx) 342 __field(s8, keyidx)
@@ -346,7 +346,7 @@ TRACE_EVENT(drv_set_key,
346 LOCAL_ASSIGN; 346 LOCAL_ASSIGN;
347 VIF_ASSIGN; 347 VIF_ASSIGN;
348 STA_ASSIGN; 348 STA_ASSIGN;
349 __entry->alg = key->alg; 349 __entry->cipher = key->cipher;
350 __entry->flags = key->flags; 350 __entry->flags = key->flags;
351 __entry->keyidx = key->keyidx; 351 __entry->keyidx = key->keyidx;
352 __entry->hw_key_idx = key->hw_key_idx; 352 __entry->hw_key_idx = key->hw_key_idx;
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index d6dbc8ea4ead..3203d1d3cd38 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -227,9 +227,7 @@ static void __ieee80211_key_replace(struct ieee80211_sub_if_data *sdata,
227 } 227 }
228} 228}
229 229
230struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg, 230struct ieee80211_key *ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
231 int idx,
232 size_t key_len,
233 const u8 *key_data, 231 const u8 *key_data,
234 size_t seq_len, const u8 *seq) 232 size_t seq_len, const u8 *seq)
235{ 233{
@@ -249,15 +247,16 @@ struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg,
249 key->conf.flags = 0; 247 key->conf.flags = 0;
250 key->flags = 0; 248 key->flags = 0;
251 249
252 key->conf.alg = alg; 250 key->conf.cipher = cipher;
253 key->conf.keyidx = idx; 251 key->conf.keyidx = idx;
254 key->conf.keylen = key_len; 252 key->conf.keylen = key_len;
255 switch (alg) { 253 switch (cipher) {
256 case ALG_WEP: 254 case WLAN_CIPHER_SUITE_WEP40:
255 case WLAN_CIPHER_SUITE_WEP104:
257 key->conf.iv_len = WEP_IV_LEN; 256 key->conf.iv_len = WEP_IV_LEN;
258 key->conf.icv_len = WEP_ICV_LEN; 257 key->conf.icv_len = WEP_ICV_LEN;
259 break; 258 break;
260 case ALG_TKIP: 259 case WLAN_CIPHER_SUITE_TKIP:
261 key->conf.iv_len = TKIP_IV_LEN; 260 key->conf.iv_len = TKIP_IV_LEN;
262 key->conf.icv_len = TKIP_ICV_LEN; 261 key->conf.icv_len = TKIP_ICV_LEN;
263 if (seq) { 262 if (seq) {
@@ -269,7 +268,7 @@ struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg,
269 } 268 }
270 } 269 }
271 break; 270 break;
272 case ALG_CCMP: 271 case WLAN_CIPHER_SUITE_CCMP:
273 key->conf.iv_len = CCMP_HDR_LEN; 272 key->conf.iv_len = CCMP_HDR_LEN;
274 key->conf.icv_len = CCMP_MIC_LEN; 273 key->conf.icv_len = CCMP_MIC_LEN;
275 if (seq) { 274 if (seq) {
@@ -279,7 +278,7 @@ struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg,
279 seq[CCMP_PN_LEN - j - 1]; 278 seq[CCMP_PN_LEN - j - 1];
280 } 279 }
281 break; 280 break;
282 case ALG_AES_CMAC: 281 case WLAN_CIPHER_SUITE_AES_CMAC:
283 key->conf.iv_len = 0; 282 key->conf.iv_len = 0;
284 key->conf.icv_len = sizeof(struct ieee80211_mmie); 283 key->conf.icv_len = sizeof(struct ieee80211_mmie);
285 if (seq) 284 if (seq)
@@ -290,7 +289,7 @@ struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg,
290 memcpy(key->conf.key, key_data, key_len); 289 memcpy(key->conf.key, key_data, key_len);
291 INIT_LIST_HEAD(&key->list); 290 INIT_LIST_HEAD(&key->list);
292 291
293 if (alg == ALG_CCMP) { 292 if (cipher == WLAN_CIPHER_SUITE_CCMP) {
294 /* 293 /*
295 * Initialize AES key state here as an optimization so that 294 * Initialize AES key state here as an optimization so that
296 * it does not need to be initialized for every packet. 295 * it does not need to be initialized for every packet.
@@ -303,7 +302,7 @@ struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg,
303 } 302 }
304 } 303 }
305 304
306 if (alg == ALG_AES_CMAC) { 305 if (cipher == WLAN_CIPHER_SUITE_AES_CMAC) {
307 /* 306 /*
308 * Initialize AES key state here as an optimization so that 307 * Initialize AES key state here as an optimization so that
309 * it does not need to be initialized for every packet. 308 * it does not need to be initialized for every packet.
@@ -328,9 +327,9 @@ static void __ieee80211_key_destroy(struct ieee80211_key *key)
328 if (key->local) 327 if (key->local)
329 ieee80211_key_disable_hw_accel(key); 328 ieee80211_key_disable_hw_accel(key);
330 329
331 if (key->conf.alg == ALG_CCMP) 330 if (key->conf.cipher == WLAN_CIPHER_SUITE_CCMP)
332 ieee80211_aes_key_free(key->u.ccmp.tfm); 331 ieee80211_aes_key_free(key->u.ccmp.tfm);
333 if (key->conf.alg == ALG_AES_CMAC) 332 if (key->conf.cipher == WLAN_CIPHER_SUITE_AES_CMAC)
334 ieee80211_aes_cmac_key_free(key->u.aes_cmac.tfm); 333 ieee80211_aes_cmac_key_free(key->u.aes_cmac.tfm);
335 if (key->local) 334 if (key->local)
336 ieee80211_debugfs_key_remove(key); 335 ieee80211_debugfs_key_remove(key);
diff --git a/net/mac80211/key.h b/net/mac80211/key.h
index b665bbb7a471..53b5ce12536f 100644
--- a/net/mac80211/key.h
+++ b/net/mac80211/key.h
@@ -123,9 +123,7 @@ struct ieee80211_key {
123 struct ieee80211_key_conf conf; 123 struct ieee80211_key_conf conf;
124}; 124};
125 125
126struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg, 126struct ieee80211_key *ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
127 int idx,
128 size_t key_len,
129 const u8 *key_data, 127 const u8 *key_data,
130 size_t seq_len, const u8 *seq); 128 size_t seq_len, const u8 *seq);
131/* 129/*
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index f24a0a1cff1a..ad2427021b26 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -961,7 +961,8 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
961 * pairwise or station-to-station keys, but for WEP we allow 961 * pairwise or station-to-station keys, but for WEP we allow
962 * using a key index as well. 962 * using a key index as well.
963 */ 963 */
964 if (rx->key && rx->key->conf.alg != ALG_WEP && 964 if (rx->key && rx->key->conf.cipher != WLAN_CIPHER_SUITE_WEP40 &&
965 rx->key->conf.cipher != WLAN_CIPHER_SUITE_WEP104 &&
965 !is_multicast_ether_addr(hdr->addr1)) 966 !is_multicast_ether_addr(hdr->addr1))
966 rx->key = NULL; 967 rx->key = NULL;
967 } 968 }
@@ -977,8 +978,9 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
977 return RX_DROP_UNUSABLE; 978 return RX_DROP_UNUSABLE;
978 /* the hdr variable is invalid now! */ 979 /* the hdr variable is invalid now! */
979 980
980 switch (rx->key->conf.alg) { 981 switch (rx->key->conf.cipher) {
981 case ALG_WEP: 982 case WLAN_CIPHER_SUITE_WEP40:
983 case WLAN_CIPHER_SUITE_WEP104:
982 /* Check for weak IVs if possible */ 984 /* Check for weak IVs if possible */
983 if (rx->sta && ieee80211_is_data(fc) && 985 if (rx->sta && ieee80211_is_data(fc) &&
984 (!(status->flag & RX_FLAG_IV_STRIPPED) || 986 (!(status->flag & RX_FLAG_IV_STRIPPED) ||
@@ -988,13 +990,13 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
988 990
989 result = ieee80211_crypto_wep_decrypt(rx); 991 result = ieee80211_crypto_wep_decrypt(rx);
990 break; 992 break;
991 case ALG_TKIP: 993 case WLAN_CIPHER_SUITE_TKIP:
992 result = ieee80211_crypto_tkip_decrypt(rx); 994 result = ieee80211_crypto_tkip_decrypt(rx);
993 break; 995 break;
994 case ALG_CCMP: 996 case WLAN_CIPHER_SUITE_CCMP:
995 result = ieee80211_crypto_ccmp_decrypt(rx); 997 result = ieee80211_crypto_ccmp_decrypt(rx);
996 break; 998 break;
997 case ALG_AES_CMAC: 999 case WLAN_CIPHER_SUITE_AES_CMAC:
998 result = ieee80211_crypto_aes_cmac_decrypt(rx); 1000 result = ieee80211_crypto_aes_cmac_decrypt(rx);
999 break; 1001 break;
1000 } 1002 }
@@ -1291,7 +1293,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
1291 /* This is the first fragment of a new frame. */ 1293 /* This is the first fragment of a new frame. */
1292 entry = ieee80211_reassemble_add(rx->sdata, frag, seq, 1294 entry = ieee80211_reassemble_add(rx->sdata, frag, seq,
1293 rx->queue, &(rx->skb)); 1295 rx->queue, &(rx->skb));
1294 if (rx->key && rx->key->conf.alg == ALG_CCMP && 1296 if (rx->key && rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP &&
1295 ieee80211_has_protected(fc)) { 1297 ieee80211_has_protected(fc)) {
1296 int queue = ieee80211_is_mgmt(fc) ? 1298 int queue = ieee80211_is_mgmt(fc) ?
1297 NUM_RX_DATA_QUEUES : rx->queue; 1299 NUM_RX_DATA_QUEUES : rx->queue;
@@ -1320,7 +1322,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
1320 int i; 1322 int i;
1321 u8 pn[CCMP_PN_LEN], *rpn; 1323 u8 pn[CCMP_PN_LEN], *rpn;
1322 int queue; 1324 int queue;
1323 if (!rx->key || rx->key->conf.alg != ALG_CCMP) 1325 if (!rx->key || rx->key->conf.cipher != WLAN_CIPHER_SUITE_CCMP)
1324 return RX_DROP_UNUSABLE; 1326 return RX_DROP_UNUSABLE;
1325 memcpy(pn, entry->last_pn, CCMP_PN_LEN); 1327 memcpy(pn, entry->last_pn, CCMP_PN_LEN);
1326 for (i = CCMP_PN_LEN - 1; i >= 0; i--) { 1328 for (i = CCMP_PN_LEN - 1; i >= 0; i--) {
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index c54db966926b..bc4fefc91663 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -543,15 +543,16 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
543 tx->key->tx_rx_count++; 543 tx->key->tx_rx_count++;
544 /* TODO: add threshold stuff again */ 544 /* TODO: add threshold stuff again */
545 545
546 switch (tx->key->conf.alg) { 546 switch (tx->key->conf.cipher) {
547 case ALG_WEP: 547 case WLAN_CIPHER_SUITE_WEP40:
548 case WLAN_CIPHER_SUITE_WEP104:
548 if (ieee80211_is_auth(hdr->frame_control)) 549 if (ieee80211_is_auth(hdr->frame_control))
549 break; 550 break;
550 case ALG_TKIP: 551 case WLAN_CIPHER_SUITE_TKIP:
551 if (!ieee80211_is_data_present(hdr->frame_control)) 552 if (!ieee80211_is_data_present(hdr->frame_control))
552 tx->key = NULL; 553 tx->key = NULL;
553 break; 554 break;
554 case ALG_CCMP: 555 case WLAN_CIPHER_SUITE_CCMP:
555 if (!ieee80211_is_data_present(hdr->frame_control) && 556 if (!ieee80211_is_data_present(hdr->frame_control) &&
556 !ieee80211_use_mfp(hdr->frame_control, tx->sta, 557 !ieee80211_use_mfp(hdr->frame_control, tx->sta,
557 tx->skb)) 558 tx->skb))
@@ -561,7 +562,7 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
561 IEEE80211_KEY_FLAG_SW_MGMT) && 562 IEEE80211_KEY_FLAG_SW_MGMT) &&
562 ieee80211_is_mgmt(hdr->frame_control); 563 ieee80211_is_mgmt(hdr->frame_control);
563 break; 564 break;
564 case ALG_AES_CMAC: 565 case WLAN_CIPHER_SUITE_AES_CMAC:
565 if (!ieee80211_is_mgmt(hdr->frame_control)) 566 if (!ieee80211_is_mgmt(hdr->frame_control))
566 tx->key = NULL; 567 tx->key = NULL;
567 break; 568 break;
@@ -949,14 +950,15 @@ ieee80211_tx_h_encrypt(struct ieee80211_tx_data *tx)
949 if (!tx->key) 950 if (!tx->key)
950 return TX_CONTINUE; 951 return TX_CONTINUE;
951 952
952 switch (tx->key->conf.alg) { 953 switch (tx->key->conf.cipher) {
953 case ALG_WEP: 954 case WLAN_CIPHER_SUITE_WEP40:
955 case WLAN_CIPHER_SUITE_WEP104:
954 return ieee80211_crypto_wep_encrypt(tx); 956 return ieee80211_crypto_wep_encrypt(tx);
955 case ALG_TKIP: 957 case WLAN_CIPHER_SUITE_TKIP:
956 return ieee80211_crypto_tkip_encrypt(tx); 958 return ieee80211_crypto_tkip_encrypt(tx);
957 case ALG_CCMP: 959 case WLAN_CIPHER_SUITE_CCMP:
958 return ieee80211_crypto_ccmp_encrypt(tx); 960 return ieee80211_crypto_ccmp_encrypt(tx);
959 case ALG_AES_CMAC: 961 case WLAN_CIPHER_SUITE_AES_CMAC:
960 return ieee80211_crypto_aes_cmac_encrypt(tx); 962 return ieee80211_crypto_aes_cmac_encrypt(tx);
961 } 963 }
962 964
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c
index 9ebc8d8a1f5b..f27484c22b9f 100644
--- a/net/mac80211/wep.c
+++ b/net/mac80211/wep.c
@@ -240,7 +240,7 @@ static int ieee80211_wep_decrypt(struct ieee80211_local *local,
240 240
241 keyidx = skb->data[hdrlen + 3] >> 6; 241 keyidx = skb->data[hdrlen + 3] >> 6;
242 242
243 if (!key || keyidx != key->conf.keyidx || key->conf.alg != ALG_WEP) 243 if (!key || keyidx != key->conf.keyidx)
244 return -1; 244 return -1;
245 245
246 klen = 3 + key->conf.keylen; 246 klen = 3 + key->conf.keylen;
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index 8d59d27d887e..b08ad94b56da 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -36,8 +36,8 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_tx_data *tx)
36 int tail; 36 int tail;
37 37
38 hdr = (struct ieee80211_hdr *)skb->data; 38 hdr = (struct ieee80211_hdr *)skb->data;
39 if (!tx->key || tx->key->conf.alg != ALG_TKIP || skb->len < 24 || 39 if (!tx->key || tx->key->conf.cipher != WLAN_CIPHER_SUITE_TKIP ||
40 !ieee80211_is_data_present(hdr->frame_control)) 40 skb->len < 24 || !ieee80211_is_data_present(hdr->frame_control))
41 return TX_CONTINUE; 41 return TX_CONTINUE;
42 42
43 hdrlen = ieee80211_hdrlen(hdr->frame_control); 43 hdrlen = ieee80211_hdrlen(hdr->frame_control);
@@ -94,7 +94,7 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx)
94 if (status->flag & RX_FLAG_MMIC_STRIPPED) 94 if (status->flag & RX_FLAG_MMIC_STRIPPED)
95 return RX_CONTINUE; 95 return RX_CONTINUE;
96 96
97 if (!rx->key || rx->key->conf.alg != ALG_TKIP || 97 if (!rx->key || rx->key->conf.cipher != WLAN_CIPHER_SUITE_TKIP ||
98 !ieee80211_has_protected(hdr->frame_control) || 98 !ieee80211_has_protected(hdr->frame_control) ||
99 !ieee80211_is_data_present(hdr->frame_control)) 99 !ieee80211_is_data_present(hdr->frame_control))
100 return RX_CONTINUE; 100 return RX_CONTINUE;