diff options
Diffstat (limited to 'net/ieee80211/ieee80211_crypt_ccmp.c')
-rw-r--r-- | net/ieee80211/ieee80211_crypt_ccmp.c | 75 |
1 files changed, 46 insertions, 29 deletions
diff --git a/net/ieee80211/ieee80211_crypt_ccmp.c b/net/ieee80211/ieee80211_crypt_ccmp.c index 8fc13f45971e..05a853c13012 100644 --- a/net/ieee80211/ieee80211_crypt_ccmp.c +++ b/net/ieee80211/ieee80211_crypt_ccmp.c | |||
@@ -119,7 +119,7 @@ static inline void xor_block(u8 * b, u8 * a, size_t len) | |||
119 | } | 119 | } |
120 | 120 | ||
121 | static void ccmp_init_blocks(struct crypto_tfm *tfm, | 121 | static void ccmp_init_blocks(struct crypto_tfm *tfm, |
122 | struct ieee80211_hdr *hdr, | 122 | struct ieee80211_hdr_4addr *hdr, |
123 | u8 * pn, size_t dlen, u8 * b0, u8 * auth, u8 * s0) | 123 | u8 * pn, size_t dlen, u8 * b0, u8 * auth, u8 * s0) |
124 | { | 124 | { |
125 | u8 *pos, qc = 0; | 125 | u8 *pos, qc = 0; |
@@ -191,26 +191,18 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm, | |||
191 | ieee80211_ccmp_aes_encrypt(tfm, b0, s0); | 191 | ieee80211_ccmp_aes_encrypt(tfm, b0, s0); |
192 | } | 192 | } |
193 | 193 | ||
194 | static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) | 194 | static int ieee80211_ccmp_hdr(struct sk_buff *skb, int hdr_len, void *priv) |
195 | { | 195 | { |
196 | struct ieee80211_ccmp_data *key = priv; | 196 | struct ieee80211_ccmp_data *key = priv; |
197 | int data_len, i, blocks, last, len; | 197 | int i; |
198 | u8 *pos, *mic; | 198 | u8 *pos; |
199 | struct ieee80211_hdr *hdr; | ||
200 | u8 *b0 = key->tx_b0; | ||
201 | u8 *b = key->tx_b; | ||
202 | u8 *e = key->tx_e; | ||
203 | u8 *s0 = key->tx_s0; | ||
204 | 199 | ||
205 | if (skb_headroom(skb) < CCMP_HDR_LEN || | 200 | if (skb_headroom(skb) < CCMP_HDR_LEN || skb->len < hdr_len) |
206 | skb_tailroom(skb) < CCMP_MIC_LEN || skb->len < hdr_len) | ||
207 | return -1; | 201 | return -1; |
208 | 202 | ||
209 | data_len = skb->len - hdr_len; | ||
210 | pos = skb_push(skb, CCMP_HDR_LEN); | 203 | pos = skb_push(skb, CCMP_HDR_LEN); |
211 | memmove(pos, pos + CCMP_HDR_LEN, hdr_len); | 204 | memmove(pos, pos + CCMP_HDR_LEN, hdr_len); |
212 | pos += hdr_len; | 205 | pos += hdr_len; |
213 | mic = skb_put(skb, CCMP_MIC_LEN); | ||
214 | 206 | ||
215 | i = CCMP_PN_LEN - 1; | 207 | i = CCMP_PN_LEN - 1; |
216 | while (i >= 0) { | 208 | while (i >= 0) { |
@@ -229,7 +221,31 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
229 | *pos++ = key->tx_pn[1]; | 221 | *pos++ = key->tx_pn[1]; |
230 | *pos++ = key->tx_pn[0]; | 222 | *pos++ = key->tx_pn[0]; |
231 | 223 | ||
232 | hdr = (struct ieee80211_hdr *)skb->data; | 224 | return CCMP_HDR_LEN; |
225 | } | ||
226 | |||
227 | static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) | ||
228 | { | ||
229 | struct ieee80211_ccmp_data *key = priv; | ||
230 | int data_len, i, blocks, last, len; | ||
231 | u8 *pos, *mic; | ||
232 | struct ieee80211_hdr_4addr *hdr; | ||
233 | u8 *b0 = key->tx_b0; | ||
234 | u8 *b = key->tx_b; | ||
235 | u8 *e = key->tx_e; | ||
236 | u8 *s0 = key->tx_s0; | ||
237 | |||
238 | if (skb_tailroom(skb) < CCMP_MIC_LEN || skb->len < hdr_len) | ||
239 | return -1; | ||
240 | |||
241 | data_len = skb->len - hdr_len; | ||
242 | len = ieee80211_ccmp_hdr(skb, hdr_len, priv); | ||
243 | if (len < 0) | ||
244 | return -1; | ||
245 | |||
246 | pos = skb->data + hdr_len + CCMP_HDR_LEN; | ||
247 | mic = skb_put(skb, CCMP_MIC_LEN); | ||
248 | hdr = (struct ieee80211_hdr_4addr *)skb->data; | ||
233 | ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); | 249 | ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); |
234 | 250 | ||
235 | blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; | 251 | blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; |
@@ -258,7 +274,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
258 | { | 274 | { |
259 | struct ieee80211_ccmp_data *key = priv; | 275 | struct ieee80211_ccmp_data *key = priv; |
260 | u8 keyidx, *pos; | 276 | u8 keyidx, *pos; |
261 | struct ieee80211_hdr *hdr; | 277 | struct ieee80211_hdr_4addr *hdr; |
262 | u8 *b0 = key->rx_b0; | 278 | u8 *b0 = key->rx_b0; |
263 | u8 *b = key->rx_b; | 279 | u8 *b = key->rx_b; |
264 | u8 *a = key->rx_a; | 280 | u8 *a = key->rx_a; |
@@ -272,7 +288,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
272 | return -1; | 288 | return -1; |
273 | } | 289 | } |
274 | 290 | ||
275 | hdr = (struct ieee80211_hdr *)skb->data; | 291 | hdr = (struct ieee80211_hdr_4addr *)skb->data; |
276 | pos = skb->data + hdr_len; | 292 | pos = skb->data + hdr_len; |
277 | keyidx = pos[3]; | 293 | keyidx = pos[3]; |
278 | if (!(keyidx & (1 << 5))) { | 294 | if (!(keyidx & (1 << 5))) { |
@@ -426,19 +442,20 @@ static char *ieee80211_ccmp_print_stats(char *p, void *priv) | |||
426 | } | 442 | } |
427 | 443 | ||
428 | static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { | 444 | static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { |
429 | .name = "CCMP", | 445 | .name = "CCMP", |
430 | .init = ieee80211_ccmp_init, | 446 | .init = ieee80211_ccmp_init, |
431 | .deinit = ieee80211_ccmp_deinit, | 447 | .deinit = ieee80211_ccmp_deinit, |
432 | .encrypt_mpdu = ieee80211_ccmp_encrypt, | 448 | .build_iv = ieee80211_ccmp_hdr, |
433 | .decrypt_mpdu = ieee80211_ccmp_decrypt, | 449 | .encrypt_mpdu = ieee80211_ccmp_encrypt, |
434 | .encrypt_msdu = NULL, | 450 | .decrypt_mpdu = ieee80211_ccmp_decrypt, |
435 | .decrypt_msdu = NULL, | 451 | .encrypt_msdu = NULL, |
436 | .set_key = ieee80211_ccmp_set_key, | 452 | .decrypt_msdu = NULL, |
437 | .get_key = ieee80211_ccmp_get_key, | 453 | .set_key = ieee80211_ccmp_set_key, |
438 | .print_stats = ieee80211_ccmp_print_stats, | 454 | .get_key = ieee80211_ccmp_get_key, |
439 | .extra_prefix_len = CCMP_HDR_LEN, | 455 | .print_stats = ieee80211_ccmp_print_stats, |
440 | .extra_postfix_len = CCMP_MIC_LEN, | 456 | .extra_mpdu_prefix_len = CCMP_HDR_LEN, |
441 | .owner = THIS_MODULE, | 457 | .extra_mpdu_postfix_len = CCMP_MIC_LEN, |
458 | .owner = THIS_MODULE, | ||
442 | }; | 459 | }; |
443 | 460 | ||
444 | static int __init ieee80211_crypto_ccmp_init(void) | 461 | static int __init ieee80211_crypto_ccmp_init(void) |