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>
This commit is contained in:
committed by
John W. Linville
parent
915a824e30
commit
97359d1235
@@ -116,7 +116,6 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
{
|
||||
struct ieee80211_sub_if_data *sdata;
|
||||
struct sta_info *sta = NULL;
|
||||
enum ieee80211_key_alg alg;
|
||||
struct ieee80211_key *key;
|
||||
int err;
|
||||
|
||||
@@ -125,31 +124,20 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
|
||||
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
||||
|
||||
/* reject WEP and TKIP keys if WEP failed to initialize */
|
||||
switch (params->cipher) {
|
||||
case WLAN_CIPHER_SUITE_WEP40:
|
||||
case WLAN_CIPHER_SUITE_WEP104:
|
||||
alg = ALG_WEP;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_TKIP:
|
||||
alg = ALG_TKIP;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_CCMP:
|
||||
alg = ALG_CCMP;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_AES_CMAC:
|
||||
alg = ALG_AES_CMAC;
|
||||
case WLAN_CIPHER_SUITE_WEP104:
|
||||
if (IS_ERR(sdata->local->wep_tx_tfm))
|
||||
return -EINVAL;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
/* reject WEP and TKIP keys if WEP failed to initialize */
|
||||
if ((alg == ALG_WEP || alg == ALG_TKIP) &&
|
||||
IS_ERR(sdata->local->wep_tx_tfm))
|
||||
return -EINVAL;
|
||||
|
||||
key = ieee80211_key_alloc(alg, key_idx, params->key_len, params->key,
|
||||
params->seq_len, params->seq);
|
||||
key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
|
||||
params->key, params->seq_len, params->seq);
|
||||
if (IS_ERR(key))
|
||||
return PTR_ERR(key);
|
||||
|
||||
@@ -247,10 +235,10 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
|
||||
switch (key->conf.alg) {
|
||||
case ALG_TKIP:
|
||||
params.cipher = WLAN_CIPHER_SUITE_TKIP;
|
||||
params.cipher = key->conf.cipher;
|
||||
|
||||
switch (key->conf.cipher) {
|
||||
case WLAN_CIPHER_SUITE_TKIP:
|
||||
iv32 = key->u.tkip.tx.iv32;
|
||||
iv16 = key->u.tkip.tx.iv16;
|
||||
|
||||
@@ -268,8 +256,7 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
params.seq = seq;
|
||||
params.seq_len = 6;
|
||||
break;
|
||||
case ALG_CCMP:
|
||||
params.cipher = WLAN_CIPHER_SUITE_CCMP;
|
||||
case WLAN_CIPHER_SUITE_CCMP:
|
||||
seq[0] = key->u.ccmp.tx_pn[5];
|
||||
seq[1] = key->u.ccmp.tx_pn[4];
|
||||
seq[2] = key->u.ccmp.tx_pn[3];
|
||||
@@ -279,14 +266,7 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
params.seq = seq;
|
||||
params.seq_len = 6;
|
||||
break;
|
||||
case ALG_WEP:
|
||||
if (key->conf.keylen == 5)
|
||||
params.cipher = WLAN_CIPHER_SUITE_WEP40;
|
||||
else
|
||||
params.cipher = WLAN_CIPHER_SUITE_WEP104;
|
||||
break;
|
||||
case ALG_AES_CMAC:
|
||||
params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
|
||||
case WLAN_CIPHER_SUITE_AES_CMAC:
|
||||
seq[0] = key->u.aes_cmac.tx_pn[5];
|
||||
seq[1] = key->u.aes_cmac.tx_pn[4];
|
||||
seq[2] = key->u.aes_cmac.tx_pn[3];
|
||||
|
Reference in New Issue
Block a user