diff options
Diffstat (limited to 'drivers/staging/rtl8723au/core/rtw_security.c')
-rw-r--r-- | drivers/staging/rtl8723au/core/rtw_security.c | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/drivers/staging/rtl8723au/core/rtw_security.c b/drivers/staging/rtl8723au/core/rtw_security.c index fd43e71bf6d6..d6c07adc7bf4 100644 --- a/drivers/staging/rtl8723au/core/rtw_security.c +++ b/drivers/staging/rtl8723au/core/rtw_security.c @@ -170,16 +170,17 @@ void rtw_wep_encrypt23a(struct rtw_adapter *padapter, pframe = pxmitframe->buf_addr + hw_hdr_offset; /* start to encrypt each fragment */ - if ((pattrib->encrypt != _WEP40_) && (pattrib->encrypt != _WEP104_)) + if (pattrib->encrypt != WLAN_CIPHER_SUITE_WEP40 && + pattrib->encrypt != WLAN_CIPHER_SUITE_WEP104) 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; @@ -225,17 +226,17 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter, pframe = skb->data; /* start to decrypt recvframe */ - if ((prxattrib->encrypt != _WEP40_) && (prxattrib->encrypt != _WEP104_)) + if (prxattrib->encrypt != WLAN_CIPHER_SUITE_WEP40 && + prxattrib->encrypt != WLAN_CIPHER_SUITE_WEP104) return; 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; @@ -248,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)" @@ -610,9 +611,9 @@ static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16) } /* The hlen isn't include the IV */ -u32 rtw_tkip_encrypt23a(struct rtw_adapter *padapter, - struct xmit_frame *pxmitframe) -{ /* exclude ICV */ +int rtw_tkip_encrypt23a(struct rtw_adapter *padapter, + struct xmit_frame *pxmitframe) +{ u16 pnl; u32 pnh; u8 rc4key[16]; @@ -622,14 +623,13 @@ u32 rtw_tkip_encrypt23a(struct rtw_adapter *padapter, struct arc4context mycontext; int curfragnum, length; u32 prwskeylen; - u8 *pframe, *payload,*iv,*prwskey; union pn48 dot11txpn; struct sta_info *stainfo; struct pkt_attrib *pattrib = &pxmitframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - u32 res = _SUCCESS; + int res = _SUCCESS; if (!pxmitframe->buf_addr) return _FAIL; @@ -638,14 +638,10 @@ u32 rtw_tkip_encrypt23a(struct rtw_adapter *padapter, pframe = pxmitframe->buf_addr + hw_hdr_offset; /* 4 start to encrypt each fragment */ - if (pattrib->encrypt == _TKIP_) { - + if (pattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) { if (pattrib->psta) - { stainfo = pattrib->psta; - } - else - { + else { DBG_8723A("%s, call rtw_get_stainfo()\n", __func__); stainfo = rtw_get_stainfo23a(&padapter->stapriv, &pattrib->ra[0]); @@ -716,10 +712,9 @@ u32 rtw_tkip_encrypt23a(struct rtw_adapter *padapter, } /* The hlen isn't include the IV */ -u32 rtw_tkip_decrypt23a(struct rtw_adapter *padapter, - struct recv_frame *precvframe) +int rtw_tkip_decrypt23a(struct rtw_adapter *padapter, + struct recv_frame *precvframe) { - /* exclude ICV */ u16 pnl; u32 pnh; u8 rc4key[16]; @@ -734,19 +729,19 @@ u32 rtw_tkip_decrypt23a(struct rtw_adapter *padapter, struct rx_pkt_attrib *prxattrib = &precvframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct sk_buff * skb = precvframe->pkt; - u32 res = _SUCCESS; + int res = _SUCCESS; pframe = skb->data; /* 4 start to decrypt recvframe */ - if (prxattrib->encrypt == _TKIP_) { + if (prxattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) { stainfo = rtw_get_stainfo23a(&padapter->stapriv, &prxattrib->ta[0]); if (stainfo!= NULL) { if (is_multicast_ether_addr(prxattrib->ra)) { - if (psecuritypriv->binstallGrpkey == false) { + if (psecuritypriv->binstallGrpkey == 0) { res = _FAIL; DBG_8723A("%s:rx bc/mc packets, but didn't install group key!!!!!!!!!!\n", __func__); goto exit; @@ -1303,7 +1298,8 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) return _SUCCESS; } -u32 rtw_aes_encrypt23a(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe) +int rtw_aes_encrypt23a(struct rtw_adapter *padapter, + struct xmit_frame *pxmitframe) { /* exclude ICV */ /* Intermediate Buffers */ int curfragnum, length; @@ -1314,7 +1310,7 @@ u32 rtw_aes_encrypt23a(struct rtw_adapter *padapter, struct xmit_frame *pxmitfra struct pkt_attrib *pattrib = &pxmitframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - u32 res = _SUCCESS; + int res = _SUCCESS; if (!pxmitframe->buf_addr) return _FAIL; @@ -1324,7 +1320,7 @@ u32 rtw_aes_encrypt23a(struct rtw_adapter *padapter, struct xmit_frame *pxmitfra pframe = pxmitframe->buf_addr + hw_hdr_offset; /* 4 start to encrypt each fragment */ - if (pattrib->encrypt != _AES_) + if (pattrib->encrypt != WLAN_CIPHER_SUITE_CCMP) return _FAIL; if (pattrib->psta) { @@ -1586,7 +1582,8 @@ static int aes_decipher(u8 *key, uint hdrlen, return res; } -u32 rtw_aes_decrypt23a(struct rtw_adapter *padapter, struct recv_frame *precvframe) +int rtw_aes_decrypt23a(struct rtw_adapter *padapter, + struct recv_frame *precvframe) { /* exclude ICV */ struct sta_info *stainfo; struct rx_pkt_attrib *prxattrib = &precvframe->attrib; @@ -1594,11 +1591,11 @@ u32 rtw_aes_decrypt23a(struct rtw_adapter *padapter, struct recv_frame *precvfra struct sk_buff *skb = precvframe->pkt; int length; u8 *pframe, *prwskey; /* *payload,*iv */ - u32 res = _SUCCESS; + int res = _SUCCESS; pframe = skb->data; /* 4 start to encrypt each fragment */ - if (prxattrib->encrypt != _AES_) + if (prxattrib->encrypt != WLAN_CIPHER_SUITE_CCMP) return _FAIL; stainfo = rtw_get_stainfo23a(&padapter->stapriv, &prxattrib->ta[0]); @@ -1645,7 +1642,7 @@ void rtw_use_tkipkey_handler23a(void *FunctionContext) struct rtw_adapter *padapter = (struct rtw_adapter *)FunctionContext; RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("^^^rtw_use_tkipkey_handler23a ^^^\n")); - padapter->securitypriv.busetkipkey = true; + padapter->securitypriv.busetkipkey = 1; RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("^^^rtw_use_tkipkey_handler23a padapter->securitypriv.busetkipkey =%d^^^\n", padapter->securitypriv.busetkipkey)); |