aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/wpa.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2007-08-28 17:01:54 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:48:51 -0400
commit8f20fc24986a083228823d9b68adca20714b254e (patch)
treeb5d7638b913649c7a181d6703ccd72e35ca06de9 /net/mac80211/wpa.c
parent13262ffd4902805acad2618c12b41fcaa6c50791 (diff)
[MAC80211]: embed key conf in key, fix driver interface
This patch embeds the struct ieee80211_key_conf into struct ieee80211_key and thus avoids allocations and having data present twice. This required some more changes: 1) The removal of the IEEE80211_KEY_DEFAULT_TX_KEY key flag. This flag isn't used by drivers nor should it be since we have a set_key_idx() callback. Maybe that callback needs to be extended to include the key conf, but only a driver that requires it will tell. 2) The removal of the IEEE80211_KEY_DEFAULT_WEP_ONLY key flag. This flag is global, so it shouldn't be passed in the key conf structure. Pass it to the function instead. Also, this patch removes the AID parameter to the set_key() callback because it is currently unused and the hardware currently cannot know about the AID anyway. I suspect this was used with some hardware that actually selected the AID itself, but that functionality was removed. Additionally, I've removed the ALG_NULL key algorithm since we have ALG_NONE. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Acked-by: Michael Wu <flamingice@sourmilk.net> Signed-off-by: John W. Linville <linville@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/mac80211/wpa.c')
-rw-r--r--net/mac80211/wpa.c61
1 files changed, 34 insertions, 27 deletions
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index 1142b42b5fe9..4a2a9aa638b3 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -82,14 +82,14 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx)
82 82
83 fc = tx->fc; 83 fc = tx->fc;
84 84
85 if (!tx->key || tx->key->alg != ALG_TKIP || skb->len < 24 || 85 if (!tx->key || tx->key->conf.alg != ALG_TKIP || skb->len < 24 ||
86 !WLAN_FC_DATA_PRESENT(fc)) 86 !WLAN_FC_DATA_PRESENT(fc))
87 return TXRX_CONTINUE; 87 return TXRX_CONTINUE;
88 88
89 if (ieee80211_get_hdr_info(skb, &sa, &da, &qos_tid, &data, &data_len)) 89 if (ieee80211_get_hdr_info(skb, &sa, &da, &qos_tid, &data, &data_len))
90 return TXRX_DROP; 90 return TXRX_DROP;
91 91
92 if (!tx->key->force_sw_encrypt && 92 if (!(tx->key->conf.flags & IEEE80211_KEY_FORCE_SW_ENCRYPT) &&
93 !(tx->flags & IEEE80211_TXRXD_FRAGMENTED) && 93 !(tx->flags & IEEE80211_TXRXD_FRAGMENTED) &&
94 !(tx->local->hw.flags & IEEE80211_HW_TKIP_INCLUDE_MMIC) && 94 !(tx->local->hw.flags & IEEE80211_HW_TKIP_INCLUDE_MMIC) &&
95 !wpa_test) { 95 !wpa_test) {
@@ -114,8 +114,8 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx)
114#else 114#else
115 authenticator = 1; 115 authenticator = 1;
116#endif 116#endif
117 key = &tx->key->key[authenticator ? ALG_TKIP_TEMP_AUTH_TX_MIC_KEY : 117 key = &tx->key->conf.key[authenticator ? ALG_TKIP_TEMP_AUTH_TX_MIC_KEY :
118 ALG_TKIP_TEMP_AUTH_RX_MIC_KEY]; 118 ALG_TKIP_TEMP_AUTH_RX_MIC_KEY];
119 mic = skb_put(skb, MICHAEL_MIC_LEN); 119 mic = skb_put(skb, MICHAEL_MIC_LEN);
120 michael_mic(key, da, sa, qos_tid & 0x0f, data, data_len, mic); 120 michael_mic(key, da, sa, qos_tid & 0x0f, data, data_len, mic);
121 121
@@ -141,12 +141,12 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx)
141 if (rx->local->hw.flags & IEEE80211_HW_DEVICE_STRIPS_MIC) 141 if (rx->local->hw.flags & IEEE80211_HW_DEVICE_STRIPS_MIC)
142 return TXRX_CONTINUE; 142 return TXRX_CONTINUE;
143 143
144 if (!rx->key || rx->key->alg != ALG_TKIP || 144 if (!rx->key || rx->key->conf.alg != ALG_TKIP ||
145 !(rx->fc & IEEE80211_FCTL_PROTECTED) || !WLAN_FC_DATA_PRESENT(fc)) 145 !(rx->fc & IEEE80211_FCTL_PROTECTED) || !WLAN_FC_DATA_PRESENT(fc))
146 return TXRX_CONTINUE; 146 return TXRX_CONTINUE;
147 147
148 if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) && 148 if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) &&
149 !rx->key->force_sw_encrypt) { 149 !(rx->key->conf.flags & IEEE80211_KEY_FORCE_SW_ENCRYPT)) {
150 if (rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV) { 150 if (rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV) {
151 if (skb->len < MICHAEL_MIC_LEN) 151 if (skb->len < MICHAEL_MIC_LEN)
152 return TXRX_DROP; 152 return TXRX_DROP;
@@ -169,8 +169,8 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx)
169#else 169#else
170 authenticator = 1; 170 authenticator = 1;
171#endif 171#endif
172 key = &rx->key->key[authenticator ? ALG_TKIP_TEMP_AUTH_RX_MIC_KEY : 172 key = &rx->key->conf.key[authenticator ? ALG_TKIP_TEMP_AUTH_RX_MIC_KEY :
173 ALG_TKIP_TEMP_AUTH_TX_MIC_KEY]; 173 ALG_TKIP_TEMP_AUTH_TX_MIC_KEY];
174 michael_mic(key, da, sa, qos_tid & 0x0f, data, data_len, mic); 174 michael_mic(key, da, sa, qos_tid & 0x0f, data, data_len, mic);
175 if (memcmp(mic, data + data_len, MICHAEL_MIC_LEN) != 0 || wpa_test) { 175 if (memcmp(mic, data + data_len, MICHAEL_MIC_LEN) != 0 || wpa_test) {
176 if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) 176 if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
@@ -179,7 +179,7 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx)
179 printk(KERN_DEBUG "%s: invalid Michael MIC in data frame from " 179 printk(KERN_DEBUG "%s: invalid Michael MIC in data frame from "
180 MAC_FMT "\n", rx->dev->name, MAC_ARG(sa)); 180 MAC_FMT "\n", rx->dev->name, MAC_ARG(sa));
181 181
182 mac80211_ev_michael_mic_failure(rx->dev, rx->key->keyidx, 182 mac80211_ev_michael_mic_failure(rx->dev, rx->key->conf.keyidx,
183 (void *) skb->data); 183 (void *) skb->data);
184 return TXRX_DROP; 184 return TXRX_DROP;
185 } 185 }
@@ -205,7 +205,11 @@ static int tkip_encrypt_skb(struct ieee80211_txrx_data *tx,
205 hdrlen = ieee80211_get_hdrlen(fc); 205 hdrlen = ieee80211_get_hdrlen(fc);
206 len = skb->len - hdrlen; 206 len = skb->len - hdrlen;
207 207
208 tailneed = !tx->key->force_sw_encrypt ? 0 : TKIP_ICV_LEN; 208 if (tx->key->conf.flags & IEEE80211_KEY_FORCE_SW_ENCRYPT)
209 tailneed = TKIP_ICV_LEN;
210 else
211 tailneed = 0;
212
209 if ((skb_headroom(skb) < TKIP_IV_LEN || 213 if ((skb_headroom(skb) < TKIP_IV_LEN ||
210 skb_tailroom(skb) < tailneed)) { 214 skb_tailroom(skb) < tailneed)) {
211 I802_DEBUG_INC(tx->local->tx_expand_skb_head); 215 I802_DEBUG_INC(tx->local->tx_expand_skb_head);
@@ -223,7 +227,7 @@ static int tkip_encrypt_skb(struct ieee80211_txrx_data *tx,
223 if (key->u.tkip.iv16 == 0) 227 if (key->u.tkip.iv16 == 0)
224 key->u.tkip.iv32++; 228 key->u.tkip.iv32++;
225 229
226 if (!tx->key->force_sw_encrypt) { 230 if (!(tx->key->conf.flags & IEEE80211_KEY_FORCE_SW_ENCRYPT)) {
227 u32 flags = tx->local->hw.flags; 231 u32 flags = tx->local->hw.flags;
228 hdr = (struct ieee80211_hdr *)skb->data; 232 hdr = (struct ieee80211_hdr *)skb->data;
229 233
@@ -250,7 +254,7 @@ static int tkip_encrypt_skb(struct ieee80211_txrx_data *tx,
250 ~IEEE80211_TXCTL_TKIP_NEW_PHASE1_KEY; 254 ~IEEE80211_TXCTL_TKIP_NEW_PHASE1_KEY;
251 } 255 }
252 256
253 tx->u.tx.control->key_idx = tx->key->hw_key_idx; 257 tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx;
254 return 0; 258 return 0;
255 } 259 }
256 260
@@ -275,18 +279,18 @@ ieee80211_tx_h_tkip_encrypt(struct ieee80211_txrx_data *tx)
275 279
276 fc = le16_to_cpu(hdr->frame_control); 280 fc = le16_to_cpu(hdr->frame_control);
277 281
278 if (!key || key->alg != ALG_TKIP || !WLAN_FC_DATA_PRESENT(fc)) 282 if (!key || key->conf.alg != ALG_TKIP || !WLAN_FC_DATA_PRESENT(fc))
279 return TXRX_CONTINUE; 283 return TXRX_CONTINUE;
280 284
281 tx->u.tx.control->icv_len = TKIP_ICV_LEN; 285 tx->u.tx.control->icv_len = TKIP_ICV_LEN;
282 tx->u.tx.control->iv_len = TKIP_IV_LEN; 286 tx->u.tx.control->iv_len = TKIP_IV_LEN;
283 ieee80211_tx_set_iswep(tx); 287 ieee80211_tx_set_iswep(tx);
284 288
285 if (!tx->key->force_sw_encrypt && 289 if (!(tx->key->conf.flags & IEEE80211_KEY_FORCE_SW_ENCRYPT) &&
286 !(tx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV) && 290 !(tx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV) &&
287 !wpa_test) { 291 !wpa_test) {
288 /* hwaccel - with no need for preallocated room for IV/ICV */ 292 /* hwaccel - with no need for preallocated room for IV/ICV */
289 tx->u.tx.control->key_idx = tx->key->hw_key_idx; 293 tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx;
290 return TXRX_CONTINUE; 294 return TXRX_CONTINUE;
291 } 295 }
292 296
@@ -318,7 +322,7 @@ ieee80211_rx_h_tkip_decrypt(struct ieee80211_txrx_data *rx)
318 fc = le16_to_cpu(hdr->frame_control); 322 fc = le16_to_cpu(hdr->frame_control);
319 hdrlen = ieee80211_get_hdrlen(fc); 323 hdrlen = ieee80211_get_hdrlen(fc);
320 324
321 if (!rx->key || rx->key->alg != ALG_TKIP || 325 if (!rx->key || rx->key->conf.alg != ALG_TKIP ||
322 !(rx->fc & IEEE80211_FCTL_PROTECTED) || 326 !(rx->fc & IEEE80211_FCTL_PROTECTED) ||
323 (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) 327 (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
324 return TXRX_CONTINUE; 328 return TXRX_CONTINUE;
@@ -327,7 +331,7 @@ ieee80211_rx_h_tkip_decrypt(struct ieee80211_txrx_data *rx)
327 return TXRX_DROP; 331 return TXRX_DROP;
328 332
329 if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) && 333 if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) &&
330 !rx->key->force_sw_encrypt) { 334 !(key->conf.flags & IEEE80211_KEY_FORCE_SW_ENCRYPT)) {
331 if (!(rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV)) { 335 if (!(rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV)) {
332 /* Hardware takes care of all processing, including 336 /* Hardware takes care of all processing, including
333 * replay protection, so no need to continue here. */ 337 * replay protection, so no need to continue here. */
@@ -471,7 +475,10 @@ static int ccmp_encrypt_skb(struct ieee80211_txrx_data *tx,
471 hdrlen = ieee80211_get_hdrlen(fc); 475 hdrlen = ieee80211_get_hdrlen(fc);
472 len = skb->len - hdrlen; 476 len = skb->len - hdrlen;
473 477
474 tailneed = !key->force_sw_encrypt ? 0 : CCMP_MIC_LEN; 478 if (key->conf.flags & IEEE80211_KEY_FORCE_SW_ENCRYPT)
479 tailneed = CCMP_MIC_LEN;
480 else
481 tailneed = 0;
475 482
476 if ((skb_headroom(skb) < CCMP_HDR_LEN || 483 if ((skb_headroom(skb) < CCMP_HDR_LEN ||
477 skb_tailroom(skb) < tailneed)) { 484 skb_tailroom(skb) < tailneed)) {
@@ -495,11 +502,11 @@ static int ccmp_encrypt_skb(struct ieee80211_txrx_data *tx,
495 break; 502 break;
496 } 503 }
497 504
498 ccmp_pn2hdr(pos, pn, key->keyidx); 505 ccmp_pn2hdr(pos, pn, key->conf.keyidx);
499 506
500 if (!key->force_sw_encrypt) { 507 if (!(key->conf.flags & IEEE80211_KEY_FORCE_SW_ENCRYPT)) {
501 /* hwaccel - with preallocated room for CCMP header */ 508 /* hwaccel - with preallocated room for CCMP header */
502 tx->u.tx.control->key_idx = key->hw_key_idx; 509 tx->u.tx.control->key_idx = key->conf.hw_key_idx;
503 return 0; 510 return 0;
504 } 511 }
505 512
@@ -523,18 +530,18 @@ ieee80211_tx_h_ccmp_encrypt(struct ieee80211_txrx_data *tx)
523 530
524 fc = le16_to_cpu(hdr->frame_control); 531 fc = le16_to_cpu(hdr->frame_control);
525 532
526 if (!key || key->alg != ALG_CCMP || !WLAN_FC_DATA_PRESENT(fc)) 533 if (!key || key->conf.alg != ALG_CCMP || !WLAN_FC_DATA_PRESENT(fc))
527 return TXRX_CONTINUE; 534 return TXRX_CONTINUE;
528 535
529 tx->u.tx.control->icv_len = CCMP_MIC_LEN; 536 tx->u.tx.control->icv_len = CCMP_MIC_LEN;
530 tx->u.tx.control->iv_len = CCMP_HDR_LEN; 537 tx->u.tx.control->iv_len = CCMP_HDR_LEN;
531 ieee80211_tx_set_iswep(tx); 538 ieee80211_tx_set_iswep(tx);
532 539
533 if (!tx->key->force_sw_encrypt && 540 if (!(tx->key->conf.flags & IEEE80211_KEY_FORCE_SW_ENCRYPT) &&
534 !(tx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV)) { 541 !(tx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV)) {
535 /* hwaccel - with no need for preallocated room for CCMP " 542 /* hwaccel - with no need for preallocated room for CCMP "
536 * header or MIC fields */ 543 * header or MIC fields */
537 tx->u.tx.control->key_idx = tx->key->hw_key_idx; 544 tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx;
538 return TXRX_CONTINUE; 545 return TXRX_CONTINUE;
539 } 546 }
540 547
@@ -569,7 +576,7 @@ ieee80211_rx_h_ccmp_decrypt(struct ieee80211_txrx_data *rx)
569 fc = le16_to_cpu(hdr->frame_control); 576 fc = le16_to_cpu(hdr->frame_control);
570 hdrlen = ieee80211_get_hdrlen(fc); 577 hdrlen = ieee80211_get_hdrlen(fc);
571 578
572 if (!key || key->alg != ALG_CCMP || 579 if (!key || key->conf.alg != ALG_CCMP ||
573 !(rx->fc & IEEE80211_FCTL_PROTECTED) || 580 !(rx->fc & IEEE80211_FCTL_PROTECTED) ||
574 (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) 581 (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
575 return TXRX_CONTINUE; 582 return TXRX_CONTINUE;
@@ -579,7 +586,7 @@ ieee80211_rx_h_ccmp_decrypt(struct ieee80211_txrx_data *rx)
579 return TXRX_DROP; 586 return TXRX_DROP;
580 587
581 if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) && 588 if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) &&
582 !key->force_sw_encrypt && 589 !(key->conf.flags & IEEE80211_KEY_FORCE_SW_ENCRYPT) &&
583 !(rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV)) 590 !(rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV))
584 return TXRX_CONTINUE; 591 return TXRX_CONTINUE;
585 592
@@ -600,7 +607,7 @@ ieee80211_rx_h_ccmp_decrypt(struct ieee80211_txrx_data *rx)
600 } 607 }
601 608
602 if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) && 609 if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) &&
603 !key->force_sw_encrypt) { 610 !(key->conf.flags & IEEE80211_KEY_FORCE_SW_ENCRYPT)) {
604 /* hwaccel has already decrypted frame and verified MIC */ 611 /* hwaccel has already decrypted frame and verified MIC */
605 } else { 612 } else {
606 u8 *scratch, *b_0, *aad; 613 u8 *scratch, *b_0, *aad;