diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-07-02 19:30:52 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-07-08 14:16:02 -0400 |
commit | feccb466944cb1aeaabc701cfde6771f3be74919 (patch) | |
tree | 62da55862059f4adb4858376b4698f1d81afbec4 /net | |
parent | c34498b9e633baa3266af98106502633b6bc371b (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')
-rw-r--r-- | net/mac80211/aes_ccm.c | 13 | ||||
-rw-r--r-- | net/mac80211/aes_ccm.h | 4 | ||||
-rw-r--r-- | net/mac80211/wpa.c | 26 |
3 files changed, 20 insertions, 23 deletions
diff --git a/net/mac80211/aes_ccm.c b/net/mac80211/aes_ccm.c index 4d4c2dfcf9a0..e756ed931164 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 | ||
55 | void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *scratch, | 55 | void 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 | ||
94 | int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *scratch, | 96 | int 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 8cd0f14aab4d..6e7820ef3448 100644 --- a/net/mac80211/aes_ccm.h +++ b/net/mac80211/aes_ccm.h | |||
@@ -16,10 +16,10 @@ | |||
16 | 16 | ||
17 | struct crypto_cipher *ieee80211_aes_key_setup_encrypt(const u8 key[]); | 17 | struct crypto_cipher *ieee80211_aes_key_setup_encrypt(const u8 key[]); |
18 | void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *scratch, | 18 | void 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); |
21 | int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *scratch, | 21 | int 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); |
24 | void ieee80211_aes_key_free(struct crypto_cipher *tfm); | 24 | void ieee80211_aes_key_free(struct crypto_cipher *tfm); |
25 | 25 | ||
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 | ||
277 | static void ccmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *b_0, u8 *aad, | 277 | static 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)) { |