aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest/tkip.c
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2011-01-14 15:43:17 (GMT)
committerJouni Malinen <j@w1.fi>2011-01-14 15:43:17 (GMT)
commit2e479416d1bfa584eddf7d335cf969ea6fe1f89c (patch)
tree0ef076cbd4031ef46afe8e0eeff30062aaa19be7 /wlantest/tkip.c
parent3558c41ee71ff0e34aca47412b33019630c8e922 (diff)
downloadhostap-2e479416d1bfa584eddf7d335cf969ea6fe1f89c.zip
hostap-2e479416d1bfa584eddf7d335cf969ea6fe1f89c.tar.gz
hostap-2e479416d1bfa584eddf7d335cf969ea6fe1f89c.tar.bz2
wlantest: Add support for decrypting WEP frames
Diffstat (limited to 'wlantest/tkip.c')
-rw-r--r--wlantest/tkip.c32
1 files changed, 3 insertions, 29 deletions
diff --git a/wlantest/tkip.c b/wlantest/tkip.c
index 3da64c5..3533914 100644
--- a/wlantest/tkip.c
+++ b/wlantest/tkip.c
@@ -19,6 +19,9 @@
#include "wlantest.h"
+void wep_crypt(u8 *key, u8 *buf, size_t plen);
+
+
static inline u16 RotR1(u16 val)
{
return (val >> 1) | (val << 15);
@@ -172,35 +175,6 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
}
-static void wep_crypt(u8 *key, u8 *buf, size_t plen)
-{
- u32 i, j, k;
- u8 S[256];
-#define S_SWAP(a,b) do { u8 t = S[a]; S[a] = S[b]; S[b] = t; } while(0)
- u8 *pos;
-
- /* Setup RC4 state */
- for (i = 0; i < 256; i++)
- S[i] = i;
- j = 0;
- for (i = 0; i < 256; i++) {
- j = (j + S[i] + key[i & 0x0f]) & 0xff;
- S_SWAP(i, j);
- }
-
- /* Apply RC4 to data */
- pos = buf;
- i = j = 0;
- for (k = 0; k < plen; k++) {
- i = (i + 1) & 0xff;
- j = (j + S[i]) & 0xff;
- S_SWAP(i, j);
- *pos ^= S[(S[i] + S[j]) & 0xff];
- pos++;
- }
-}
-
-
static inline u32 rotl(u32 val, int bits)
{
return (val << bits) | (val >> (32 - bits));