nl80211: Fix static WEP key configuration when using SME
authorJouni Malinen <j@w1.fi>
Sat, 4 Apr 2009 13:58:16 +0000 (16:58 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 4 Apr 2009 13:58:16 +0000 (16:58 +0300)
Need to set WEP keys before requesting authentication in order to get
Shared Key authentication working. Previously, the WEP keys were not set
at all when using SME in wpa_supplicant.

src/drivers/driver.h
src/drivers/driver_nl80211.c
wpa_supplicant/sme.c

index ce83a3d..51e3909 100644 (file)
@@ -209,6 +209,9 @@ struct wpa_driver_auth_params {
        int auth_alg;
        const u8 *ie;
        size_t ie_len;
+       const u8 *wep_key[4];
+       size_t wep_key_len[4];
+       int wep_tx_keyidx;
 };
 
 /**
index f720f34..08a52d0 100644 (file)
@@ -1488,7 +1488,7 @@ static int wpa_driver_nl80211_authenticate(
        void *priv, struct wpa_driver_auth_params *params)
 {
        struct wpa_driver_nl80211_data *drv = priv;
-       int ret = -1;
+       int ret = -1, i;
        struct nl_msg *msg;
        enum nl80211_auth_type type;
 
@@ -1500,6 +1500,16 @@ static int wpa_driver_nl80211_authenticate(
 
        wpa_printf(MSG_DEBUG, "nl80211: Authenticate (ifindex=%d)",
                   drv->ifindex);
+
+       for (i = 0; i < 4; i++) {
+               if (!params->wep_key[i])
+                       continue;
+               wpa_driver_nl80211_set_key(drv, WPA_ALG_WEP, NULL, i,
+                                          i == params->wep_tx_keyidx, NULL, 0,
+                                          params->wep_key[i],
+                                          params->wep_key_len[i]);
+       }
+
        genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
                    NL80211_CMD_AUTHENTICATE, 0);
 
index 97a5f80..87b6b95 100644 (file)
@@ -35,6 +35,7 @@ void sme_authenticate(struct wpa_supplicant *wpa_s,
 #ifdef CONFIG_IEEE80211R
        const u8 *md = NULL;
 #endif /* CONFIG_IEEE80211R */
+       int i;
 
        if (bss == NULL) {
                wpa_printf(MSG_ERROR, "SME: No scan result available for the "
@@ -84,6 +85,13 @@ void sme_authenticate(struct wpa_supplicant *wpa_s,
                           params.auth_alg);
        }
 
+       for (i = 0; i < NUM_WEP_KEYS; i++) {
+               if (ssid->wep_key_len[i])
+                       params.wep_key[i] = ssid->wep_key[i];
+               params.wep_key_len[i] = ssid->wep_key_len[i];
+       }
+       params.wep_tx_keyidx = ssid->wep_tx_keyidx;
+
        os_memset(wpa_s->bssid, 0, ETH_ALEN);
        os_memcpy(wpa_s->pending_bssid, bss->bssid, ETH_ALEN);