Skip to content

Commit

Permalink
Staging: rtl8187se/ieee80211: remove superfluous JOHN_* ifdefs
Browse files Browse the repository at this point in the history
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Bartlomiej Zolnierkiewicz authored and Greg Kroah-Hartman committed Sep 15, 2009
1 parent 8f75675 commit 7fdb78d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 60 deletions.
3 changes: 0 additions & 3 deletions drivers/staging/rtl8187se/ieee80211/ieee80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,11 @@
#endif
*/

//#ifdef JOHN_HWSEC
#define KEY_TYPE_NA 0x0
#define KEY_TYPE_WEP40 0x1
#define KEY_TYPE_TKIP 0x2
#define KEY_TYPE_CCMP 0x4
#define KEY_TYPE_WEP104 0x5
//#endif


#define aSifsTime 10

Expand Down
13 changes: 3 additions & 10 deletions drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ static inline void xor_block(u8 *b, u8 *a, size_t len)
b[i] ^= a[i];
}

#ifndef JOHN_CCMP
static void ccmp_init_blocks(struct crypto_tfm *tfm,
struct ieee80211_hdr *hdr,
u8 *pn, size_t dlen, u8 *b0, u8 *auth,
Expand Down Expand Up @@ -196,22 +195,20 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm,
b0[14] = b0[15] = 0;
ieee80211_ccmp_aes_encrypt(tfm, b0, s0);
}
#endif

static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
struct ieee80211_ccmp_data *key = priv;
int data_len, i;
u8 *pos;
struct ieee80211_hdr *hdr;
#ifndef JOHN_CCMP
int blocks, last, len;
u8 *mic;
u8 *b0 = key->tx_b0;
u8 *b = key->tx_b;
u8 *e = key->tx_e;
u8 *s0 = key->tx_s0;
#endif

if (skb_headroom(skb) < CCMP_HDR_LEN ||
skb_tailroom(skb) < CCMP_MIC_LEN ||
skb->len < hdr_len)
Expand Down Expand Up @@ -241,7 +238,6 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
*pos++ = key->tx_pn[0];

hdr = (struct ieee80211_hdr *) skb->data;
#ifndef JOHN_CCMP
//mic is moved to here by john
mic = skb_put(skb, CCMP_MIC_LEN);

Expand All @@ -265,7 +261,7 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)

for (i = 0; i < CCMP_MIC_LEN; i++)
mic[i] = b[i] ^ s0[i];
#endif

return 0;
}

Expand All @@ -276,14 +272,13 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
u8 keyidx, *pos;
struct ieee80211_hdr *hdr;
u8 pn[6];
#ifndef JOHN_CCMP
size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - CCMP_MIC_LEN;
u8 *mic = skb->data + skb->len - CCMP_MIC_LEN;
u8 *b0 = key->rx_b0;
u8 *b = key->rx_b;
u8 *a = key->rx_a;
int i, blocks, last, len;
#endif

if (skb->len < hdr_len + CCMP_HDR_LEN + CCMP_MIC_LEN) {
key->dot11RSNAStatsCCMPFormatErrors++;
return -1;
Expand Down Expand Up @@ -335,7 +330,6 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
return -4;
}

#ifndef JOHN_CCMP
ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b);
xor_block(mic, b, CCMP_MIC_LEN);

Expand Down Expand Up @@ -366,7 +360,6 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)

memcpy(key->rx_pn, pn, CCMP_PN_LEN);

#endif
/* Remove hdr and MIC */
memmove(skb->data + CCMP_HDR_LEN, skb->data, hdr_len);
skb_pull(skb, CCMP_HDR_LEN);
Expand Down
42 changes: 4 additions & 38 deletions drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ static inline u16 _S_(u16 v)
return Sbox[Lo8(v)] ^ ((t << 8) | (t >> 8));
}

#ifndef JOHN_TKIP
#define PHASE1_LOOP_COUNT 8

static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32)
Expand Down Expand Up @@ -309,19 +308,17 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
}
#endif
}
#endif

static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
struct ieee80211_tkip_data *tkey = priv;
struct blkcipher_desc desc = {.tfm = tkey->tx_tfm_arc4};
int len;
u8 *pos;
struct ieee80211_hdr *hdr;
#ifndef JOHN_TKIP
u8 rc4key[16],*icv;
u32 crc;
struct scatterlist sg;
#endif
int ret;

ret = 0;
Expand All @@ -342,38 +339,27 @@ printk("%x|", ((u32*)tkey->key)[6]);
printk("%x\n", ((u32*)tkey->key)[7]);
#endif

#ifndef JOHN_TKIP
if (!tkey->tx_phase1_done) {
tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2,
tkey->tx_iv32);
tkey->tx_phase1_done = 1;
}
tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);

#else
tkey->tx_phase1_done = 1;
#endif /*JOHN_TKIP*/

