diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-07-02 19:30:53 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-07-08 14:16:02 -0400 |
commit | 5fdae6b37e9346dbaea1e51ed6235ed0269d445d (patch) | |
tree | a01b0978b4e9c175189b54a641d00e4b1d8b0a1f /net/mac80211 | |
parent | feccb466944cb1aeaabc701cfde6771f3be74919 (diff) |
mac80211: aes_ccm.c remove crypto wrapper and extra args
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r-- | net/mac80211/aes_ccm.c | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/net/mac80211/aes_ccm.c b/net/mac80211/aes_ccm.c index e756ed931164..a87cb3ba2df6 100644 --- a/net/mac80211/aes_ccm.c +++ b/net/mac80211/aes_ccm.c | |||
@@ -16,31 +16,28 @@ | |||
16 | #include "key.h" | 16 | #include "key.h" |
17 | #include "aes_ccm.h" | 17 | #include "aes_ccm.h" |
18 | 18 | ||
19 | 19 | static void aes_ccm_prepare(struct crypto_cipher *tfm, u8 *scratch, u8 *a) | |
20 | static void ieee80211_aes_encrypt(struct crypto_cipher *tfm, | ||
21 | const u8 pt[16], u8 ct[16]) | ||
22 | { | ||
23 | crypto_cipher_encrypt_one(tfm, ct, pt); | ||
24 | } | ||
25 | |||
26 | |||
27 | static inline void aes_ccm_prepare(struct crypto_cipher *tfm, u8 *b_0, u8 *aad, | ||
28 | u8 *b, u8 *s_0, u8 *a) | ||
29 | { | 20 | { |
30 | int i; | 21 | int i; |
22 | u8 *b_0, *aad, *b, *s_0; | ||
31 | 23 | ||
32 | ieee80211_aes_encrypt(tfm, b_0, b); | 24 | b_0 = scratch + 3 * AES_BLOCK_LEN; |
25 | aad = scratch + 4 * AES_BLOCK_LEN; | ||
26 | b = scratch; | ||
27 | s_0 = scratch + AES_BLOCK_LEN; | ||
28 | |||
29 | crypto_cipher_encrypt_one(tfm, b, b_0); | ||
33 | 30 | ||
34 | /* Extra Authenticate-only data (always two AES blocks) */ | 31 | /* Extra Authenticate-only data (always two AES blocks) */ |
35 | for (i = 0; i < AES_BLOCK_LEN; i++) | 32 | for (i = 0; i < AES_BLOCK_LEN; i++) |
36 | aad[i] ^= b[i]; | 33 | aad[i] ^= b[i]; |
37 | ieee80211_aes_encrypt(tfm, aad, b); | 34 | crypto_cipher_encrypt_one(tfm, b, aad); |
38 | 35 | ||
39 | aad += AES_BLOCK_LEN; | 36 | aad += AES_BLOCK_LEN; |
40 | 37 | ||
41 | for (i = 0; i < AES_BLOCK_LEN; i++) | 38 | for (i = 0; i < AES_BLOCK_LEN; i++) |
42 | aad[i] ^= b[i]; | 39 | aad[i] ^= b[i]; |
43 | ieee80211_aes_encrypt(tfm, aad, a); | 40 | crypto_cipher_encrypt_one(tfm, a, aad); |
44 | 41 | ||
45 | /* Mask out bits from auth-only-b_0 */ | 42 | /* Mask out bits from auth-only-b_0 */ |
46 | b_0[0] &= 0x07; | 43 | b_0[0] &= 0x07; |
@@ -48,7 +45,7 @@ static inline void aes_ccm_prepare(struct crypto_cipher *tfm, u8 *b_0, u8 *aad, | |||
48 | /* S_0 is used to encrypt T (= MIC) */ | 45 | /* S_0 is used to encrypt T (= MIC) */ |
49 | b_0[14] = 0; | 46 | b_0[14] = 0; |
50 | b_0[15] = 0; | 47 | b_0[15] = 0; |
51 | ieee80211_aes_encrypt(tfm, b_0, s_0); | 48 | crypto_cipher_encrypt_one(tfm, s_0, b_0); |
52 | } | 49 | } |
53 | 50 | ||
54 | 51 | ||
@@ -67,7 +64,7 @@ void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *scratch, | |||
67 | 64 | ||
68 | num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_LEN); | 65 | num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_LEN); |
69 | last_len = data_len % AES_BLOCK_LEN; | 66 | last_len = data_len % AES_BLOCK_LEN; |
70 | aes_ccm_prepare(tfm, b_0, aad, b, s_0, b); | 67 | aes_ccm_prepare(tfm, scratch, b); |
71 | 68 | ||
72 | /* Process payload blocks */ | 69 | /* Process payload blocks */ |
73 | pos = data; | 70 | pos = data; |
@@ -79,11 +76,11 @@ void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *scratch, | |||
79 | /* Authentication followed by encryption */ | 76 | /* Authentication followed by encryption */ |
80 | for (i = 0; i < blen; i++) | 77 | for (i = 0; i < blen; i++) |
81 | b[i] ^= pos[i]; | 78 | b[i] ^= pos[i]; |
82 | ieee80211_aes_encrypt(tfm, b, b); | 79 | crypto_cipher_encrypt_one(tfm, b, b); |
83 | 80 | ||
84 | b_0[14] = (j >> 8) & 0xff; | 81 | b_0[14] = (j >> 8) & 0xff; |
85 | b_0[15] = j & 0xff; | 82 | b_0[15] = j & 0xff; |
86 | ieee80211_aes_encrypt(tfm, b_0, e); | 83 | crypto_cipher_encrypt_one(tfm, e, b_0); |
87 | for (i = 0; i < blen; i++) | 84 | for (i = 0; i < blen; i++) |
88 | *cpos++ = *pos++ ^ e[i]; | 85 | *cpos++ = *pos++ ^ e[i]; |
89 | } | 86 | } |
@@ -107,7 +104,7 @@ int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *scratch, | |||
107 | 104 | ||
108 | num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_LEN); | 105 | num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_LEN); |
109 | last_len = data_len % AES_BLOCK_LEN; | 106 | last_len = data_len % AES_BLOCK_LEN; |
110 | aes_ccm_prepare(tfm, b_0, aad, b, s_0, a); | 107 | aes_ccm_prepare(tfm, scratch, a); |
111 | 108 | ||
112 | /* Process payload blocks */ | 109 | /* Process payload blocks */ |
113 | cpos = cdata; | 110 | cpos = cdata; |
@@ -119,13 +116,12 @@ int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *scratch, | |||
119 | /* Decryption followed by authentication */ | 116 | /* Decryption followed by authentication */ |
120 | b_0[14] = (j >> 8) & 0xff; | 117 | b_0[14] = (j >> 8) & 0xff; |
121 | b_0[15] = j & 0xff; | 118 | b_0[15] = j & 0xff; |
122 | ieee80211_aes_encrypt(tfm, b_0, b); | 119 | crypto_cipher_encrypt_one(tfm, b, b_0); |
123 | for (i = 0; i < blen; i++) { | 120 | for (i = 0; i < blen; i++) { |
124 | *pos = *cpos++ ^ b[i]; | 121 | *pos = *cpos++ ^ b[i]; |
125 | a[i] ^= *pos++; | 122 | a[i] ^= *pos++; |
126 | } | 123 | } |
127 | 124 | crypto_cipher_encrypt_one(tfm, a, a); | |
128 | ieee80211_aes_encrypt(tfm, a, a); | ||
129 | } | 125 | } |
130 | 126 | ||
131 | for (i = 0; i < CCMP_MIC_LEN; i++) { | 127 | for (i = 0; i < CCMP_MIC_LEN; i++) { |