wlantest: Derive PMK to existing BSSes when a new passphrase is added
This commit is contained in:
parent
81d5989176
commit
221519dea3
3 changed files with 36 additions and 17 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -726,8 +726,16 @@ static void ctrl_add_passphrase(struct wlantest *wt, int sock, u8 *cmd,
|
|||
}
|
||||
}
|
||||
|
||||
if (p)
|
||||
if (p) {
|
||||
struct wlantest_bss *bss;
|
||||
dl_list_add(&wt->passphrase, &p->list);
|
||||
dl_list_for_each(bss, &wt->bss, struct wlantest_bss, list) {
|
||||
if (bssid &&
|
||||
os_memcmp(p->bssid, bss->bssid, ETH_ALEN) != 0)
|
||||
continue;
|
||||
bss_add_pmk_from_passphrase(bss, p->passphrase);
|
||||
}
|
||||
}
|
||||
|
||||
ctrl_send_simple(wt, sock, WLANTEST_CTRL_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -169,6 +169,8 @@ void bss_deinit(struct wlantest_bss *bss);
|
|||
void bss_update(struct wlantest *wt, struct wlantest_bss *bss,
|
||||
struct ieee802_11_elems *elems);
|
||||
void bss_flush(struct wlantest *wt);
|
||||
int bss_add_pmk_from_passphrase(struct wlantest_bss *bss,
|
||||
const char *passphrase);
|
||||
void pmk_deinit(struct wlantest_pmk *pmk);
|
||||
|
||||
struct wlantest_sta * sta_find(struct wlantest_bss *bss, const u8 *addr);
|
||||
|
|
Loading…
Reference in a new issue