len = skb->len - hdr_len;
pos = skb_push(skb, 8);
memmove(pos, pos + 8, hdr_len);
pos += hdr_len;

#ifdef JOHN_TKIP
*pos++ = Hi8(tkey->tx_iv16);
*pos++ = (Hi8(tkey->tx_iv16) | 0x20) & 0x7F;
*pos++ = Lo8(tkey->tx_iv16);
#else
*pos++ = rc4key[0];
*pos++ = rc4key[1];
*pos++ = rc4key[2];
#endif
*pos++ = (tkey->key_idx << 6) | (1 << 5) /* Ext IV included */;
*pos++ = tkey->tx_iv32 & 0xff;
*pos++ = (tkey->tx_iv32 >> 8) & 0xff;
*pos++ = (tkey->tx_iv32 >> 16) & 0xff;
*pos++ = (tkey->tx_iv32 >> 24) & 0xff;
#ifndef JOHN_TKIP

icv = skb_put(skb, 4);
crc = ~crc32_le(~0, pos, len);
icv[0] = crc;
Expand All @@ -383,17 +369,13 @@ printk("%x\n", ((u32*)tkey->key)[7]);
crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16);
sg_init_one(&sg, pos, len + 4);
ret= crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
#endif

tkey->tx_iv16++;
if (tkey->tx_iv16 == 0) {
tkey->tx_phase1_done = 0;
tkey->tx_iv32++;
}
#ifndef JOHN_TKIP
return ret;
#else
return 0;
#endif
}

static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
Expand All @@ -404,13 +386,12 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
u32 iv32;
u16 iv16;
struct ieee80211_hdr *hdr;
#ifndef JOHN_TKIP
u8 icv[4];
u32 crc;
struct scatterlist sg;
u8 rc4key[16];
int plen;
#endif

if (skb->len < hdr_len + 8 + 4)
return -1;

Expand Down Expand Up @@ -441,7 +422,6 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
iv16 = (pos[0] << 8) | pos[2];
iv32 = pos[4] | (pos[5] << 8) | (pos[6] << 16) | (pos[7] << 24);
pos += 8;
#ifndef JOHN_TKIP

if (iv32 < tkey->rx_iv32 ||
(iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) {
Expand Down Expand Up @@ -492,8 +472,6 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
return -5;
}

#endif /* JOHN_TKIP */

/* Update real counters only after Michael MIC verification has
* completed */
tkey->rx_iv32_new = iv32;
Expand All @@ -504,18 +482,6 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
skb_pull(skb, 8);
skb_trim(skb, skb->len - 4);

//john's test
#ifdef JOHN_DUMP
if( ((u16*)skb->data)[0] & 0x4000){
printk("@@ rx decrypted skb->data");
int i;
for(i=0;i<skb->len;i++){
if( (i%24)==0 ) printk("\n");
printk("%2x ", ((u8*)skb->data)[i]);
}
printk("\n");
}
#endif /*JOHN_DUMP*/
return keyidx;
}

Expand Down
12 changes: 3 additions & 9 deletions drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,10 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
u32 klen, len;
u8 key[WEP_KEY_LEN + 3];
u8 *pos;
#ifndef JOHN_HWSEC
u32 crc;
u8 *icv;
struct scatterlist sg;
#endif

if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 ||
skb->len < hdr_len)
return -1;
Expand Down Expand Up @@ -152,7 +151,6 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
/* Copy rest of the WEP key (the secret part) */
memcpy(key + 3, wep->key, wep->key_len);

#ifndef JOHN_HWSEC
/* Append little-endian CRC32 and encrypt it to produce ICV */
crc = ~crc32_le(~0, pos, len);
icv = skb_put(skb, 4);
Expand All @@ -165,8 +163,6 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
sg_init_one(&sg, pos, len + 4);

return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
#endif /* JOHN_HWSEC */
return 0;
}


Expand All @@ -184,11 +180,10 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
u32 klen, plen;
u8 key[WEP_KEY_LEN + 3];
u8 keyidx, *pos;
#ifndef JOHN_HWSEC
u32 crc;
u8 icv[4];
struct scatterlist sg;
#endif

if (skb->len < hdr_len + 8)
return -1;

Expand All @@ -207,7 +202,7 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)

/* Apply RC4 to data and compute CRC32 over decrypted data */
plen = skb->len - hdr_len - 8;
#ifndef JOHN_HWSEC

crypto_blkcipher_setkey(wep->rx_tfm, key, klen);
sg_init_one(&sg, pos, plen + 4);

Expand All @@ -224,7 +219,6 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
/* ICV mismatch - drop frame */
return -2;
}
#endif /* JOHN_HWSEC */

/* Remove IV and ICV */
memmove(skb->data + 4, skb->data, hdr_len);
Expand Down

0 comments on commit 7fdb78d

Please sign in to comment.