Subject: [patch] d80211: fix WEP on big endian cpus

From: David Kimdon <[email-masked]>
Date: Sun, 10 Sep 2006 10:36:49 -0700

The ICV is transmitted on the network as a 4 byte little endian
quantity.  WEP encryption needs to swap the bytes before transmission
and decryption needs to swap bytes before ICV verification.

Index: wireless-dev/net/d80211/wep.c
===================================================================
--- wireless-dev.orig/net/d80211/wep.c	2006-09-10 14:50:52.073583400 +0000
+++ wireless-dev/net/d80211/wep.c	2006-09-10 14:51:10.146835848 +0000
@@ -121,9 +121,11 @@
 {
 	struct scatterlist sg;
 	u32 *icv;
+	u32 crc;
 
 	icv = (u32 *)(data + data_len);
-	*icv = ~crc32_le(~0, data, data_len);
+	crc = ~crc32_le(~0, data, data_len);
+	*icv = cpu_to_le32(crc);
 
 	crypto_cipher_setkey(tfm, rc4key, klen);
 	sg.page = virt_to_page(data);
@@ -196,6 +198,7 @@
 	crypto_cipher_decrypt(tfm, &sg, &sg, sg.length);
 
 	crc = ~crc32_le(~0, data, data_len);
+	crc = cpu_to_le32(crc);
 	if (memcmp(&crc, data + data_len, WEP_ICV_LEN) != 0)
 		/* ICV mismatch */
 		return -1;

--