#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
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,
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)
{
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)
*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);
for (i = 0; i < CCMP_MIC_LEN; i++)
mic[i] = b[i] ^ s0[i];
-#endif
+
return 0;
}
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;
return -4;
}
-#ifndef JOHN_CCMP
ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b);
xor_block(mic, b, CCMP_MIC_LEN);
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);
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)
}
#endif
}
-#endif
+
static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
struct ieee80211_tkip_data *tkey = priv;
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;
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);
}
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;
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)
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;
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)) {
return -5;
}
-#endif /* JOHN_TKIP */
-
/* Update real counters only after Michael MIC verification has
* completed */
tkey->rx_iv32_new = iv32;
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;
}
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;
/* 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);
sg_init_one(&sg, pos, len + 4);
return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
-#endif /* JOHN_HWSEC */
- return 0;
}
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;
/* 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);
/* ICV mismatch - drop frame */
return -2;
}
-#endif /* JOHN_HWSEC */
/* Remove IV and ICV */
memmove(skb->data + 4, skb->data, hdr_len);