summaryrefslogtreecommitdiff
path: root/drivers/staging
diff options
context:
space:
mode:
authorJes Sorensen <Jes.Sorensen@redhat.com>2014-05-21 09:37:35 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-05-23 16:27:42 +0900
commite0827909a27c5d90bf88f714e108de9419fd8b29 (patch)
tree277f0a9ddef587f481de5fe8de2d8f1729b8cc2c /drivers/staging
parent9e3d6df2df8dbc4c2c5fb733dc494dfc82e0e2ae (diff)
staging: rtl8723au: Introduce struct rtw_wep_key to store our wep keys
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/rtl8723au/core/rtw_ioctl_set.c39
-rw-r--r--drivers/staging/rtl8723au/core/rtw_mlme.c4
-rw-r--r--drivers/staging/rtl8723au/core/rtw_security.c11
-rw-r--r--drivers/staging/rtl8723au/include/rtw_security.h8
-rw-r--r--drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c29
5 files changed, 49 insertions, 42 deletions
diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c
index 347ea999ec4a..19e2e68ff85c 100644
--- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c
+++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c
@@ -396,7 +396,8 @@ int rtw_set_802_11_add_wep23a(struct rtw_adapter* padapter,
RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
("MgntActrtw_set_802_11_add_wep23a:wep->KeyLength!= 5 "
"or 13\n"));
- break;
+ res = _FAIL;
+ goto exit;
}
RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
@@ -404,29 +405,29 @@ int rtw_set_802_11_add_wep23a(struct rtw_adapter* padapter,
"wep->KeyIndex = 0x%x keyid =%x\n",
wep->KeyLength, wep->KeyIndex, keyid));
- memcpy(&psecuritypriv->dot11DefKey[keyid].skey[0],
- &wep->KeyMaterial, wep->KeyLength);
+ memcpy(&psecuritypriv->wep_key[keyid].key, &wep->KeyMaterial,
+ wep->KeyLength);
- psecuritypriv->dot11DefKeylen[keyid] = wep->KeyLength;
+ psecuritypriv->wep_key[keyid].keylen = wep->KeyLength;
psecuritypriv->dot11PrivacyKeyIndex = keyid;
RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
- ("rtw_set_802_11_add_wep23a:security key material : %x %x %x %x "
- "%x %x %x %x %x %x %x %x %x\n",
- psecuritypriv->dot11DefKey[keyid].skey[0],
- psecuritypriv->dot11DefKey[keyid].skey[1],
- psecuritypriv->dot11DefKey[keyid].skey[2],
- psecuritypriv->dot11DefKey[keyid].skey[3],
- psecuritypriv->dot11DefKey[keyid].skey[4],
- psecuritypriv->dot11DefKey[keyid].skey[5],
- psecuritypriv->dot11DefKey[keyid].skey[6],
- psecuritypriv->dot11DefKey[keyid].skey[7],
- psecuritypriv->dot11DefKey[keyid].skey[8],
- psecuritypriv->dot11DefKey[keyid].skey[9],
- psecuritypriv->dot11DefKey[keyid].skey[10],
- psecuritypriv->dot11DefKey[keyid].skey[11],
- psecuritypriv->dot11DefKey[keyid].skey[12]));
+ ("rtw_set_802_11_add_wep23a:security key material : "
+ "%x %x %x %x %x %x %x %x %x %x %x %x %x\n",
+ psecuritypriv->wep_key[keyid].key[0],
+ psecuritypriv->wep_key[keyid].key[1],
+ psecuritypriv->wep_key[keyid].key[2],
+ psecuritypriv->wep_key[keyid].key[3],
+ psecuritypriv->wep_key[keyid].key[4],
+ psecuritypriv->wep_key[keyid].key[5],
+ psecuritypriv->wep_key[keyid].key[6],
+ psecuritypriv->wep_key[keyid].key[7],
+ psecuritypriv->wep_key[keyid].key[8],
+ psecuritypriv->wep_key[keyid].key[9],
+ psecuritypriv->wep_key[keyid].key[10],
+ psecuritypriv->wep_key[keyid].key[11],
+ psecuritypriv->wep_key[keyid].key[12]));
res = rtw_set_key23a(padapter, psecuritypriv, keyid, 1);
diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c
index 42efc171b89b..5dace9b9e830 100644
--- a/drivers/staging/rtl8723au/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723au/core/rtw_mlme.c
@@ -1914,12 +1914,12 @@ int rtw_set_key23a(struct rtw_adapter *adapter,
case WLAN_CIPHER_SUITE_WEP40:
keylen = 5;
memcpy(&psetkeyparm->key[0],
- &psecuritypriv->dot11DefKey[keyid].skey[0], keylen);
+ &psecuritypriv->wep_key[keyid].key, keylen);
break;
case WLAN_CIPHER_SUITE_WEP104:
keylen = 13;
memcpy(&psetkeyparm->key[0],
- &psecuritypriv->dot11DefKey[keyid].skey[0], keylen);
+ &psecuritypriv->wep_key[keyid].key, keylen);
break;
case WLAN_CIPHER_SUITE_TKIP:
keylen = 16;
diff --git a/drivers/staging/rtl8723au/core/rtw_security.c b/drivers/staging/rtl8723au/core/rtw_security.c
index aeb503b1f066..d6c07adc7bf4 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -175,12 +175,12 @@ void rtw_wep_encrypt23a(struct rtw_adapter *padapter,
return;
index = psecuritypriv->dot11PrivacyKeyIndex;
- keylength = psecuritypriv->dot11DefKeylen[index];
+ keylength = psecuritypriv->wep_key[index].keylen;
for (curfragnum = 0; curfragnum < pattrib->nr_frags ; curfragnum++) {
iv = pframe + pattrib->hdrlen;
memcpy(&wepkey[0], iv, 3);
- memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[index].skey[0],
+ memcpy(&wepkey[3], &psecuritypriv->wep_key[index].key,
keylength);
payload = pframe + pattrib->iv_len + pattrib->hdrlen;
@@ -233,11 +233,10 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter,
iv = pframe + prxattrib->hdrlen;
/* keyindex = (iv[3]&0x3); */
keyindex = prxattrib->key_index;
- keylength = psecuritypriv->dot11DefKeylen[keyindex];
+ keylength = psecuritypriv->wep_key[keyindex].keylen;
memcpy(&wepkey[0], iv, 3);
/* memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0], keylength); */
- memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[keyindex].skey[0],
- keylength);
+ memcpy(&wepkey[3], &psecuritypriv->wep_key[keyindex].key, keylength);
length = skb->len - prxattrib->hdrlen - prxattrib->iv_len;
payload = pframe + prxattrib->iv_len + prxattrib->hdrlen;
@@ -250,7 +249,7 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter,
*((u32 *)crc) = le32_to_cpu(getcrc32(payload, length - 4));
if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] ||
- crc[1] != payload[length - 3] || crc[0] != payload[length - 4]) {
+ crc[1] != payload[length - 3] || crc[0] != payload[length - 4]) {
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
("rtw_wep_decrypt23a:icv error crc[3](%x)!= payload"
"[length-1](%x) || crc[2](%x)!= payload[length-2](%x)"
diff --git a/drivers/staging/rtl8723au/include/rtw_security.h b/drivers/staging/rtl8723au/include/rtw_security.h
index e235ecd3e5e7..f44fd3334329 100644
--- a/drivers/staging/rtl8723au/include/rtw_security.h
+++ b/drivers/staging/rtl8723au/include/rtw_security.h
@@ -17,6 +17,7 @@
#include <osdep_service.h>
#include <drv_types.h>
+#include <net/lib80211.h>
#define is_wep_enc(alg) (alg == WLAN_CIPHER_SUITE_WEP40 || \
@@ -84,6 +85,10 @@ union Keytype {
u32 lkey[4];
};
+struct rtw_wep_key {
+ u8 key[WLAN_KEY_LEN_WEP104 + 1]; /* 14 */
+ u16 keylen;
+};
struct rt_pmkid_list {
u8 bUsed;
@@ -104,8 +109,7 @@ struct security_priv {
u32 dot11PrivacyKeyIndex; /* this is only valid for legendary
* wep, 0~3 for key id. (tx key index)
*/
- union Keytype dot11DefKey[4]; /* this is only valid for def. key */
- u32 dot11DefKeylen[4];
+ struct rtw_wep_key wep_key[NUM_WEP_KEYS];
u32 dot118021XGrpPrivacy; /* specify the privacy algthm.
* used for Grp key
diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
index e5662a82debd..08d6b3472bf6 100644
--- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
@@ -532,7 +532,7 @@ exit:
return res;
}
-static int set_wep_key(struct rtw_adapter *padapter, u8 *key, u8 keylen,
+static int set_wep_key(struct rtw_adapter *padapter, u8 *key, u16 keylen,
u8 keyid)
{
u32 alg;
@@ -556,7 +556,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
u32 param_len)
{
int ret = 0;
- u32 wep_key_len;
+ u16 wep_key_len;
u8 wep_key_idx;
struct sta_info *psta = NULL, *pbcmc_sta = NULL;
struct rtw_adapter *padapter = netdev_priv(dev);
@@ -636,10 +636,10 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
psecuritypriv->dot11PrivacyKeyIndex = wep_key_idx;
}
- memcpy(&psecuritypriv->dot11DefKey[wep_key_idx].skey[0],
+ memcpy(&psecuritypriv->wep_key[wep_key_idx].key,
param->u.crypt.key, wep_key_len);
- psecuritypriv->dot11DefKeylen[wep_key_idx] = wep_key_len;
+ psecuritypriv->wep_key[wep_key_idx].keylen = wep_key_len;
set_wep_key(padapter, param->u.crypt.key, wep_key_len,
wep_key_idx);
@@ -883,7 +883,8 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev,
struct ieee_param *param, u32 param_len)
{
int ret = 0;
- u32 wep_key_idx, wep_key_len;
+ u32 wep_key_idx;
+ u16 wep_key_len;
struct rtw_adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct security_priv *psecuritypriv = &padapter->securitypriv;
@@ -942,10 +943,10 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev,
psecuritypriv->dot11PrivacyKeyIndex = wep_key_idx;
}
- memcpy(&psecuritypriv->dot11DefKey[wep_key_idx].skey[0],
+ memcpy(&psecuritypriv->wep_key[wep_key_idx].key,
param->u.crypt.key, wep_key_len);
- psecuritypriv->dot11DefKeylen[wep_key_idx] = wep_key_len;
+ psecuritypriv->wep_key[wep_key_idx].keylen = wep_key_len;
rtw_set_key23a(padapter, psecuritypriv, wep_key_idx, 0);
@@ -1201,9 +1202,9 @@ static int cfg80211_rtw_set_default_key(struct wiphy *wiphy,
DBG_8723A("%s(%s): key_index =%d, unicast =%d, multicast =%d.\n",
__func__, ndev->name, key_index, unicast, multicast);
- if ((key_index < WEP_KEYS) &&
- ((psecuritypriv->dot11PrivacyAlgrthm == WLAN_CIPHER_SUITE_WEP40) ||
- (psecuritypriv->dot11PrivacyAlgrthm == WLAN_CIPHER_SUITE_WEP104))) {
+ if (key_index < NUM_WEP_KEYS &&
+ (psecuritypriv->dot11PrivacyAlgrthm == WLAN_CIPHER_SUITE_WEP40 ||
+ psecuritypriv->dot11PrivacyAlgrthm == WLAN_CIPHER_SUITE_WEP104)) {
/* set wep default key */
psecuritypriv->ndisencryptstatus = Ndis802_11Encryption1Enabled;
@@ -1211,9 +1212,11 @@ static int cfg80211_rtw_set_default_key(struct wiphy *wiphy,
psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP40;
psecuritypriv->dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_WEP40;
- if (psecuritypriv->dot11DefKeylen[key_index] == 13) {
- psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP104;
- psecuritypriv->dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_WEP104;
+ if (psecuritypriv->wep_key[key_index].keylen == 13) {
+ psecuritypriv->dot11PrivacyAlgrthm =
+ WLAN_CIPHER_SUITE_WEP104;
+ psecuritypriv->dot118021XGrpPrivacy =
+ WLAN_CIPHER_SUITE_WEP104;
}
/* set the flag to represent that wep default key