aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest/bss.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2010-11-21 11:19:43 (GMT)
committerJouni Malinen <j@w1.fi>2010-11-21 11:19:43 (GMT)
commit221519dea30870c35d7a67cfd9eb7fbce5daa681 (patch)
tree87bef8b2ec53d80d7847c7a9b761b4819bb53bfc /wlantest/bss.c
parent81d59891769e4e9335025e304bb4b4bb1fcd65b4 (diff)
downloadhostap-221519dea30870c35d7a67cfd9eb7fbce5daa681.zip
hostap-221519dea30870c35d7a67cfd9eb7fbce5daa681.tar.gz
hostap-221519dea30870c35d7a67cfd9eb7fbce5daa681.tar.bz2
wlantest: Derive PMK to existing BSSes when a new passphrase is added
Diffstat (limited to 'wlantest/bss.c')
-rw-r--r--wlantest/bss.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/wlantest/bss.c b/wlantest/bss.c
index b3a7441..88064a5 100644
--- a/wlantest/bss.c
+++ b/wlantest/bss.c
@@ -78,10 +78,33 @@ void bss_deinit(struct wlantest_bss *bss)
}
+int bss_add_pmk_from_passphrase(struct wlantest_bss *bss,
+ const char *passphrase)
+{
+ struct wlantest_pmk *pmk;
+
+ pmk = os_zalloc(sizeof(*pmk));
+ if (pmk == NULL)
+ return -1;
+ if (pbkdf2_sha1(passphrase, (char *) bss->ssid, bss->ssid_len, 4096,
+ pmk->pmk, sizeof(pmk->pmk)) < 0) {
+ os_free(pmk);
+ return -1;
+ }
+
+ wpa_printf(MSG_INFO, "Add possible PMK for BSSID " MACSTR
+ " based on passphrase '%s'",
+ MAC2STR(bss->bssid), passphrase);
+ wpa_hexdump(MSG_DEBUG, "Possible PMK", pmk->pmk, sizeof(pmk->pmk));
+ dl_list_add(&bss->pmk, &pmk->list);
+
+ return 0;
+}
+
+
static void bss_add_pmk(struct wlantest *wt, struct wlantest_bss *bss)
{
struct wlantest_passphrase *p;
- struct wlantest_pmk *pmk;
dl_list_for_each(p, &wt->passphrase, struct wlantest_passphrase, list)
{
@@ -93,22 +116,8 @@ static void bss_add_pmk(struct wlantest *wt, struct wlantest_bss *bss)
os_memcmp(p->ssid, bss->ssid, p->ssid_len) != 0))
continue;
- pmk = os_zalloc(sizeof(*pmk));
- if (pmk == NULL)
+ if (bss_add_pmk_from_passphrase(bss, p->passphrase) < 0)
break;
- if (pbkdf2_sha1(p->passphrase, (char *) bss->ssid,
- bss->ssid_len, 4096,
- pmk->pmk, sizeof(pmk->pmk)) < 0) {
- os_free(pmk);
- continue;
- }
-
- wpa_printf(MSG_INFO, "Add possible PMK for BSSID " MACSTR
- " based on passphrase '%s'",
- MAC2STR(bss->bssid), p->passphrase);
- wpa_hexdump(MSG_DEBUG, "Possible PMK",
- pmk->pmk, sizeof(pmk->pmk));
- dl_list_add(&bss->pmk, &pmk->list);
}
}