]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Allow wildcard SSID to be used with WPA-PSK if bssid is set
authorZhi Chen <zhichen@qca.qualcomm.com>
Fri, 30 Sep 2011 19:01:42 +0000 (22:01 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 30 Sep 2011 19:05:44 +0000 (22:05 +0300)
This allows the AP to be selected based on the BSSID when WPA-PSK
is used with a passphrase. The PSK will be derived from the passphrase
after the SSID has been learned from scan results.

wpa_supplicant/events.c
wpa_supplicant/wpa_supplicant.c

index 7dc084c0ad988ce647eab49aaf04fa638be074cd..7d886e71fd213898a393cbc1da8babcba928f5b1 100644 (file)
@@ -562,6 +562,10 @@ static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
                }
 #endif /* CONFIG_WPS */
 
+               if (ssid->bssid_set && ssid->ssid_len == 0 &&
+                   os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) == 0)
+                       check_ssid = 0;
+
                if (check_ssid &&
                    (ssid_len != ssid->ssid_len ||
                     os_memcmp(ssid_, ssid->ssid, ssid_len) != 0)) {
index d2e29c0d87067763deac72a0373b0290c48bc253..970d97a34b942d3a4402e5a8da79a67ee9ba89dd 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "common.h"
 #include "crypto/random.h"
+#include "crypto/sha1.h"
 #include "eapol_supp/eapol_supp_sm.h"
 #include "eap_peer/eap.h"
 #include "eap_server/eap_methods.h"
@@ -1059,8 +1060,20 @@ int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
 
        if (ssid->key_mgmt &
            (WPA_KEY_MGMT_PSK | WPA_KEY_MGMT_FT_PSK | WPA_KEY_MGMT_PSK_SHA256))
+       {
                wpa_sm_set_pmk(wpa_s->wpa, ssid->psk, PMK_LEN);
-       else
+#ifndef CONFIG_NO_PBKDF2
+               if (bss && ssid->bssid_set && ssid->ssid_len == 0 &&
+                   ssid->passphrase) {
+                       u8 psk[PMK_LEN];
+                       pbkdf2_sha1(ssid->passphrase, (char *) bss->ssid,
+                                   bss->ssid_len, 4096, psk, PMK_LEN);
+                       wpa_hexdump_key(MSG_MSGDUMP, "PSK (from passphrase)",
+                                       psk, PMK_LEN);
+                       wpa_sm_set_pmk(wpa_s->wpa, psk, PMK_LEN);
+               }
+#endif /* CONFIG_NO_PBKDF2 */
+       } else
                wpa_sm_set_pmk_from_pmksa(wpa_s->wpa);
 
        return 0;
@@ -1827,6 +1840,12 @@ struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s)
                     os_memcmp(bssid, entry->bssid, ETH_ALEN) == 0))
                        return entry;
 #endif /* CONFIG_WPS */
+
+               if (!entry->disabled && entry->bssid_set &&
+                   entry->ssid_len == 0 &&
+                   os_memcmp(bssid, entry->bssid, ETH_ALEN) == 0)
+                       return entry;
+
                entry = entry->next;
        }