diff options
author | Johannes Berg <johannes.berg@intel.com> | 2010-08-10 03:46:38 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-08-16 16:45:11 -0400 |
commit | 97359d1235eaf634fe706c9faa6e40181cc95fb8 (patch) | |
tree | 5799455c94622eaa6a4fb065bd3b5c350bb705e0 /net/mac80211/cfg.c | |
parent | 915a824e30c503157c38115eb6a85f60bb653738 (diff) |
mac80211: use cipher suite selectors
Currently, mac80211 translates the cfg80211
cipher suite selectors into ALG_* values.
That isn't all too useful, and some drivers
benefit from the distinction between WEP40
and WEP104 as well. Therefore, convert it
all to use the cipher suite selectors.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/cfg.c')
-rw-r--r-- | net/mac80211/cfg.c | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 19c6146010b7..9a35d9e7efd7 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -116,7 +116,6 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, | |||
116 | { | 116 | { |
117 | struct ieee80211_sub_if_data *sdata; | 117 | struct ieee80211_sub_if_data *sdata; |
118 | struct sta_info *sta = NULL; | 118 | struct sta_info *sta = NULL; |
119 | enum ieee80211_key_alg alg; | ||
120 | struct ieee80211_key *key; | 119 | struct ieee80211_key *key; |
121 | int err; | 120 | int err; |
122 | 121 | ||
@@ -125,31 +124,20 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, | |||
125 | 124 | ||
126 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 125 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
127 | 126 | ||
127 | /* reject WEP and TKIP keys if WEP failed to initialize */ | ||
128 | switch (params->cipher) { | 128 | switch (params->cipher) { |
129 | case WLAN_CIPHER_SUITE_WEP40: | 129 | case WLAN_CIPHER_SUITE_WEP40: |
130 | case WLAN_CIPHER_SUITE_WEP104: | ||
131 | alg = ALG_WEP; | ||
132 | break; | ||
133 | case WLAN_CIPHER_SUITE_TKIP: | 130 | case WLAN_CIPHER_SUITE_TKIP: |
134 | alg = ALG_TKIP; | 131 | case WLAN_CIPHER_SUITE_WEP104: |
135 | break; | 132 | if (IS_ERR(sdata->local->wep_tx_tfm)) |
136 | case WLAN_CIPHER_SUITE_CCMP: | 133 | return -EINVAL; |
137 | alg = ALG_CCMP; | ||
138 | break; | ||
139 | case WLAN_CIPHER_SUITE_AES_CMAC: | ||
140 | alg = ALG_AES_CMAC; | ||
141 | break; | 134 | break; |
142 | default: | 135 | default: |
143 | return -EINVAL; | 136 | break; |
144 | } | 137 | } |
145 | 138 | ||
146 | /* reject WEP and TKIP keys if WEP failed to initialize */ | 139 | key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len, |
147 | if ((alg == ALG_WEP || alg == ALG_TKIP) && | 140 | params->key, params->seq_len, params->seq); |
148 | IS_ERR(sdata->local->wep_tx_tfm)) | ||
149 | return -EINVAL; | ||
150 | |||
151 | key = ieee80211_key_alloc(alg, key_idx, params->key_len, params->key, | ||
152 | params->seq_len, params->seq); | ||
153 | if (IS_ERR(key)) | 141 | if (IS_ERR(key)) |
154 | return PTR_ERR(key); | 142 | return PTR_ERR(key); |
155 | 143 | ||
@@ -247,10 +235,10 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev, | |||
247 | 235 | ||
248 | memset(¶ms, 0, sizeof(params)); | 236 | memset(¶ms, 0, sizeof(params)); |
249 | 237 | ||
250 | switch (key->conf.alg) { | 238 | params.cipher = key->conf.cipher; |
251 | case ALG_TKIP: | ||
252 | params.cipher = WLAN_CIPHER_SUITE_TKIP; | ||
253 | 239 | ||
240 | switch (key->conf.cipher) { | ||
241 | case WLAN_CIPHER_SUITE_TKIP: | ||
254 | iv32 = key->u.tkip.tx.iv32; | 242 | iv32 = key->u.tkip.tx.iv32; |
255 | iv16 = key->u.tkip.tx.iv16; | 243 | iv16 = key->u.tkip.tx.iv16; |
256 | 244 | ||
@@ -268,8 +256,7 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev, | |||
268 | params.seq = seq; | 256 | params.seq = seq; |
269 | params.seq_len = 6; | 257 | params.seq_len = 6; |
270 | break; | 258 | break; |
271 | case ALG_CCMP: | 259 | case WLAN_CIPHER_SUITE_CCMP: |
272 | params.cipher = WLAN_CIPHER_SUITE_CCMP; | ||
273 | seq[0] = key->u.ccmp.tx_pn[5]; | 260 | seq[0] = key->u.ccmp.tx_pn[5]; |
274 | seq[1] = key->u.ccmp.tx_pn[4]; | 261 | seq[1] = key->u.ccmp.tx_pn[4]; |
275 | seq[2] = key->u.ccmp.tx_pn[3]; | 262 | seq[2] = key->u.ccmp.tx_pn[3]; |
@@ -279,14 +266,7 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev, | |||
279 | params.seq = seq; | 266 | params.seq = seq; |
280 | params.seq_len = 6; | 267 | params.seq_len = 6; |
281 | break; | 268 | break; |
282 | case ALG_WEP: | 269 | case WLAN_CIPHER_SUITE_AES_CMAC: |
283 | if (key->conf.keylen == 5) | ||
284 | params.cipher = WLAN_CIPHER_SUITE_WEP40; | ||
285 | else | ||
286 | params.cipher = WLAN_CIPHER_SUITE_WEP104; | ||
287 | break; | ||
288 | case ALG_AES_CMAC: | ||
289 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; | ||
290 | seq[0] = key->u.aes_cmac.tx_pn[5]; | 270 | seq[0] = key->u.aes_cmac.tx_pn[5]; |
291 | seq[1] = key->u.aes_cmac.tx_pn[4]; | 271 | seq[1] = key->u.aes_cmac.tx_pn[4]; |
292 | seq[2] = key->u.aes_cmac.tx_pn[3]; | 272 | seq[2] = key->u.aes_cmac.tx_pn[3]; |