aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/mac80211/aes_ccm.c13
-rw-r--r--net/mac80211/aes_ccm.h4
-rw-r--r--net/mac80211/wpa.c26
3 files changed, 20 insertions, 23 deletions
diff --git a/net/mac80211/aes_ccm.c b/net/mac80211/aes_ccm.c
index 4d4c2dfcf9a..e756ed93116 100644
--- a/net/mac80211/aes_ccm.c
+++ b/net/mac80211/aes_ccm.c
@@ -53,15 +53,17 @@ static inline void aes_ccm_prepare(struct crypto_cipher *tfm, u8 *b_0, u8 *aad,
53 53
54 54
55void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *scratch, 55void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *scratch,
56 u8 *b_0, u8 *aad, u8 *data, size_t data_len, 56 u8 *data, size_t data_len,
57 u8 *cdata, u8 *mic) 57 u8 *cdata, u8 *mic)
58{ 58{
59 int i, j, last_len, num_blocks; 59 int i, j, last_len, num_blocks;
60 u8 *pos, *cpos, *b, *s_0, *e; 60 u8 *pos, *cpos, *b, *s_0, *e, *b_0, *aad;
61 61
62 b = scratch; 62 b = scratch;
63 s_0 = scratch + AES_BLOCK_LEN; 63 s_0 = scratch + AES_BLOCK_LEN;
64 e = scratch + 2 * AES_BLOCK_LEN; 64 e = scratch + 2 * AES_BLOCK_LEN;
65 b_0 = scratch + 3 * AES_BLOCK_LEN;
66 aad = scratch + 4 * AES_BLOCK_LEN;
65 67
66 num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_LEN); 68 num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_LEN);
67 last_len = data_len % AES_BLOCK_LEN; 69 last_len = data_len % AES_BLOCK_LEN;
@@ -92,15 +94,16 @@ void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *scratch,
92 94
93 95
94int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *scratch, 96int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *scratch,
95 u8 *b_0, u8 *aad, u8 *cdata, size_t data_len, 97 u8 *cdata, size_t data_len, u8 *mic, u8 *data)
96 u8 *mic, u8 *data)
97{ 98{
98 int i, j, last_len, num_blocks; 99 int i, j, last_len, num_blocks;
99 u8 *pos, *cpos, *b, *s_0, *a; 100 u8 *pos, *cpos, *b, *s_0, *a, *b_0, *aad;
100 101
101 b = scratch; 102 b = scratch;
102 s_0 = scratch + AES_BLOCK_LEN; 103 s_0 = scratch + AES_BLOCK_LEN;
103 a = scratch + 2 * AES_BLOCK_LEN; 104 a = scratch + 2 * AES_BLOCK_LEN;
105 b_0 = scratch + 3 * AES_BLOCK_LEN;
106 aad = scratch + 4 * AES_BLOCK_LEN;
104 107
105 num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_LEN); 108 num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_LEN);
106 last_len = data_len % AES_BLOCK_LEN; 109 last_len = data_len % AES_BLOCK_LEN;
diff --git a/net/mac80211/aes_ccm.h b/net/mac80211/aes_ccm.h
index 8cd0f14aab4..6e7820ef344 100644
--- a/net/mac80211/aes_ccm.h
+++ b/net/mac80211/aes_ccm.h
@@ -16,10 +16,10 @@
16 16
17struct crypto_cipher *ieee80211_aes_key_setup_encrypt(const u8 key[]); 17struct crypto_cipher *ieee80211_aes_key_setup_encrypt(const u8 key[]);
18void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *scratch, 18void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *scratch,
19 u8 *b_0, u8 *aad, u8 *data, size_t data_len, 19 u8 *data, size_t data_len,
20 u8 *cdata, u8 *mic); 20 u8 *cdata, u8 *mic);
21int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *scratch, 21int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *scratch,
22 u8 *b_0, u8 *aad, u8 *cdata, size_t data_len, 22 u8 *cdata, size_t data_len,
23 u8 *mic, u8 *data); 23 u8 *mic, u8 *data);
24void ieee80211_aes_key_free(struct crypto_cipher *tfm); 24void ieee80211_aes_key_free(struct crypto_cipher *tfm);
25 25
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index ec2ae86d64a..2f33df0dccc 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)) {