diff options
Diffstat (limited to 'net/ieee80211/ieee80211_crypt_tkip.c')
-rw-r--r-- | net/ieee80211/ieee80211_crypt_tkip.c | 133 |
1 files changed, 54 insertions, 79 deletions
diff --git a/net/ieee80211/ieee80211_crypt_tkip.c b/net/ieee80211/ieee80211_crypt_tkip.c index f91d92c6df25..d4f9164be1a1 100644 --- a/net/ieee80211/ieee80211_crypt_tkip.c +++ b/net/ieee80211/ieee80211_crypt_tkip.c | |||
@@ -23,7 +23,6 @@ | |||
23 | 23 | ||
24 | #include <net/ieee80211.h> | 24 | #include <net/ieee80211.h> |
25 | 25 | ||
26 | |||
27 | #include <linux/crypto.h> | 26 | #include <linux/crypto.h> |
28 | #include <asm/scatterlist.h> | 27 | #include <asm/scatterlist.h> |
29 | #include <linux/crc32.h> | 28 | #include <linux/crc32.h> |
@@ -62,7 +61,7 @@ struct ieee80211_tkip_data { | |||
62 | u8 rx_hdr[16], tx_hdr[16]; | 61 | u8 rx_hdr[16], tx_hdr[16]; |
63 | }; | 62 | }; |
64 | 63 | ||
65 | static void * ieee80211_tkip_init(int key_idx) | 64 | static void *ieee80211_tkip_init(int key_idx) |
66 | { | 65 | { |
67 | struct ieee80211_tkip_data *priv; | 66 | struct ieee80211_tkip_data *priv; |
68 | 67 | ||
@@ -88,7 +87,7 @@ static void * ieee80211_tkip_init(int key_idx) | |||
88 | 87 | ||
89 | return priv; | 88 | return priv; |
90 | 89 | ||
91 | fail: | 90 | fail: |
92 | if (priv) { | 91 | if (priv) { |
93 | if (priv->tfm_michael) | 92 | if (priv->tfm_michael) |
94 | crypto_free_tfm(priv->tfm_michael); | 93 | crypto_free_tfm(priv->tfm_michael); |
@@ -100,7 +99,6 @@ fail: | |||
100 | return NULL; | 99 | return NULL; |
101 | } | 100 | } |
102 | 101 | ||
103 | |||
104 | static void ieee80211_tkip_deinit(void *priv) | 102 | static void ieee80211_tkip_deinit(void *priv) |
105 | { | 103 | { |
106 | struct ieee80211_tkip_data *_priv = priv; | 104 | struct ieee80211_tkip_data *_priv = priv; |
@@ -111,51 +109,42 @@ static void ieee80211_tkip_deinit(void *priv) | |||
111 | kfree(priv); | 109 | kfree(priv); |
112 | } | 110 | } |
113 | 111 | ||
114 | |||
115 | static inline u16 RotR1(u16 val) | 112 | static inline u16 RotR1(u16 val) |
116 | { | 113 | { |
117 | return (val >> 1) | (val << 15); | 114 | return (val >> 1) | (val << 15); |
118 | } | 115 | } |
119 | 116 | ||
120 | |||
121 | static inline u8 Lo8(u16 val) | 117 | static inline u8 Lo8(u16 val) |
122 | { | 118 | { |
123 | return val & 0xff; | 119 | return val & 0xff; |
124 | } | 120 | } |
125 | 121 | ||
126 | |||
127 | static inline u8 Hi8(u16 val) | 122 | static inline u8 Hi8(u16 val) |
128 | { | 123 | { |
129 | return val >> 8; | 124 | return val >> 8; |
130 | } | 125 | } |
131 | 126 | ||
132 | |||
133 | static inline u16 Lo16(u32 val) | 127 | static inline u16 Lo16(u32 val) |
134 | { | 128 | { |
135 | return val & 0xffff; | 129 | return val & 0xffff; |
136 | } | 130 | } |
137 | 131 | ||
138 | |||
139 | static inline u16 Hi16(u32 val) | 132 | static inline u16 Hi16(u32 val) |
140 | { | 133 | { |
141 | return val >> 16; | 134 | return val >> 16; |
142 | } | 135 | } |
143 | 136 | ||
144 | |||
145 | static inline u16 Mk16(u8 hi, u8 lo) | 137 | static inline u16 Mk16(u8 hi, u8 lo) |
146 | { | 138 | { |
147 | return lo | (((u16) hi) << 8); | 139 | return lo | (((u16) hi) << 8); |
148 | } | 140 | } |
149 | 141 | ||
150 | 142 | static inline u16 Mk16_le(u16 * v) | |
151 | static inline u16 Mk16_le(u16 *v) | ||
152 | { | 143 | { |
153 | return le16_to_cpu(*v); | 144 | return le16_to_cpu(*v); |
154 | } | 145 | } |
155 | 146 | ||
156 | 147 | static const u16 Sbox[256] = { | |
157 | static const u16 Sbox[256] = | ||
158 | { | ||
159 | 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154, | 148 | 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154, |
160 | 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A, | 149 | 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A, |
161 | 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B, | 150 | 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B, |
@@ -190,17 +179,16 @@ static const u16 Sbox[256] = | |||
190 | 0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A, | 179 | 0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A, |
191 | }; | 180 | }; |
192 | 181 | ||
193 | |||
194 | static inline u16 _S_(u16 v) | 182 | static inline u16 _S_(u16 v) |
195 | { | 183 | { |
196 | u16 t = Sbox[Hi8(v)]; | 184 | u16 t = Sbox[Hi8(v)]; |
197 | return Sbox[Lo8(v)] ^ ((t << 8) | (t >> 8)); | 185 | return Sbox[Lo8(v)] ^ ((t << 8) | (t >> 8)); |
198 | } | 186 | } |
199 | 187 | ||
200 | |||
201 | #define PHASE1_LOOP_COUNT 8 | 188 | #define PHASE1_LOOP_COUNT 8 |
202 | 189 | ||
203 | static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) | 190 | static void tkip_mixing_phase1(u16 * TTAK, const u8 * TK, const u8 * TA, |
191 | u32 IV32) | ||
204 | { | 192 | { |
205 | int i, j; | 193 | int i, j; |
206 | 194 | ||
@@ -221,13 +209,12 @@ static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) | |||
221 | } | 209 | } |
222 | } | 210 | } |
223 | 211 | ||
224 | 212 | static void tkip_mixing_phase2(u8 * WEPSeed, const u8 * TK, const u16 * TTAK, | |
225 | static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, | ||
226 | u16 IV16) | 213 | u16 IV16) |
227 | { | 214 | { |
228 | /* Make temporary area overlap WEP seed so that the final copy can be | 215 | /* Make temporary area overlap WEP seed so that the final copy can be |
229 | * avoided on little endian hosts. */ | 216 | * avoided on little endian hosts. */ |
230 | u16 *PPK = (u16 *) &WEPSeed[4]; | 217 | u16 *PPK = (u16 *) & WEPSeed[4]; |
231 | 218 | ||
232 | /* Step 1 - make copy of TTAK and bring in TSC */ | 219 | /* Step 1 - make copy of TTAK and bring in TSC */ |
233 | PPK[0] = TTAK[0]; | 220 | PPK[0] = TTAK[0]; |
@@ -238,15 +225,15 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, | |||
238 | PPK[5] = TTAK[4] + IV16; | 225 | PPK[5] = TTAK[4] + IV16; |
239 | 226 | ||
240 | /* Step 2 - 96-bit bijective mixing using S-box */ | 227 | /* Step 2 - 96-bit bijective mixing using S-box */ |
241 | PPK[0] += _S_(PPK[5] ^ Mk16_le((u16 *) &TK[0])); | 228 | PPK[0] += _S_(PPK[5] ^ Mk16_le((u16 *) & TK[0])); |
242 | PPK[1] += _S_(PPK[0] ^ Mk16_le((u16 *) &TK[2])); | 229 | PPK[1] += _S_(PPK[0] ^ Mk16_le((u16 *) & TK[2])); |
243 | PPK[2] += _S_(PPK[1] ^ Mk16_le((u16 *) &TK[4])); | 230 | PPK[2] += _S_(PPK[1] ^ Mk16_le((u16 *) & TK[4])); |
244 | PPK[3] += _S_(PPK[2] ^ Mk16_le((u16 *) &TK[6])); | 231 | PPK[3] += _S_(PPK[2] ^ Mk16_le((u16 *) & TK[6])); |
245 | PPK[4] += _S_(PPK[3] ^ Mk16_le((u16 *) &TK[8])); | 232 | PPK[4] += _S_(PPK[3] ^ Mk16_le((u16 *) & TK[8])); |
246 | PPK[5] += _S_(PPK[4] ^ Mk16_le((u16 *) &TK[10])); | 233 | PPK[5] += _S_(PPK[4] ^ Mk16_le((u16 *) & TK[10])); |
247 | 234 | ||
248 | PPK[0] += RotR1(PPK[5] ^ Mk16_le((u16 *) &TK[12])); | 235 | PPK[0] += RotR1(PPK[5] ^ Mk16_le((u16 *) & TK[12])); |
249 | PPK[1] += RotR1(PPK[0] ^ Mk16_le((u16 *) &TK[14])); | 236 | PPK[1] += RotR1(PPK[0] ^ Mk16_le((u16 *) & TK[14])); |
250 | PPK[2] += RotR1(PPK[1]); | 237 | PPK[2] += RotR1(PPK[1]); |
251 | PPK[3] += RotR1(PPK[2]); | 238 | PPK[3] += RotR1(PPK[2]); |
252 | PPK[4] += RotR1(PPK[3]); | 239 | PPK[4] += RotR1(PPK[3]); |
@@ -257,7 +244,7 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, | |||
257 | WEPSeed[0] = Hi8(IV16); | 244 | WEPSeed[0] = Hi8(IV16); |
258 | WEPSeed[1] = (Hi8(IV16) | 0x20) & 0x7F; | 245 | WEPSeed[1] = (Hi8(IV16) | 0x20) & 0x7F; |
259 | WEPSeed[2] = Lo8(IV16); | 246 | WEPSeed[2] = Lo8(IV16); |
260 | WEPSeed[3] = Lo8((PPK[5] ^ Mk16_le((u16 *) &TK[0])) >> 1); | 247 | WEPSeed[3] = Lo8((PPK[5] ^ Mk16_le((u16 *) & TK[0])) >> 1); |
261 | 248 | ||
262 | #ifdef __BIG_ENDIAN | 249 | #ifdef __BIG_ENDIAN |
263 | { | 250 | { |
@@ -281,7 +268,7 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
281 | skb->len < hdr_len) | 268 | skb->len < hdr_len) |
282 | return -1; | 269 | return -1; |
283 | 270 | ||
284 | hdr = (struct ieee80211_hdr *) skb->data; | 271 | hdr = (struct ieee80211_hdr *)skb->data; |
285 | if (!tkey->tx_phase1_done) { | 272 | if (!tkey->tx_phase1_done) { |
286 | tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, | 273 | tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, |
287 | tkey->tx_iv32); | 274 | tkey->tx_iv32); |
@@ -298,7 +285,7 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
298 | *pos++ = rc4key[0]; | 285 | *pos++ = rc4key[0]; |
299 | *pos++ = rc4key[1]; | 286 | *pos++ = rc4key[1]; |
300 | *pos++ = rc4key[2]; | 287 | *pos++ = rc4key[2]; |
301 | *pos++ = (tkey->key_idx << 6) | (1 << 5) /* Ext IV included */; | 288 | *pos++ = (tkey->key_idx << 6) | (1 << 5) /* Ext IV included */ ; |
302 | *pos++ = tkey->tx_iv32 & 0xff; | 289 | *pos++ = tkey->tx_iv32 & 0xff; |
303 | *pos++ = (tkey->tx_iv32 >> 8) & 0xff; | 290 | *pos++ = (tkey->tx_iv32 >> 8) & 0xff; |
304 | *pos++ = (tkey->tx_iv32 >> 16) & 0xff; | 291 | *pos++ = (tkey->tx_iv32 >> 16) & 0xff; |
@@ -341,7 +328,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
341 | if (skb->len < hdr_len + 8 + 4) | 328 | if (skb->len < hdr_len + 8 + 4) |
342 | return -1; | 329 | return -1; |
343 | 330 | ||
344 | hdr = (struct ieee80211_hdr *) skb->data; | 331 | hdr = (struct ieee80211_hdr *)skb->data; |
345 | pos = skb->data + hdr_len; | 332 | pos = skb->data + hdr_len; |
346 | keyidx = pos[3]; | 333 | keyidx = pos[3]; |
347 | if (!(keyidx & (1 << 5))) { | 334 | if (!(keyidx & (1 << 5))) { |
@@ -427,9 +414,8 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
427 | return keyidx; | 414 | return keyidx; |
428 | } | 415 | } |
429 | 416 | ||
430 | 417 | static int michael_mic(struct ieee80211_tkip_data *tkey, u8 * key, u8 * hdr, | |
431 | static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, | 418 | u8 * data, size_t data_len, u8 * mic) |
432 | u8 *data, size_t data_len, u8 *mic) | ||
433 | { | 419 | { |
434 | struct scatterlist sg[2]; | 420 | struct scatterlist sg[2]; |
435 | 421 | ||
@@ -453,37 +439,37 @@ static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr, | |||
453 | return 0; | 439 | return 0; |
454 | } | 440 | } |
455 | 441 | ||
456 | static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) | 442 | static void michael_mic_hdr(struct sk_buff *skb, u8 * hdr) |
457 | { | 443 | { |
458 | struct ieee80211_hdr *hdr11; | 444 | struct ieee80211_hdr *hdr11; |
459 | 445 | ||
460 | hdr11 = (struct ieee80211_hdr *) skb->data; | 446 | hdr11 = (struct ieee80211_hdr *)skb->data; |
461 | switch (le16_to_cpu(hdr11->frame_ctl) & | 447 | switch (le16_to_cpu(hdr11->frame_ctl) & |
462 | (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { | 448 | (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { |
463 | case IEEE80211_FCTL_TODS: | 449 | case IEEE80211_FCTL_TODS: |
464 | memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */ | 450 | memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */ |
465 | memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */ | 451 | memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */ |
466 | break; | 452 | break; |
467 | case IEEE80211_FCTL_FROMDS: | 453 | case IEEE80211_FCTL_FROMDS: |
468 | memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */ | 454 | memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */ |
469 | memcpy(hdr + ETH_ALEN, hdr11->addr3, ETH_ALEN); /* SA */ | 455 | memcpy(hdr + ETH_ALEN, hdr11->addr3, ETH_ALEN); /* SA */ |
470 | break; | 456 | break; |
471 | case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS: | 457 | case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS: |
472 | memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */ | 458 | memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */ |
473 | memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */ | 459 | memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */ |
474 | break; | 460 | break; |
475 | case 0: | 461 | case 0: |
476 | memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */ | 462 | memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */ |
477 | memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */ | 463 | memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */ |
478 | break; | 464 | break; |
479 | } | 465 | } |
480 | 466 | ||
481 | hdr[12] = 0; /* priority */ | 467 | hdr[12] = 0; /* priority */ |
482 | hdr[13] = hdr[14] = hdr[15] = 0; /* reserved */ | 468 | hdr[13] = hdr[14] = hdr[15] = 0; /* reserved */ |
483 | } | 469 | } |
484 | 470 | ||
485 | 471 | static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, | |
486 | static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) | 472 | void *priv) |
487 | { | 473 | { |
488 | struct ieee80211_tkip_data *tkey = priv; | 474 | struct ieee80211_tkip_data *tkey = priv; |
489 | u8 *pos; | 475 | u8 *pos; |
@@ -504,11 +490,9 @@ static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *pri | |||
504 | return 0; | 490 | return 0; |
505 | } | 491 | } |
506 | 492 | ||
507 | |||
508 | #if WIRELESS_EXT >= 18 | 493 | #if WIRELESS_EXT >= 18 |
509 | static void ieee80211_michael_mic_failure(struct net_device *dev, | 494 | static void ieee80211_michael_mic_failure(struct net_device *dev, |
510 | struct ieee80211_hdr *hdr, | 495 | struct ieee80211_hdr *hdr, int keyidx) |
511 | int keyidx) | ||
512 | { | 496 | { |
513 | union iwreq_data wrqu; | 497 | union iwreq_data wrqu; |
514 | struct iw_michaelmicfailure ev; | 498 | struct iw_michaelmicfailure ev; |
@@ -524,12 +508,11 @@ static void ieee80211_michael_mic_failure(struct net_device *dev, | |||
524 | memcpy(ev.src_addr.sa_data, hdr->addr2, ETH_ALEN); | 508 | memcpy(ev.src_addr.sa_data, hdr->addr2, ETH_ALEN); |
525 | memset(&wrqu, 0, sizeof(wrqu)); | 509 | memset(&wrqu, 0, sizeof(wrqu)); |
526 | wrqu.data.length = sizeof(ev); | 510 | wrqu.data.length = sizeof(ev); |
527 | wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev); | 511 | wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&ev); |
528 | } | 512 | } |
529 | #elif WIRELESS_EXT >= 15 | 513 | #elif WIRELESS_EXT >= 15 |
530 | static void ieee80211_michael_mic_failure(struct net_device *dev, | 514 | static void ieee80211_michael_mic_failure(struct net_device *dev, |
531 | struct ieee80211_hdr *hdr, | 515 | struct ieee80211_hdr *hdr, int keyidx) |
532 | int keyidx) | ||
533 | { | 516 | { |
534 | union iwreq_data wrqu; | 517 | union iwreq_data wrqu; |
535 | char buf[128]; | 518 | char buf[128]; |
@@ -542,17 +525,16 @@ static void ieee80211_michael_mic_failure(struct net_device *dev, | |||
542 | wrqu.data.length = strlen(buf); | 525 | wrqu.data.length = strlen(buf); |
543 | wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); | 526 | wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf); |
544 | } | 527 | } |
545 | #else /* WIRELESS_EXT >= 15 */ | 528 | #else /* WIRELESS_EXT >= 15 */ |
546 | static inline void ieee80211_michael_mic_failure(struct net_device *dev, | 529 | static inline void ieee80211_michael_mic_failure(struct net_device *dev, |
547 | struct ieee80211_hdr *hdr, | 530 | struct ieee80211_hdr *hdr, |
548 | int keyidx) | 531 | int keyidx) |
549 | { | 532 | { |
550 | } | 533 | } |
551 | #endif /* WIRELESS_EXT >= 15 */ | 534 | #endif /* WIRELESS_EXT >= 15 */ |
552 | |||
553 | 535 | ||
554 | static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, | 536 | static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, |
555 | int hdr_len, void *priv) | 537 | int hdr_len, void *priv) |
556 | { | 538 | { |
557 | struct ieee80211_tkip_data *tkey = priv; | 539 | struct ieee80211_tkip_data *tkey = priv; |
558 | u8 mic[8]; | 540 | u8 mic[8]; |
@@ -566,7 +548,7 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, | |||
566 | return -1; | 548 | return -1; |
567 | if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { | 549 | if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { |
568 | struct ieee80211_hdr *hdr; | 550 | struct ieee80211_hdr *hdr; |
569 | hdr = (struct ieee80211_hdr *) skb->data; | 551 | hdr = (struct ieee80211_hdr *)skb->data; |
570 | printk(KERN_DEBUG "%s: Michael MIC verification failed for " | 552 | printk(KERN_DEBUG "%s: Michael MIC verification failed for " |
571 | "MSDU from " MAC_FMT " keyidx=%d\n", | 553 | "MSDU from " MAC_FMT " keyidx=%d\n", |
572 | skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), | 554 | skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), |
@@ -587,8 +569,7 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, | |||
587 | return 0; | 569 | return 0; |
588 | } | 570 | } |
589 | 571 | ||
590 | 572 | static int ieee80211_tkip_set_key(void *key, int len, u8 * seq, void *priv) | |
591 | static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) | ||
592 | { | 573 | { |
593 | struct ieee80211_tkip_data *tkey = priv; | 574 | struct ieee80211_tkip_data *tkey = priv; |
594 | int keyidx; | 575 | int keyidx; |
@@ -603,10 +584,10 @@ static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) | |||
603 | if (len == TKIP_KEY_LEN) { | 584 | if (len == TKIP_KEY_LEN) { |
604 | memcpy(tkey->key, key, TKIP_KEY_LEN); | 585 | memcpy(tkey->key, key, TKIP_KEY_LEN); |
605 | tkey->key_set = 1; | 586 | tkey->key_set = 1; |
606 | tkey->tx_iv16 = 1; /* TSC is initialized to 1 */ | 587 | tkey->tx_iv16 = 1; /* TSC is initialized to 1 */ |
607 | if (seq) { | 588 | if (seq) { |
608 | tkey->rx_iv32 = (seq[5] << 24) | (seq[4] << 16) | | 589 | tkey->rx_iv32 = (seq[5] << 24) | (seq[4] << 16) | |
609 | (seq[3] << 8) | seq[2]; | 590 | (seq[3] << 8) | seq[2]; |
610 | tkey->rx_iv16 = (seq[1] << 8) | seq[0]; | 591 | tkey->rx_iv16 = (seq[1] << 8) | seq[0]; |
611 | } | 592 | } |
612 | } else if (len == 0) | 593 | } else if (len == 0) |
@@ -617,8 +598,7 @@ static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv) | |||
617 | return 0; | 598 | return 0; |
618 | } | 599 | } |
619 | 600 | ||
620 | 601 | static int ieee80211_tkip_get_key(void *key, int len, u8 * seq, void *priv) | |
621 | static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) | ||
622 | { | 602 | { |
623 | struct ieee80211_tkip_data *tkey = priv; | 603 | struct ieee80211_tkip_data *tkey = priv; |
624 | 604 | ||
@@ -647,8 +627,7 @@ static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) | |||
647 | return TKIP_KEY_LEN; | 627 | return TKIP_KEY_LEN; |
648 | } | 628 | } |
649 | 629 | ||
650 | 630 | static char *ieee80211_tkip_print_stats(char *p, void *priv) | |
651 | static char * ieee80211_tkip_print_stats(char *p, void *priv) | ||
652 | { | 631 | { |
653 | struct ieee80211_tkip_data *tkip = priv; | 632 | struct ieee80211_tkip_data *tkip = priv; |
654 | p += sprintf(p, "key[%d] alg=TKIP key_set=%d " | 633 | p += sprintf(p, "key[%d] alg=TKIP key_set=%d " |
@@ -674,7 +653,6 @@ static char * ieee80211_tkip_print_stats(char *p, void *priv) | |||
674 | return p; | 653 | return p; |
675 | } | 654 | } |
676 | 655 | ||
677 | |||
678 | static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { | 656 | static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { |
679 | .name = "TKIP", | 657 | .name = "TKIP", |
680 | .init = ieee80211_tkip_init, | 658 | .init = ieee80211_tkip_init, |
@@ -686,23 +664,20 @@ static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { | |||
686 | .set_key = ieee80211_tkip_set_key, | 664 | .set_key = ieee80211_tkip_set_key, |
687 | .get_key = ieee80211_tkip_get_key, | 665 | .get_key = ieee80211_tkip_get_key, |
688 | .print_stats = ieee80211_tkip_print_stats, | 666 | .print_stats = ieee80211_tkip_print_stats, |
689 | .extra_prefix_len = 4 + 4, /* IV + ExtIV */ | 667 | .extra_prefix_len = 4 + 4, /* IV + ExtIV */ |
690 | .extra_postfix_len = 8 + 4, /* MIC + ICV */ | 668 | .extra_postfix_len = 8 + 4, /* MIC + ICV */ |
691 | .owner = THIS_MODULE, | 669 | .owner = THIS_MODULE, |
692 | }; | 670 | }; |
693 | 671 | ||
694 | |||
695 | static int __init ieee80211_crypto_tkip_init(void) | 672 | static int __init ieee80211_crypto_tkip_init(void) |
696 | { | 673 | { |
697 | return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip); | 674 | return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip); |
698 | } | 675 | } |
699 | 676 | ||
700 | |||
701 | static void __exit ieee80211_crypto_tkip_exit(void) | 677 | static void __exit ieee80211_crypto_tkip_exit(void) |
702 | { | 678 | { |
703 | ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip); | 679 | ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip); |
704 | } | 680 | } |
705 | 681 | ||
706 | |||
707 | module_init(ieee80211_crypto_tkip_init); | 682 | module_init(ieee80211_crypto_tkip_init); |
708 | module_exit(ieee80211_crypto_tkip_exit); | 683 | module_exit(ieee80211_crypto_tkip_exit); |