aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/rtl8187se
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-06-13 12:35:00 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-09-15 15:01:28 -0400
commit7fdb78d097e4282e8b54312351a135c6f54ae03c (patch)
tree95dcb165ba81f2e8ee666b93f4cf636440f86c4d /drivers/staging/rtl8187se
parent8f75675c3a99c91325f17bcc02651c4447d9fb81 (diff)
Staging: rtl8187se/ieee80211: remove superfluous JOHN_* ifdefs
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/rtl8187se')
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211.h3
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c13
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c42
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c12
4 files changed, 10 insertions, 60 deletions
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211.h b/drivers/staging/rtl8187se/ieee80211/ieee80211.h
index d3d84b642b6..fcc65a92405 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211.h
@@ -45,14 +45,11 @@
45#endif 45#endif
46*/ 46*/
47 47
48//#ifdef JOHN_HWSEC
49#define KEY_TYPE_NA 0x0 48#define KEY_TYPE_NA 0x0
50#define KEY_TYPE_WEP40 0x1 49#define KEY_TYPE_WEP40 0x1
51#define KEY_TYPE_TKIP 0x2 50#define KEY_TYPE_TKIP 0x2
52#define KEY_TYPE_CCMP 0x4 51#define KEY_TYPE_CCMP 0x4
53#define KEY_TYPE_WEP104 0x5 52#define KEY_TYPE_WEP104 0x5
54//#endif
55
56 53
57#define aSifsTime 10 54#define aSifsTime 10
58 55
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
index 21f09c62cff..2651811ad39 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
@@ -118,7 +118,6 @@ static inline void xor_block(u8 *b, u8 *a, size_t len)
118 b[i] ^= a[i]; 118 b[i] ^= a[i];
119} 119}
120 120
121#ifndef JOHN_CCMP
122static void ccmp_init_blocks(struct crypto_tfm *tfm, 121static void ccmp_init_blocks(struct crypto_tfm *tfm,
123 struct ieee80211_hdr *hdr, 122 struct ieee80211_hdr *hdr,
124 u8 *pn, size_t dlen, u8 *b0, u8 *auth, 123 u8 *pn, size_t dlen, u8 *b0, u8 *auth,
@@ -196,7 +195,6 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm,
196 b0[14] = b0[15] = 0; 195 b0[14] = b0[15] = 0;
197 ieee80211_ccmp_aes_encrypt(tfm, b0, s0); 196 ieee80211_ccmp_aes_encrypt(tfm, b0, s0);
198} 197}
199#endif
200 198
201static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) 199static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
202{ 200{
@@ -204,14 +202,13 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
204 int data_len, i; 202 int data_len, i;
205 u8 *pos; 203 u8 *pos;
206 struct ieee80211_hdr *hdr; 204 struct ieee80211_hdr *hdr;
207#ifndef JOHN_CCMP
208 int blocks, last, len; 205 int blocks, last, len;
209 u8 *mic; 206 u8 *mic;
210 u8 *b0 = key->tx_b0; 207 u8 *b0 = key->tx_b0;
211 u8 *b = key->tx_b; 208 u8 *b = key->tx_b;
212 u8 *e = key->tx_e; 209 u8 *e = key->tx_e;
213 u8 *s0 = key->tx_s0; 210 u8 *s0 = key->tx_s0;
214#endif 211
215 if (skb_headroom(skb) < CCMP_HDR_LEN || 212 if (skb_headroom(skb) < CCMP_HDR_LEN ||
216 skb_tailroom(skb) < CCMP_MIC_LEN || 213 skb_tailroom(skb) < CCMP_MIC_LEN ||
217 skb->len < hdr_len) 214 skb->len < hdr_len)
@@ -241,7 +238,6 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
241 *pos++ = key->tx_pn[0]; 238 *pos++ = key->tx_pn[0];
242 239
243 hdr = (struct ieee80211_hdr *) skb->data; 240 hdr = (struct ieee80211_hdr *) skb->data;
244#ifndef JOHN_CCMP
245 //mic is moved to here by john 241 //mic is moved to here by john
246 mic = skb_put(skb, CCMP_MIC_LEN); 242 mic = skb_put(skb, CCMP_MIC_LEN);
247 243
@@ -265,7 +261,7 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
265 261
266 for (i = 0; i < CCMP_MIC_LEN; i++) 262 for (i = 0; i < CCMP_MIC_LEN; i++)
267 mic[i] = b[i] ^ s0[i]; 263 mic[i] = b[i] ^ s0[i];
268#endif 264
269 return 0; 265 return 0;
270} 266}
271 267
@@ -276,14 +272,13 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
276 u8 keyidx, *pos; 272 u8 keyidx, *pos;
277 struct ieee80211_hdr *hdr; 273 struct ieee80211_hdr *hdr;
278 u8 pn[6]; 274 u8 pn[6];
279#ifndef JOHN_CCMP
280 size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - CCMP_MIC_LEN; 275 size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - CCMP_MIC_LEN;
281 u8 *mic = skb->data + skb->len - CCMP_MIC_LEN; 276 u8 *mic = skb->data + skb->len - CCMP_MIC_LEN;
282 u8 *b0 = key->rx_b0; 277 u8 *b0 = key->rx_b0;
283 u8 *b = key->rx_b; 278 u8 *b = key->rx_b;
284 u8 *a = key->rx_a; 279 u8 *a = key->rx_a;
285 int i, blocks, last, len; 280 int i, blocks, last, len;
286#endif 281
287 if (skb->len < hdr_len + CCMP_HDR_LEN + CCMP_MIC_LEN) { 282 if (skb->len < hdr_len + CCMP_HDR_LEN + CCMP_MIC_LEN) {
288 key->dot11RSNAStatsCCMPFormatErrors++; 283 key->dot11RSNAStatsCCMPFormatErrors++;
289 return -1; 284 return -1;
@@ -335,7 +330,6 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
335 return -4; 330 return -4;
336 } 331 }
337 332
338#ifndef JOHN_CCMP
339 ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b); 333 ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b);
340 xor_block(mic, b, CCMP_MIC_LEN); 334 xor_block(mic, b, CCMP_MIC_LEN);
341 335
@@ -366,7 +360,6 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
366 360
367 memcpy(key->rx_pn, pn, CCMP_PN_LEN); 361 memcpy(key->rx_pn, pn, CCMP_PN_LEN);
368 362
369#endif
370 /* Remove hdr and MIC */ 363 /* Remove hdr and MIC */
371 memmove(skb->data + CCMP_HDR_LEN, skb->data, hdr_len); 364 memmove(skb->data + CCMP_HDR_LEN, skb->data, hdr_len);
372 skb_pull(skb, CCMP_HDR_LEN); 365 skb_pull(skb, CCMP_HDR_LEN);
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c
index 961bcd2b635..65830759482 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c
@@ -239,7 +239,6 @@ static inline u16 _S_(u16 v)
239 return Sbox[Lo8(v)] ^ ((t << 8) | (t >> 8)); 239 return Sbox[Lo8(v)] ^ ((t << 8) | (t >> 8));
240} 240}
241 241
242#ifndef JOHN_TKIP
243#define PHASE1_LOOP_COUNT 8 242#define PHASE1_LOOP_COUNT 8
244 243
245static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) 244static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32)
@@ -309,7 +308,7 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
309 } 308 }
310#endif 309#endif
311} 310}
312#endif 311
313static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) 312static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
314{ 313{
315 struct ieee80211_tkip_data *tkey = priv; 314 struct ieee80211_tkip_data *tkey = priv;
@@ -317,11 +316,9 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
317 int len; 316 int len;
318 u8 *pos; 317 u8 *pos;
319 struct ieee80211_hdr *hdr; 318 struct ieee80211_hdr *hdr;
320#ifndef JOHN_TKIP
321 u8 rc4key[16],*icv; 319 u8 rc4key[16],*icv;
322 u32 crc; 320 u32 crc;
323 struct scatterlist sg; 321 struct scatterlist sg;
324#endif
325 int ret; 322 int ret;
326 323
327 ret = 0; 324 ret = 0;
@@ -342,7 +339,6 @@ printk("%x|", ((u32*)tkey->key)[6]);
342printk("%x\n", ((u32*)tkey->key)[7]); 339printk("%x\n", ((u32*)tkey->key)[7]);
343#endif 340#endif
344 341
345#ifndef JOHN_TKIP
346 if (!tkey->tx_phase1_done) { 342 if (!tkey->tx_phase1_done) {
347 tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, 343 tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2,
348 tkey->tx_iv32); 344 tkey->tx_iv32);
@@ -350,30 +346,20 @@ printk("%x\n", ((u32*)tkey->key)[7]);
350 } 346 }
351 tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); 347 tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
352 348
353#else
354 tkey->tx_phase1_done = 1;
355#endif /*JOHN_TKIP*/
356
357 len = skb->len - hdr_len; 349 len = skb->len - hdr_len;
358 pos = skb_push(skb, 8); 350 pos = skb_push(skb, 8);
359 memmove(pos, pos + 8, hdr_len); 351 memmove(pos, pos + 8, hdr_len);
360 pos += hdr_len; 352 pos += hdr_len;
361 353
362#ifdef JOHN_TKIP
363 *pos++ = Hi8(tkey->tx_iv16);
364 *pos++ = (Hi8(tkey->tx_iv16) | 0x20) & 0x7F;
365 *pos++ = Lo8(tkey->tx_iv16);
366#else
367 *pos++ = rc4key[0]; 354 *pos++ = rc4key[0];
368 *pos++ = rc4key[1]; 355 *pos++ = rc4key[1];
369 *pos++ = rc4key[2]; 356 *pos++ = rc4key[2];
370#endif
371 *pos++ = (tkey->key_idx << 6) | (1 << 5) /* Ext IV included */; 357 *pos++ = (tkey->key_idx << 6) | (1 << 5) /* Ext IV included */;
372 *pos++ = tkey->tx_iv32 & 0xff; 358 *pos++ = tkey->tx_iv32 & 0xff;
373 *pos++ = (tkey->tx_iv32 >> 8) & 0xff; 359 *pos++ = (tkey->tx_iv32 >> 8) & 0xff;
374 *pos++ = (tkey->tx_iv32 >> 16) & 0xff; 360 *pos++ = (tkey->tx_iv32 >> 16) & 0xff;
375 *pos++ = (tkey->tx_iv32 >> 24) & 0xff; 361 *pos++ = (tkey->tx_iv32 >> 24) & 0xff;
376#ifndef JOHN_TKIP 362
377 icv = skb_put(skb, 4); 363 icv = skb_put(skb, 4);
378 crc = ~crc32_le(~0, pos, len); 364 crc = ~crc32_le(~0, pos, len);
379 icv[0] = crc; 365 icv[0] = crc;
@@ -383,17 +369,13 @@ printk("%x\n", ((u32*)tkey->key)[7]);
383 crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); 369 crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16);
384 sg_init_one(&sg, pos, len + 4); 370 sg_init_one(&sg, pos, len + 4);
385 ret= crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); 371 ret= crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
386#endif 372
387 tkey->tx_iv16++; 373 tkey->tx_iv16++;
388 if (tkey->tx_iv16 == 0) { 374 if (tkey->tx_iv16 == 0) {
389 tkey->tx_phase1_done = 0; 375 tkey->tx_phase1_done = 0;
390 tkey->tx_iv32++; 376 tkey->tx_iv32++;
391 } 377 }
392#ifndef JOHN_TKIP
393 return ret; 378 return ret;
394#else
395 return 0;
396#endif
397} 379}
398 380
399static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) 381static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
@@ -404,13 +386,12 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
404 u32 iv32; 386 u32 iv32;
405 u16 iv16; 387 u16 iv16;
406 struct ieee80211_hdr *hdr; 388 struct ieee80211_hdr *hdr;
407#ifndef JOHN_TKIP
408 u8 icv[4]; 389 u8 icv[4];
409 u32 crc; 390 u32 crc;
410 struct scatterlist sg; 391 struct scatterlist sg;
411 u8 rc4key[16]; 392 u8 rc4key[16];
412 int plen; 393 int plen;
413#endif 394
414 if (skb->len < hdr_len + 8 + 4) 395 if (skb->len < hdr_len + 8 + 4)
415 return -1; 396 return -1;
416 397
@@ -441,7 +422,6 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
441 iv16 = (pos[0] << 8) | pos[2]; 422 iv16 = (pos[0] << 8) | pos[2];
442 iv32 = pos[4] | (pos[5] << 8) | (pos[6] << 16) | (pos[7] << 24); 423 iv32 = pos[4] | (pos[5] << 8) | (pos[6] << 16) | (pos[7] << 24);
443 pos += 8; 424 pos += 8;
444#ifndef JOHN_TKIP
445 425
446 if (iv32 < tkey->rx_iv32 || 426 if (iv32 < tkey->rx_iv32 ||
447 (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) { 427 (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) {
@@ -492,8 +472,6 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
492 return -5; 472 return -5;
493 } 473 }
494 474
495#endif /* JOHN_TKIP */
496
497 /* Update real counters only after Michael MIC verification has 475 /* Update real counters only after Michael MIC verification has
498 * completed */ 476 * completed */
499 tkey->rx_iv32_new = iv32; 477 tkey->rx_iv32_new = iv32;
@@ -504,18 +482,6 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
504 skb_pull(skb, 8); 482 skb_pull(skb, 8);
505 skb_trim(skb, skb->len - 4); 483 skb_trim(skb, skb->len - 4);
506 484
507//john's test
508#ifdef JOHN_DUMP
509if( ((u16*)skb->data)[0] & 0x4000){
510 printk("@@ rx decrypted skb->data");
511 int i;
512 for(i=0;i<skb->len;i++){
513 if( (i%24)==0 ) printk("\n");
514 printk("%2x ", ((u8*)skb->data)[i]);
515 }
516 printk("\n");
517}
518#endif /*JOHN_DUMP*/
519 return keyidx; 485 return keyidx;
520} 486}
521 487
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c
index 371ef871222..f6b3e6380e2 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c
@@ -116,11 +116,10 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
116 u32 klen, len; 116 u32 klen, len;
117 u8 key[WEP_KEY_LEN + 3]; 117 u8 key[WEP_KEY_LEN + 3];
118 u8 *pos; 118 u8 *pos;
119#ifndef JOHN_HWSEC
120 u32 crc; 119 u32 crc;
121 u8 *icv; 120 u8 *icv;
122 struct scatterlist sg; 121 struct scatterlist sg;
123#endif 122
124 if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 || 123 if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 ||
125 skb->len < hdr_len) 124 skb->len < hdr_len)
126 return -1; 125 return -1;
@@ -152,7 +151,6 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
152 /* Copy rest of the WEP key (the secret part) */ 151 /* Copy rest of the WEP key (the secret part) */
153 memcpy(key + 3, wep->key, wep->key_len); 152 memcpy(key + 3, wep->key, wep->key_len);
154 153
155#ifndef JOHN_HWSEC
156 /* Append little-endian CRC32 and encrypt it to produce ICV */ 154 /* Append little-endian CRC32 and encrypt it to produce ICV */
157 crc = ~crc32_le(~0, pos, len); 155 crc = ~crc32_le(~0, pos, len);
158 icv = skb_put(skb, 4); 156 icv = skb_put(skb, 4);
@@ -165,8 +163,6 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
165 sg_init_one(&sg, pos, len + 4); 163 sg_init_one(&sg, pos, len + 4);
166 164
167 return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); 165 return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
168#endif /* JOHN_HWSEC */
169 return 0;
170} 166}
171 167
172 168
@@ -184,11 +180,10 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
184 u32 klen, plen; 180 u32 klen, plen;
185 u8 key[WEP_KEY_LEN + 3]; 181 u8 key[WEP_KEY_LEN + 3];
186 u8 keyidx, *pos; 182 u8 keyidx, *pos;
187#ifndef JOHN_HWSEC
188 u32 crc; 183 u32 crc;
189 u8 icv[4]; 184 u8 icv[4];
190 struct scatterlist sg; 185 struct scatterlist sg;
191#endif 186
192 if (skb->len < hdr_len + 8) 187 if (skb->len < hdr_len + 8)
193 return -1; 188 return -1;
194 189
@@ -207,7 +202,7 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
207 202
208 /* Apply RC4 to data and compute CRC32 over decrypted data */ 203 /* Apply RC4 to data and compute CRC32 over decrypted data */
209 plen = skb->len - hdr_len - 8; 204 plen = skb->len - hdr_len - 8;
210#ifndef JOHN_HWSEC 205
211 crypto_blkcipher_setkey(wep->rx_tfm, key, klen); 206 crypto_blkcipher_setkey(wep->rx_tfm, key, klen);
212 sg_init_one(&sg, pos, plen + 4); 207 sg_init_one(&sg, pos, plen + 4);
213 208
@@ -224,7 +219,6 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
224 /* ICV mismatch - drop frame */ 219 /* ICV mismatch - drop frame */
225 return -2; 220 return -2;
226 } 221 }
227#endif /* JOHN_HWSEC */
228 222
229 /* Remove IV and ICV */ 223 /* Remove IV and ICV */
230 memmove(skb->data + 4, skb->data, hdr_len); 224 memmove(skb->data + 4, skb->data, hdr_len);