printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " 
printk(KERN_DEBUG "TKIP countermeasures: dropped " 
static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv){	struct ieee80211_tkip_data *tkey = priv;	u8 rc4key[16];	u8 keyidx, *pos;	u32 iv32;	u16 iv16;	struct ieee80211_hdr_4addr *hdr;	u8 icv[4];	u32 crc;	struct scatterlist sg;	int plen;	hdr = (struct ieee80211_hdr_4addr *)skb->data;	if (tkey->ieee->tkip_countermeasures) {		if (net_ratelimit()) {			printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "			       "received packet from " MAC_FMT "\n",			       tkey->ieee->dev->name, MAC_ARG(hdr->addr2));		}		return -1;	}	if (skb->len < hdr_len + 8 + 4)		return -1;	pos = skb->data + hdr_len;	keyidx = pos[3];	if (!(keyidx & (1 << 5))) {		if (net_ratelimit()) {			printk(KERN_DEBUG "TKIP: received packet without ExtIV"			       " flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2));		}		return -2;	}	keyidx >>= 6;	if (tkey->key_idx != keyidx) {		printk(KERN_DEBUG "TKIP: RX tkey->key_idx=%d frame "		       "keyidx=%d priv=%p\n", tkey->key_idx, keyidx, priv);		return -6;	}	if (!tkey->key_set) {		if (net_ratelimit()) {			printk(KERN_DEBUG "TKIP: received packet from " MAC_FMT			       " with keyid=%d that does not have a configured"			       " key\n", MAC_ARG(hdr->addr2), keyidx);		}		return -3;	}	iv16 = (pos[0] << 8) | pos[2];	iv32 = pos[4] | (pos[5] << 8) | (pos[6] << 16) | (pos[7] << 24);	pos += 8;	if (iv32 < tkey->rx_iv32 ||	    (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) {		if (net_ratelimit()) {			printk(KERN_DEBUG "TKIP: replay detected: STA=" MAC_FMT			       " previous TSC %08x%04x received TSC "			       "%08x%04x\n", MAC_ARG(hdr->addr2),			       tkey->rx_iv32, tkey->rx_iv16, iv32, iv16);		}		tkey->dot11RSNAStatsTKIPReplays++;		return -4;	}	if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) {		tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32);		tkey->rx_phase1_done = 1;	}	tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16);	plen = skb->len - hdr_len - 12;	crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16);	sg.page = virt_to_page(pos);	sg.offset = offset_in_page(pos);	sg.length = plen + 4;	crypto_cipher_decrypt(tkey->tfm_arc4, &sg, &sg, plen + 4);	crc = ~crc32_le(~0, pos, plen);	icv[0] = crc;	icv[1] = crc >> 8;	icv[2] = crc >> 16;	icv[3] = crc >> 24;	if (memcmp(icv, pos + plen, 4) != 0) {		if (iv32 != tkey->rx_iv32) {			/* Previously cached Phase1 result was already lost, so			 * it needs to be recalculated for the next packet. */			tkey->rx_phase1_done = 0;		}		if (net_ratelimit()) {			printk(KERN_DEBUG "TKIP: ICV error detected: STA="			       MAC_FMT "\n", MAC_ARG(hdr->addr2));		}		tkey->dot11RSNAStatsTKIPICVErrors++;		return -5;	}	/* Update real counters only after Michael MIC verification has	 * completed */	tkey->rx_iv32_new = iv32;	tkey->rx_iv16_new = iv16;	/* Remove IV and ICV */	memmove(skb->data + 8, skb->data, hdr_len);	skb_pull(skb, 8);	skb_trim(skb, skb->len - 4);	return keyidx;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/6eb6edf04acd09e3cea09456913e8da59323b89e/ieee80211_crypt_tkip.c/clean/net/ieee80211/ieee80211_crypt_tkip.c