rc4_crypt(&ctx, dat, dat, len);
wi_do_hostdecrypt(struct wi_softc *sc, caddr_t buf, int len){	u_int32_t i, crc, klen, kid;	u_int8_t state[RC4STATE], key[RC4KEYLEN];	u_int8_t x, y, *dat;	if (len < IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN +	    IEEE80211_WEP_CRCLEN)		return -1;	len -= (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN +	    IEEE80211_WEP_CRCLEN);	dat = buf;	bzero(key, sizeof(key));	key[0] = dat[0];	key[1] = dat[1];	key[2] = dat[2];	kid = (dat[3] >> 6) % 4;	dat += 4;	klen = sc->wi_keys.wi_keys[kid].wi_keylen;	bcopy((char *)&sc->wi_keys.wi_keys[kid].wi_keydat,	    (char *)key + IEEE80211_WEP_IVLEN, klen);	klen = (klen > IEEE80211_WEP_KEYLEN) ? RC4KEYLEN : RC4KEYLEN / 2;	/* rc4 keysetup */	x = y = 0;	for (i = 0; i < RC4STATE; i++)		state[i] = i;	for (i = 0; i < RC4STATE; i++) {		y = (key[x] + state[i] + y) % RC4STATE;		RC4SWAP(i, y);		x = (x + 1) % klen;	}	/* compute rc4 over data, crc32 over data */	crc = ~0;	x = y = 0;	for (i = 0; i < len; i++) {		x = (x + 1) % RC4STATE;		y = (state[x] + y) % RC4STATE;		RC4SWAP(x, y);		dat[i] ^= state[(state[x] + state[y]) % RC4STATE];		crc = crc32tab[(crc ^ dat[i]) & 0xff] ^ (crc >> 8);	}	crc = ~crc;	dat += len;	/* append little-endian crc32 and encrypt */	for (i = 0; i < IEEE80211_WEP_CRCLEN; i++) {		x = (x + 1) % RC4STATE;		y = (state[x] + y) % RC4STATE;		RC4SWAP(x, y);		dat[i] ^= state[(state[x] + state[y]) % RC4STATE];	}	if ((dat[0] != crc) && (dat[1] != crc >> 8) &&	    (dat[2] != crc >> 16) && (dat[3] != crc >> 24)) {		if (sc->sc_arpcom.ac_if.if_flags & IFF_DEBUG)			printf(WI_PRT_FMT ": wi_do_hostdecrypt: iv mismatch: "			    "0x%02x%02x%02x%02x vs. 0x%x\n", WI_PRT_ARG(sc),			    dat[3], dat[2], dat[1], dat[0], crc);		return -1;	}	return 0;}