aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest/wlantest.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/wlantest.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/wlantest.c')
-rw-r--r--wlantest/wlantest.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/wlantest/wlantest.c b/wlantest/wlantest.c
index a98513a..17b3dd3 100644
--- a/wlantest/wlantest.c
+++ b/wlantest/wlantest.c
@@ -66,6 +66,7 @@ static void wlantest_init(struct wlantest *wt)
dl_list_init(&wt->secret);
dl_list_init(&wt->radius);
dl_list_init(&wt->pmk);
+ dl_list_init(&wt->wep);
}
@@ -82,6 +83,7 @@ static void wlantest_deinit(struct wlantest *wt)
struct wlantest_radius_secret *s, *sn;
struct wlantest_radius *r, *rn;
struct wlantest_pmk *pmk, *np;
+ struct wlantest_wep *wep, *nw;
if (wt->ctrl_sock >= 0)
ctrl_deinit(wt);
@@ -98,6 +100,8 @@ static void wlantest_deinit(struct wlantest *wt)
radius_deinit(r);
dl_list_for_each_safe(pmk, np, &wt->pmk, struct wlantest_pmk, list)
pmk_deinit(pmk);
+ dl_list_for_each_safe(wep, nw, &wt->wep, struct wlantest_wep, list)
+ os_free(wep);
write_pcap_deinit(wt);
}
@@ -132,6 +136,28 @@ static void add_secret(struct wlantest *wt, const char *secret)
}
+static void add_wep(struct wlantest *wt, const char *key)
+{
+ struct wlantest_wep *w;
+ size_t len = os_strlen(key);
+
+ if (len != 2 * 5 && len != 2 * 13) {
+ wpa_printf(MSG_INFO, "Invalid WEP key '%s'", key);
+ return;
+ }
+ w = os_zalloc(sizeof(*w));
+ if (w == NULL)
+ return;
+ if (hexstr2bin(key, w->key, len / 2) < 0) {
+ os_free(w);
+ wpa_printf(MSG_INFO, "Invalid WEP key '%s'", key);
+ return;
+ }
+ w->key_len = len / 2;
+ dl_list_add(&wt->wep, &w->list);
+}
+
+
int main(int argc, char *argv[])
{
int c;
@@ -152,7 +178,7 @@ int main(int argc, char *argv[])
wlantest_init(&wt);
for (;;) {
- c = getopt(argc, argv, "cdhi:I:p:P:qr:R:w:");
+ c = getopt(argc, argv, "cdhi:I:p:P:qr:R:w:W:");
if (c < 0)
break;
switch (c) {
@@ -190,6 +216,9 @@ int main(int argc, char *argv[])
case 'w':
write_file = optarg;
break;
+ case 'W':
+ add_wep(&wt, optarg);
+ break;
default:
usage();
return -1;