Commit 482a4136 authored by Moritz Muehlenhoff's avatar Moritz Muehlenhoff Committed by Greg Kroah-Hartman

Staging: wlan-ng: Replace SSWAP() with the generic swap(). Also remove a

Signed-off-by: default avatarMoritz Muehlenhoff <jmm@debian.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 4ae14c36
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include <linux/wireless.h> #include <linux/wireless.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/random.h> #include <linux/random.h>
#include <linux/kernel.h>
#include "wlan_compat.h" #include "wlan_compat.h"
...@@ -72,17 +73,8 @@ ...@@ -72,17 +73,8 @@
/*================================================================*/ /*================================================================*/
/* Local Constants */ /* Local Constants */
#define SSWAP(a,b) {u8 tmp = s[a]; s[a] = s[b]; s[b] = tmp;}
#define WEP_KEY(x) (((x) & 0xC0) >> 6) #define WEP_KEY(x) (((x) & 0xC0) >> 6)
/*================================================================*/
/* Local Macros */
/*================================================================*/
/* Local Types */
/*================================================================*/ /*================================================================*/
/* Local Static Definitions */ /* Local Static Definitions */
...@@ -211,7 +203,7 @@ int wep_decrypt(wlandevice_t *wlandev, u8 *buf, u32 len, int key_override, u8 *i ...@@ -211,7 +203,7 @@ int wep_decrypt(wlandevice_t *wlandev, u8 *buf, u32 len, int key_override, u8 *i
j = 0; j = 0;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
j = (j + s[i] + key[i % keylen]) & 0xff; j = (j + s[i] + key[i % keylen]) & 0xff;
SSWAP(i,j); swap(i,j);
} }
/* Apply the RC4 to the data, update the CRC32 */ /* 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,7 +212,7 @@ int wep_decrypt(wlandevice_t *wlandev, u8 *buf, u32 len, int key_override, u8 *i
for (k = 0; k < len; k++) { for (k = 0; k < len; k++) {
i = (i+1) & 0xff; i = (i+1) & 0xff;
j = (j+s[i]) & 0xff; j = (j+s[i]) & 0xff;
SSWAP(i,j); swap(i,j);
buf[k] ^= s[(s[i] + s[j]) & 0xff]; buf[k] ^= s[(s[i] + s[j]) & 0xff];
crc = wep_crc32_table[(crc ^ buf[k]) & 0xff] ^ (crc >> 8); crc = wep_crc32_table[(crc ^ buf[k]) & 0xff] ^ (crc >> 8);
} }
...@@ -235,7 +227,7 @@ int wep_decrypt(wlandevice_t *wlandev, u8 *buf, u32 len, int key_override, u8 *i ...@@ -235,7 +227,7 @@ int wep_decrypt(wlandevice_t *wlandev, u8 *buf, u32 len, int key_override, u8 *i
for (k = 0; k < 4; k++) { for (k = 0; k < 4; k++) {
i = (i + 1) & 0xff; i = (i + 1) & 0xff;
j = (j+s[i]) & 0xff; j = (j+s[i]) & 0xff;
SSWAP(i,j); swap(i,j);
if ((c_crc[k] ^ s[(s[i] + s[j]) & 0xff]) != icv[k]) if ((c_crc[k] ^ s[(s[i] + s[j]) & 0xff]) != icv[k])
return -(4 | (k << 4)) ; /* ICV mismatch */ return -(4 | (k << 4)) ; /* ICV mismatch */
} }
...@@ -283,7 +275,7 @@ int wep_encrypt(wlandevice_t *wlandev, u8 *buf, u8 *dst, u32 len, int keynum, u8 ...@@ -283,7 +275,7 @@ int wep_encrypt(wlandevice_t *wlandev, u8 *buf, u8 *dst, u32 len, int keynum, u8
j = 0; j = 0;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
j = (j + s[i] + key[i % keylen]) & 0xff; j = (j + s[i] + key[i % keylen]) & 0xff;
SSWAP(i,j); swap(i,j);
} }
/* Update CRC32 then apply RC4 to the data */ /* 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,7 +285,7 @@ int wep_encrypt(wlandevice_t *wlandev, u8 *buf, u8 *dst, u32 len, int keynum, u8
crc = wep_crc32_table[(crc ^ buf[k]) & 0xff] ^ (crc >> 8); crc = wep_crc32_table[(crc ^ buf[k]) & 0xff] ^ (crc >> 8);
i = (i+1) & 0xff; i = (i+1) & 0xff;
j = (j+s[i]) & 0xff; j = (j+s[i]) & 0xff;
SSWAP(i,j); swap(i,j);
dst[k] = buf[k] ^ s[(s[i] + s[j]) & 0xff]; dst[k] = buf[k] ^ s[(s[i] + s[j]) & 0xff];
} }
crc = ~crc; crc = ~crc;
...@@ -307,7 +299,7 @@ int wep_encrypt(wlandevice_t *wlandev, u8 *buf, u8 *dst, u32 len, int keynum, u8 ...@@ -307,7 +299,7 @@ int wep_encrypt(wlandevice_t *wlandev, u8 *buf, u8 *dst, u32 len, int keynum, u8
for (k = 0; k < 4; k++) { for (k = 0; k < 4; k++) {
i = (i + 1) & 0xff; i = (i + 1) & 0xff;
j = (j+s[i]) & 0xff; j = (j+s[i]) & 0xff;
SSWAP(i,j); swap(i,j);
icv[k] ^= s[(s[i] + s[j]) & 0xff]; icv[k] ^= s[(s[i] + s[j]) & 0xff];
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment