Browse Source

nl80211: Fix static WEP key configuration when using SME

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.
Jouni Malinen 16 years ago
parent
commit
a0b2f99bd7
3 changed files with 22 additions and 1 deletions
  1. 3 0
      src/drivers/driver.h
  2. 11 1
      src/drivers/driver_nl80211.c
  3. 8 0
      wpa_supplicant/sme.c

+ 3 - 0
src/drivers/driver.h

@@ -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;
 };
 
 /**

+ 11 - 1
src/drivers/driver_nl80211.c

@@ -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);
 

+ 8 - 0
wpa_supplicant/sme.c

@@ -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);