aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/wpa.c
diff options
context:
space:
mode:
authorHarvey Harrison <harvey.harrison@gmail.com>2008-07-02 19:30:52 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-07-08 14:16:02 -0400
commitfeccb466944cb1aeaabc701cfde6771f3be74919 (patch)
tree62da55862059f4adb4858376b4698f1d81afbec4 /net/mac80211/wpa.c
parentc34498b9e633baa3266af98106502633b6bc371b (diff)
mac80211: pass scratch buffer directly, remove additional pointers
Recalculate the offset pointers in the ccmp calculations rather than in the callers. Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/wpa.c')
-rw-r--r--net/mac80211/wpa.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index ec2ae86d64aa..2f33df0dcccf 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -274,16 +274,20 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_rx_data *rx)
274} 274}
275 275
276 276
277static void ccmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *b_0, u8 *aad, 277static void ccmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *scratch,
278 int encrypted) 278 int encrypted)
279{ 279{
280 __le16 mask_fc; 280 __le16 mask_fc;
281 int a4_included; 281 int a4_included;
282 u8 qos_tid; 282 u8 qos_tid;
283 u8 *b_0, *aad;
283 u16 data_len, len_a; 284 u16 data_len, len_a;
284 unsigned int hdrlen; 285 unsigned int hdrlen;
285 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 286 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
286 287
288 b_0 = scratch + 3 * AES_BLOCK_LEN;
289 aad = scratch + 4 * AES_BLOCK_LEN;
290
287 /* 291 /*
288 * Mask FC: zero subtype b4 b5 b6 292 * Mask FC: zero subtype b4 b5 b6
289 * Retry, PwrMgt, MoreData; set Protected 293 * Retry, PwrMgt, MoreData; set Protected
@@ -367,7 +371,7 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
367 struct ieee80211_key *key = tx->key; 371 struct ieee80211_key *key = tx->key;
368 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 372 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
369 int hdrlen, len, tail; 373 int hdrlen, len, tail;
370 u8 *pos, *pn, *b_0, *aad, *scratch; 374 u8 *pos, *pn;
371 int i; 375 int i;
372 376
373 info->control.icv_len = CCMP_MIC_LEN; 377 info->control.icv_len = CCMP_MIC_LEN;
@@ -381,10 +385,6 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
381 return 0; 385 return 0;
382 } 386 }
383 387
384 scratch = key->u.ccmp.tx_crypto_buf;
385 b_0 = scratch + 3 * AES_BLOCK_LEN;
386 aad = scratch + 4 * AES_BLOCK_LEN;
387
388 hdrlen = ieee80211_hdrlen(hdr->frame_control); 388 hdrlen = ieee80211_hdrlen(hdr->frame_control);
389 len = skb->len - hdrlen; 389 len = skb->len - hdrlen;
390 390
@@ -420,8 +420,8 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
420 } 420 }
421 421
422 pos += CCMP_HDR_LEN; 422 pos += CCMP_HDR_LEN;
423 ccmp_special_blocks(skb, pn, b_0, aad, 0); 423 ccmp_special_blocks(skb, pn, key->u.ccmp.tx_crypto_buf, 0);
424 ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, scratch, b_0, aad, pos, len, 424 ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, key->u.ccmp.tx_crypto_buf, pos, len,
425 pos, skb_put(skb, CCMP_MIC_LEN)); 425 pos, skb_put(skb, CCMP_MIC_LEN));
426 426
427 return 0; 427 return 0;
@@ -483,16 +483,10 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx)
483 483
484 if (!(rx->status->flag & RX_FLAG_DECRYPTED)) { 484 if (!(rx->status->flag & RX_FLAG_DECRYPTED)) {
485 /* hardware didn't decrypt/verify MIC */ 485 /* hardware didn't decrypt/verify MIC */
486 u8 *scratch, *b_0, *aad; 486 ccmp_special_blocks(skb, pn, key->u.ccmp.rx_crypto_buf, 1);
487
488 scratch = key->u.ccmp.rx_crypto_buf;
489 b_0 = scratch + 3 * AES_BLOCK_LEN;
490 aad = scratch + 4 * AES_BLOCK_LEN;
491
492 ccmp_special_blocks(skb, pn, b_0, aad, 1);
493 487
494 if (ieee80211_aes_ccm_decrypt( 488 if (ieee80211_aes_ccm_decrypt(
495 key->u.ccmp.tfm, scratch, b_0, aad, 489 key->u.ccmp.tfm, key->u.ccmp.rx_crypto_buf,
496 skb->data + hdrlen + CCMP_HDR_LEN, data_len, 490 skb->data + hdrlen + CCMP_HDR_LEN, data_len,
497 skb->data + skb->len - CCMP_MIC_LEN, 491 skb->data + skb->len - CCMP_MIC_LEN,
498 skb->data + hdrlen + CCMP_HDR_LEN)) { 492 skb->data + hdrlen + CCMP_HDR_LEN)) {