Commit e0827909 authored by Jes Sorensen's avatar Jes Sorensen Committed by Greg Kroah-Hartman

staging: rtl8723au: Introduce struct rtw_wep_key to store our wep keys

Signed-off-by: default avatarJes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9e3d6df2
...@@ -396,7 +396,8 @@ int rtw_set_802_11_add_wep23a(struct rtw_adapter* padapter, ...@@ -396,7 +396,8 @@ int rtw_set_802_11_add_wep23a(struct rtw_adapter* padapter,
RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
("MgntActrtw_set_802_11_add_wep23a:wep->KeyLength!= 5 " ("MgntActrtw_set_802_11_add_wep23a:wep->KeyLength!= 5 "
"or 13\n")); "or 13\n"));
break; res = _FAIL;
goto exit;
} }
RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
...@@ -404,29 +405,29 @@ int rtw_set_802_11_add_wep23a(struct rtw_adapter* padapter, ...@@ -404,29 +405,29 @@ int rtw_set_802_11_add_wep23a(struct rtw_adapter* padapter,
"wep->KeyIndex = 0x%x keyid =%x\n", "wep->KeyIndex = 0x%x keyid =%x\n",
wep->KeyLength, wep->KeyIndex, keyid)); wep->KeyLength, wep->KeyIndex, keyid));
memcpy(&psecuritypriv->dot11DefKey[keyid].skey[0], memcpy(&psecuritypriv->wep_key[keyid].key, &wep->KeyMaterial,
&wep->KeyMaterial, wep->KeyLength); wep->KeyLength);
psecuritypriv->dot11DefKeylen[keyid] = wep->KeyLength; psecuritypriv->wep_key[keyid].keylen = wep->KeyLength;
psecuritypriv->dot11PrivacyKeyIndex = keyid; psecuritypriv->dot11PrivacyKeyIndex = keyid;
RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
("rtw_set_802_11_add_wep23a:security key material : %x %x %x %x " ("rtw_set_802_11_add_wep23a:security key material : "
"%x %x %x %x %x %x %x %x %x\n", "%x %x %x %x %x %x %x %x %x %x %x %x %x\n",
psecuritypriv->dot11DefKey[keyid].skey[0], psecuritypriv->wep_key[keyid].key[0],
psecuritypriv->dot11DefKey[keyid].skey[1], psecuritypriv->wep_key[keyid].key[1],
psecuritypriv->dot11DefKey[keyid].skey[2], psecuritypriv->wep_key[keyid].key[2],
psecuritypriv->dot11DefKey[keyid].skey[3], psecuritypriv->wep_key[keyid].key[3],
psecuritypriv->dot11DefKey[keyid].skey[4], psecuritypriv->wep_key[keyid].key[4],
psecuritypriv->dot11DefKey[keyid].skey[5], psecuritypriv->wep_key[keyid].key[5],
psecuritypriv->dot11DefKey[keyid].skey[6], psecuritypriv->wep_key[keyid].key[6],
psecuritypriv->dot11DefKey[keyid].skey[7], psecuritypriv->wep_key[keyid].key[7],
psecuritypriv->dot11DefKey[keyid].skey[8], psecuritypriv->wep_key[keyid].key[8],
psecuritypriv->dot11DefKey[keyid].skey[9], psecuritypriv->wep_key[keyid].key[9],
psecuritypriv->dot11DefKey[keyid].skey[10], psecuritypriv->wep_key[keyid].key[10],
psecuritypriv->dot11DefKey[keyid].skey[11], psecuritypriv->wep_key[keyid].key[11],
psecuritypriv->dot11DefKey[keyid].skey[12])); psecuritypriv->wep_key[keyid].key[12]));
res = rtw_set_key23a(padapter, psecuritypriv, keyid, 1); res = rtw_set_key23a(padapter, psecuritypriv, keyid, 1);
......
...@@ -1914,12 +1914,12 @@ int rtw_set_key23a(struct rtw_adapter *adapter, ...@@ -1914,12 +1914,12 @@ int rtw_set_key23a(struct rtw_adapter *adapter,
case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP40:
keylen = 5; keylen = 5;
memcpy(&psetkeyparm->key[0], memcpy(&psetkeyparm->key[0],
&psecuritypriv->dot11DefKey[keyid].skey[0], keylen); &psecuritypriv->wep_key[keyid].key, keylen);
break; break;
case WLAN_CIPHER_SUITE_WEP104: case WLAN_CIPHER_SUITE_WEP104:
keylen = 13; keylen = 13;
memcpy(&psetkeyparm->key[0], memcpy(&psetkeyparm->key[0],
&psecuritypriv->dot11DefKey[keyid].skey[0], keylen); &psecuritypriv->wep_key[keyid].key, keylen);
break; break;
case WLAN_CIPHER_SUITE_TKIP: case WLAN_CIPHER_SUITE_TKIP:
keylen = 16; keylen = 16;
......
...@@ -175,12 +175,12 @@ void rtw_wep_encrypt23a(struct rtw_adapter *padapter, ...@@ -175,12 +175,12 @@ void rtw_wep_encrypt23a(struct rtw_adapter *padapter,
return; return;
index = psecuritypriv->dot11PrivacyKeyIndex; index = psecuritypriv->dot11PrivacyKeyIndex;
keylength = psecuritypriv->dot11DefKeylen[index]; keylength = psecuritypriv->wep_key[index].keylen;
for (curfragnum = 0; curfragnum < pattrib->nr_frags ; curfragnum++) { for (curfragnum = 0; curfragnum < pattrib->nr_frags ; curfragnum++) {
iv = pframe + pattrib->hdrlen; iv = pframe + pattrib->hdrlen;
memcpy(&wepkey[0], iv, 3); memcpy(&wepkey[0], iv, 3);
memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[index].skey[0], memcpy(&wepkey[3], &psecuritypriv->wep_key[index].key,
keylength); keylength);
payload = pframe + pattrib->iv_len + pattrib->hdrlen; payload = pframe + pattrib->iv_len + pattrib->hdrlen;
...@@ -233,11 +233,10 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter, ...@@ -233,11 +233,10 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter,
iv = pframe + prxattrib->hdrlen; iv = pframe + prxattrib->hdrlen;
/* keyindex = (iv[3]&0x3); */ /* keyindex = (iv[3]&0x3); */
keyindex = prxattrib->key_index; keyindex = prxattrib->key_index;
keylength = psecuritypriv->dot11DefKeylen[keyindex]; keylength = psecuritypriv->wep_key[keyindex].keylen;
memcpy(&wepkey[0], iv, 3); memcpy(&wepkey[0], iv, 3);
/* memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0], keylength); */ /* memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0], keylength); */
memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[keyindex].skey[0], memcpy(&wepkey[3], &psecuritypriv->wep_key[keyindex].key, keylength);
keylength);
length = skb->len - prxattrib->hdrlen - prxattrib->iv_len; length = skb->len - prxattrib->hdrlen - prxattrib->iv_len;
payload = pframe + prxattrib->iv_len + prxattrib->hdrlen; payload = pframe + prxattrib->iv_len + prxattrib->hdrlen;
...@@ -250,7 +249,7 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter, ...@@ -250,7 +249,7 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter,
*((u32 *)crc) = le32_to_cpu(getcrc32(payload, length - 4)); *((u32 *)crc) = le32_to_cpu(getcrc32(payload, length - 4));
if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] || 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_, RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
("rtw_wep_decrypt23a:icv error crc[3](%x)!= payload" ("rtw_wep_decrypt23a:icv error crc[3](%x)!= payload"
"[length-1](%x) || crc[2](%x)!= payload[length-2](%x)" "[length-1](%x) || crc[2](%x)!= payload[length-2](%x)"
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <osdep_service.h> #include <osdep_service.h>
#include <drv_types.h> #include <drv_types.h>
#include <net/lib80211.h>
#define is_wep_enc(alg) (alg == WLAN_CIPHER_SUITE_WEP40 || \ #define is_wep_enc(alg) (alg == WLAN_CIPHER_SUITE_WEP40 || \
...@@ -84,6 +85,10 @@ union Keytype { ...@@ -84,6 +85,10 @@ union Keytype {
u32 lkey[4]; u32 lkey[4];
}; };
struct rtw_wep_key {
u8 key[WLAN_KEY_LEN_WEP104 + 1]; /* 14 */
u16 keylen;
};
struct rt_pmkid_list { struct rt_pmkid_list {
u8 bUsed; u8 bUsed;
...@@ -104,8 +109,7 @@ struct security_priv { ...@@ -104,8 +109,7 @@ struct security_priv {
u32 dot11PrivacyKeyIndex; /* this is only valid for legendary u32 dot11PrivacyKeyIndex; /* this is only valid for legendary
* wep, 0~3 for key id. (tx key index) * wep, 0~3 for key id. (tx key index)
*/ */
union Keytype dot11DefKey[4]; /* this is only valid for def. key */ struct rtw_wep_key wep_key[NUM_WEP_KEYS];
u32 dot11DefKeylen[4];
u32 dot118021XGrpPrivacy; /* specify the privacy algthm. u32 dot118021XGrpPrivacy; /* specify the privacy algthm.
* used for Grp key * used for Grp key
......
...@@ -532,7 +532,7 @@ static int set_group_key(struct rtw_adapter *padapter, u8 *key, u32 alg, ...@@ -532,7 +532,7 @@ static int set_group_key(struct rtw_adapter *padapter, u8 *key, u32 alg,
return res; 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) u8 keyid)
{ {
u32 alg; u32 alg;
...@@ -556,7 +556,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, ...@@ -556,7 +556,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
u32 param_len) u32 param_len)
{ {
int ret = 0; int ret = 0;
u32 wep_key_len; u16 wep_key_len;
u8 wep_key_idx; u8 wep_key_idx;
struct sta_info *psta = NULL, *pbcmc_sta = NULL; struct sta_info *psta = NULL, *pbcmc_sta = NULL;
struct rtw_adapter *padapter = netdev_priv(dev); struct rtw_adapter *padapter = netdev_priv(dev);
...@@ -636,10 +636,10 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, ...@@ -636,10 +636,10 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev,
psecuritypriv->dot11PrivacyKeyIndex = wep_key_idx; 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); 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, set_wep_key(padapter, param->u.crypt.key, wep_key_len,
wep_key_idx); wep_key_idx);
...@@ -883,7 +883,8 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, ...@@ -883,7 +883,8 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev,
struct ieee_param *param, u32 param_len) struct ieee_param *param, u32 param_len)
{ {
int ret = 0; 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 rtw_adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct security_priv *psecuritypriv = &padapter->securitypriv; struct security_priv *psecuritypriv = &padapter->securitypriv;
...@@ -942,10 +943,10 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, ...@@ -942,10 +943,10 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev,
psecuritypriv->dot11PrivacyKeyIndex = wep_key_idx; 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); 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); rtw_set_key23a(padapter, psecuritypriv, wep_key_idx, 0);
...@@ -1201,9 +1202,9 @@ static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, ...@@ -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", DBG_8723A("%s(%s): key_index =%d, unicast =%d, multicast =%d.\n",
__func__, ndev->name, key_index, unicast, multicast); __func__, ndev->name, key_index, unicast, multicast);
if ((key_index < WEP_KEYS) && if (key_index < NUM_WEP_KEYS &&
((psecuritypriv->dot11PrivacyAlgrthm == WLAN_CIPHER_SUITE_WEP40) || (psecuritypriv->dot11PrivacyAlgrthm == WLAN_CIPHER_SUITE_WEP40 ||
(psecuritypriv->dot11PrivacyAlgrthm == WLAN_CIPHER_SUITE_WEP104))) { psecuritypriv->dot11PrivacyAlgrthm == WLAN_CIPHER_SUITE_WEP104)) {
/* set wep default key */ /* set wep default key */
psecuritypriv->ndisencryptstatus = Ndis802_11Encryption1Enabled; psecuritypriv->ndisencryptstatus = Ndis802_11Encryption1Enabled;
...@@ -1211,9 +1212,11 @@ static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, ...@@ -1211,9 +1212,11 @@ static int cfg80211_rtw_set_default_key(struct wiphy *wiphy,
psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP40; psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP40;
psecuritypriv->dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_WEP40; psecuritypriv->dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_WEP40;
if (psecuritypriv->dot11DefKeylen[key_index] == 13) { if (psecuritypriv->wep_key[key_index].keylen == 13) {
psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP104; psecuritypriv->dot11PrivacyAlgrthm =
psecuritypriv->dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_WEP104; WLAN_CIPHER_SUITE_WEP104;
psecuritypriv->dot118021XGrpPrivacy =
WLAN_CIPHER_SUITE_WEP104;
} }
/* set the flag to represent that wep default key /* set the flag to represent that wep default key
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment