diff options
author | Moritz Muehlenhoff <jmm@debian.org> | 2009-02-01 07:28:59 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-04-03 17:53:19 -0400 |
commit | 482a41361a9ac571cee265f44daaadd09e402cb1 (patch) | |
tree | 946b4319bd9cf2c90bb7d9ab4f227fb1b1466859 /drivers/staging/wlan-ng/p80211wep.c | |
parent | 4ae14c368a4fa8d06bd49d1874cdb8bd79a83072 (diff) |
Staging: wlan-ng: Replace SSWAP() with the generic swap(). Also remove a
Signed-off-by: Moritz Muehlenhoff <jmm@debian.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/wlan-ng/p80211wep.c')
-rw-r--r-- | drivers/staging/wlan-ng/p80211wep.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/drivers/staging/wlan-ng/p80211wep.c b/drivers/staging/wlan-ng/p80211wep.c index 46a2a6b3bdc..51f3af84f9c 100644 --- a/drivers/staging/wlan-ng/p80211wep.c +++ b/drivers/staging/wlan-ng/p80211wep.c | |||
@@ -55,6 +55,7 @@ | |||
55 | #include <linux/wireless.h> | 55 | #include <linux/wireless.h> |
56 | #include <linux/slab.h> | 56 | #include <linux/slab.h> |
57 | #include <linux/random.h> | 57 | #include <linux/random.h> |
58 | #include <linux/kernel.h> | ||
58 | 59 | ||
59 | #include "wlan_compat.h" | 60 | #include "wlan_compat.h" |
60 | 61 | ||
@@ -72,18 +73,9 @@ | |||
72 | /*================================================================*/ | 73 | /*================================================================*/ |
73 | /* Local Constants */ | 74 | /* Local Constants */ |
74 | 75 | ||
75 | #define SSWAP(a,b) {u8 tmp = s[a]; s[a] = s[b]; s[b] = tmp;} | ||
76 | #define WEP_KEY(x) (((x) & 0xC0) >> 6) | 76 | #define WEP_KEY(x) (((x) & 0xC0) >> 6) |
77 | 77 | ||
78 | /*================================================================*/ | 78 | /*================================================================*/ |
79 | /* Local Macros */ | ||
80 | |||
81 | |||
82 | /*================================================================*/ | ||
83 | /* Local Types */ | ||
84 | |||
85 | |||
86 | /*================================================================*/ | ||
87 | /* Local Static Definitions */ | 79 | /* Local Static Definitions */ |
88 | 80 | ||
89 | static const u32 wep_crc32_table[256] = { | 81 | static const u32 wep_crc32_table[256] = { |
@@ -211,7 +203,7 @@ int wep_decrypt(wlandevice_t *wlandev, u8 *buf, u32 len, int key_override, u8 *i | |||
211 | j = 0; | 203 | j = 0; |
212 | for (i = 0; i < 256; i++) { | 204 | for (i = 0; i < 256; i++) { |
213 | j = (j + s[i] + key[i % keylen]) & 0xff; | 205 | j = (j + s[i] + key[i % keylen]) & 0xff; |
214 | SSWAP(i,j); | 206 | swap(i,j); |
215 | } | 207 | } |
216 | 208 | ||
217 | /* Apply the RC4 to the data, update the CRC32 */ | 209 | /* Apply the RC4 to the data, update the CRC32 */ |
@@ -220,7 +212,7 @@ int wep_decrypt(wlandevice_t *wlandev, u8 *buf, u32 len, int key_override, u8 *i | |||
220 | for (k = 0; k < len; k++) { | 212 | for (k = 0; k < len; k++) { |
221 | i = (i+1) & 0xff; | 213 | i = (i+1) & 0xff; |
222 | j = (j+s[i]) & 0xff; | 214 | j = (j+s[i]) & 0xff; |
223 | SSWAP(i,j); | 215 | swap(i,j); |
224 | buf[k] ^= s[(s[i] + s[j]) & 0xff]; | 216 | buf[k] ^= s[(s[i] + s[j]) & 0xff]; |
225 | crc = wep_crc32_table[(crc ^ buf[k]) & 0xff] ^ (crc >> 8); | 217 | crc = wep_crc32_table[(crc ^ buf[k]) & 0xff] ^ (crc >> 8); |
226 | } | 218 | } |
@@ -235,7 +227,7 @@ int wep_decrypt(wlandevice_t *wlandev, u8 *buf, u32 len, int key_override, u8 *i | |||
235 | for (k = 0; k < 4; k++) { | 227 | for (k = 0; k < 4; k++) { |
236 | i = (i + 1) & 0xff; | 228 | i = (i + 1) & 0xff; |
237 | j = (j+s[i]) & 0xff; | 229 | j = (j+s[i]) & 0xff; |
238 | SSWAP(i,j); | 230 | swap(i,j); |
239 | if ((c_crc[k] ^ s[(s[i] + s[j]) & 0xff]) != icv[k]) | 231 | if ((c_crc[k] ^ s[(s[i] + s[j]) & 0xff]) != icv[k]) |
240 | return -(4 | (k << 4)) ; /* ICV mismatch */ | 232 | return -(4 | (k << 4)) ; /* ICV mismatch */ |
241 | } | 233 | } |
@@ -283,7 +275,7 @@ int wep_encrypt(wlandevice_t *wlandev, u8 *buf, u8 *dst, u32 len, int keynum, u8 | |||
283 | j = 0; | 275 | j = 0; |
284 | for (i = 0; i < 256; i++) { | 276 | for (i = 0; i < 256; i++) { |
285 | j = (j + s[i] + key[i % keylen]) & 0xff; | 277 | j = (j + s[i] + key[i % keylen]) & 0xff; |
286 | SSWAP(i,j); | 278 | swap(i,j); |
287 | } | 279 | } |
288 | 280 | ||
289 | /* Update CRC32 then apply RC4 to the data */ | 281 | /* Update CRC32 then apply RC4 to the data */ |
@@ -293,7 +285,7 @@ int wep_encrypt(wlandevice_t *wlandev, u8 *buf, u8 *dst, u32 len, int keynum, u8 | |||
293 | crc = wep_crc32_table[(crc ^ buf[k]) & 0xff] ^ (crc >> 8); | 285 | crc = wep_crc32_table[(crc ^ buf[k]) & 0xff] ^ (crc >> 8); |
294 | i = (i+1) & 0xff; | 286 | i = (i+1) & 0xff; |
295 | j = (j+s[i]) & 0xff; | 287 | j = (j+s[i]) & 0xff; |
296 | SSWAP(i,j); | 288 | swap(i,j); |
297 | dst[k] = buf[k] ^ s[(s[i] + s[j]) & 0xff]; | 289 | dst[k] = buf[k] ^ s[(s[i] + s[j]) & 0xff]; |
298 | } | 290 | } |
299 | crc = ~crc; | 291 | crc = ~crc; |
@@ -307,7 +299,7 @@ int wep_encrypt(wlandevice_t *wlandev, u8 *buf, u8 *dst, u32 len, int keynum, u8 | |||
307 | for (k = 0; k < 4; k++) { | 299 | for (k = 0; k < 4; k++) { |
308 | i = (i + 1) & 0xff; | 300 | i = (i + 1) & 0xff; |
309 | j = (j+s[i]) & 0xff; | 301 | j = (j+s[i]) & 0xff; |
310 | SSWAP(i,j); | 302 | swap(i,j); |
311 | icv[k] ^= s[(s[i] + s[j]) & 0xff]; | 303 | icv[k] ^= s[(s[i] + s[j]) & 0xff]; |
312 | } | 304 | } |
313 | 305 | ||