Skip to contentSkip to conversation

cfg80211: Set WEP ciphers

PATCH In review Samuel Ortiz 4 participants 6 messages Aug 6, 2009 – Aug 10, 2009 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cfg80211: Set WEP ciphers

With iwconfig there is no way to properly set the ciphers when trying to connect to a WEP SSID. Although mac80211 based drivers dont need it, several fullmac drivers do.
This patch basically sets the WEP ciphers whenever they're not set at all.

---
 net/wireless/sme.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
net/wireless/sme.c +16 -2
index 8a7dcbf..b78a111 100644
@@ -638,14 +638,28 @@ int __cfg80211_connect(struct cfg80211_registered_device *rdev,
 
 	if (connkeys && connkeys->def >= 0) {
 		int idx;
+		u32 cipher;
 
 		idx = connkeys->def;
+		cipher = connkeys->params[idx].cipher;
 		/* If given a WEP key we may need it for shared key auth */
-		if (connkeys->params[idx].cipher == WLAN_CIPHER_SUITE_WEP40 ||
-		    connkeys->params[idx].cipher == WLAN_CIPHER_SUITE_WEP104) {
+		if (cipher == WLAN_CIPHER_SUITE_WEP40 ||
+		    cipher == WLAN_CIPHER_SUITE_WEP104) {
 			connect->key_idx = idx;
 			connect->key = connkeys->params[idx].key;
 			connect->key_len = connkeys->params[idx].key_len;
+
+			/*
+			 * If ciphers are not set (e.g. when going through
+			 * iwconfig), we have to set them appropriately here.
+			 */
+			if (connect->crypto.cipher_group == 0)
+				connect->crypto.cipher_group = cipher;
+
+			if (connect->crypto.n_ciphers_pairwise == 0) {
+				connect->crypto.n_ciphers_pairwise = 1;
+				connect->crypto.ciphers_pairwise[0] = cipher;
+			}					
 		}
 	}
 
Signature · 5 lines
1.6.3.1

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
#1 lore raw
Quoted 4 lines · Samuel Ortiz

With iwconfig there is no way to properly set the ciphers when trying to connect to a WEP SSID. Although mac80211 based drivers dont need it, several fullmac drivers do.
This patch basically sets the WEP ciphers whenever they're not set at all.

If you're talking about Dynamic WEP, that's what wpa_supplicant is for, it will handle setting the ciphers through SIOCSIWENCODEEXT.

If you're talking about static WEP, then the ciphers are determined by the WEP keys that have been set with iwconfig, and you determine WEP40/WEP104 based on the length of the current WEP TX index.

You should *not* be trying to do Dynamic WEP via iwconfig (which it seems is what you're doing below?)

Dan

Quoted 43 lines
---
 net/wireless/sme.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
net/wireless/sme.c +16 -2
index 8a7dcbf..b78a111 100644
@@ -638,14 +638,28 @@ int __cfg80211_connect(struct cfg80211_registered_device *rdev,
 
 	if (connkeys && connkeys->def >= 0) {
 		int idx;
+		u32 cipher;
 
 		idx = connkeys->def;
+		cipher = connkeys->params[idx].cipher;
 		/* If given a WEP key we may need it for shared key auth */
-		if (connkeys->params[idx].cipher == WLAN_CIPHER_SUITE_WEP40 ||
-		    connkeys->params[idx].cipher == WLAN_CIPHER_SUITE_WEP104) {
+		if (cipher == WLAN_CIPHER_SUITE_WEP40 ||
+		    cipher == WLAN_CIPHER_SUITE_WEP104) {
 			connect->key_idx = idx;
 			connect->key = connkeys->params[idx].key;
 			connect->key_len = connkeys->params[idx].key_len;
+
+			/*
+			 * If ciphers are not set (e.g. when going through
+			 * iwconfig), we have to set them appropriately here.
+			 */
+			if (connect->crypto.cipher_group == 0)
+				connect->crypto.cipher_group = cipher;
+
+			if (connect->crypto.n_ciphers_pairwise == 0) {
+				connect->crypto.n_ciphers_pairwise = 1;
+				connect->crypto.ciphers_pairwise[0] = cipher;
+			}					
 		}
 	}
 
Signature · 1 line
1.6.3.1
#2 lore raw
Quoted 3 lines · Dan Williams

If you're talking about static WEP, then the ciphers are determined by the WEP keys that have been set with iwconfig, and you determine WEP40/WEP104 based on the length of the current WEP TX index.

Exactly. But we need to pass this cipher info to the connect API anyway. With cfg80211 key rework [1], driver's add_key callback won't be called until it is associated. If driver needs the cipher info for association, passing it to the connect API is the only choice.

Thanks,
-yi

1. http://marc.info/?l=linux-wireless&m=124705584228953&w=2

maintainer
#3 lore raw
Quoted 9 lines · Zhu Yi
Quoted 3 lines · Dan Williams

If you're talking about static WEP, then the ciphers are determined by the WEP keys that have been set with iwconfig, and you determine WEP40/WEP104 based on the length of the current WEP TX index.

Exactly. But we need to pass this cipher info to the connect API anyway. With cfg80211 key rework [1], driver's add_key callback won't be called until it is associated. If driver needs the cipher info for association, passing it to the connect API is the only choice.

The other question is whether we should actually pass the real keys to connect() too, at this point, instead of waiting for add_key, but I haven't really formed an opinion on that.

johannes

#4 lore raw
In reply to Dan Williams

Hi Dan,

Quoted 8 lines · Dan Williams
Quoted 4 lines · Samuel Ortiz

With iwconfig there is no way to properly set the ciphers when trying to connect to a WEP SSID. Although mac80211 based drivers dont need it, several fullmac drivers do.
This patch basically sets the WEP ciphers whenever they're not set at all.

If you're talking about Dynamic WEP, that's what wpa_supplicant is for, it will handle setting the ciphers through SIOCSIWENCODEEXT.

No, I'm not talking about dynamic WEP, but rather about "iwconfig wlan0 key your_static_key".

Quoted 3 lines

If you're talking about static WEP, then the ciphers are determined by the WEP keys that have been set with iwconfig, and you determine WEP40/WEP104 based on the length of the current WEP TX index.

In theory, yes, but our driver's UMAC wants to get the key cipher before having actually set the keys, and with the latest key handling rework we get our connect() handler called before keys are actually set.

Quoted 2 lines

You should *not* be trying to do Dynamic WEP via iwconfig (which it seems is what you're doing below?)

No, that's not what we're trying to do.

Cheers,
Samuel.

Quoted 46 lines

Dan

Quoted 43 lines
---
 net/wireless/sme.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
net/wireless/sme.c +16 -2
index 8a7dcbf..b78a111 100644
@@ -638,14 +638,28 @@ int __cfg80211_connect(struct cfg80211_registered_device *rdev,
 
 	if (connkeys && connkeys->def >= 0) {
 		int idx;
+		u32 cipher;
 
 		idx = connkeys->def;
+		cipher = connkeys->params[idx].cipher;
 		/* If given a WEP key we may need it for shared key auth */
-		if (connkeys->params[idx].cipher == WLAN_CIPHER_SUITE_WEP40 ||
-		    connkeys->params[idx].cipher == WLAN_CIPHER_SUITE_WEP104) {
+		if (cipher == WLAN_CIPHER_SUITE_WEP40 ||
+		    cipher == WLAN_CIPHER_SUITE_WEP104) {
 			connect->key_idx = idx;
 			connect->key = connkeys->params[idx].key;
 			connect->key_len = connkeys->params[idx].key_len;
+
+			/*
+			 * If ciphers are not set (e.g. when going through
+			 * iwconfig), we have to set them appropriately here.
+			 */
+			if (connect->crypto.cipher_group == 0)
+				connect->crypto.cipher_group = cipher;
+
+			if (connect->crypto.n_ciphers_pairwise == 0) {
+				connect->crypto.n_ciphers_pairwise = 1;
+				connect->crypto.ciphers_pairwise[0] = cipher;
+			}					
 		}
 	}
 
Signature · 1 line
1.6.3.1
Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#5 lore raw
Quoted 18 lines · Samuel Ortiz

Hi Dan,

Quoted 8 lines · Dan Williams
Quoted 4 lines · Samuel Ortiz

With iwconfig there is no way to properly set the ciphers when trying to connect to a WEP SSID. Although mac80211 based drivers dont need it, several fullmac drivers do.
This patch basically sets the WEP ciphers whenever they're not set at all.

If you're talking about Dynamic WEP, that's what wpa_supplicant is for, it will handle setting the ciphers through SIOCSIWENCODEEXT.

No, I'm not talking about dynamic WEP, but rather about "iwconfig wlan0 key your_static_key".

Quoted 3 lines

If you're talking about static WEP, then the ciphers are determined by the WEP keys that have been set with iwconfig, and you determine WEP40/WEP104 based on the length of the current WEP TX index.

Quoted 8 lines

In theory, yes, but our driver's UMAC wants to get the key cipher before having actually set the keys, and with the latest key handling rework we get our connect() handler called before keys are actually set.

Quoted 2 lines

You should *not* be trying to do Dynamic WEP via iwconfig (which it seems is what you're doing below?)

No, that's not what we're trying to do.

Thanks for the explanation, sorry for the noise then.

Dan

Quoted 51 lines

Cheers,
Samuel.

Quoted 46 lines

Dan

Quoted 43 lines
---
 net/wireless/sme.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
net/wireless/sme.c +16 -2
index 8a7dcbf..b78a111 100644
@@ -638,14 +638,28 @@ int __cfg80211_connect(struct cfg80211_registered_device *rdev,
 
 	if (connkeys && connkeys->def >= 0) {
 		int idx;
+		u32 cipher;
 
 		idx = connkeys->def;
+		cipher = connkeys->params[idx].cipher;
 		/* If given a WEP key we may need it for shared key auth */
-		if (connkeys->params[idx].cipher == WLAN_CIPHER_SUITE_WEP40 ||
-		    connkeys->params[idx].cipher == WLAN_CIPHER_SUITE_WEP104) {
+		if (cipher == WLAN_CIPHER_SUITE_WEP40 ||
+		    cipher == WLAN_CIPHER_SUITE_WEP104) {
 			connect->key_idx = idx;
 			connect->key = connkeys->params[idx].key;
 			connect->key_len = connkeys->params[idx].key_len;
+
+			/*
+			 * If ciphers are not set (e.g. when going through
+			 * iwconfig), we have to set them appropriately here.
+			 */
+			if (connect->crypto.cipher_group == 0)
+				connect->crypto.cipher_group = cipher;
+
+			if (connect->crypto.n_ciphers_pairwise == 0) {
+				connect->crypto.n_ciphers_pairwise = 1;
+				connect->crypto.ciphers_pairwise[0] = cipher;
+			}					
 		}
 	}
 
Signature · 1 line
1.6.3.1