summaryrefslogtreecommitdiffstats
path: root/kernel/drivers/staging/rtl8723au/core/rtw_security.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/drivers/staging/rtl8723au/core/rtw_security.c')
-rw-r--r--kernel/drivers/staging/rtl8723au/core/rtw_security.c41
1 files changed, 18 insertions, 23 deletions
diff --git a/kernel/drivers/staging/rtl8723au/core/rtw_security.c b/kernel/drivers/staging/rtl8723au/core/rtw_security.c
index af53c92fc..038b57b3a 100644
--- a/kernel/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/kernel/drivers/staging/rtl8723au/core/rtw_security.c
@@ -148,7 +148,7 @@ void rtw_wep_encrypt23a(struct rtw_adapter *padapter,
struct xmit_frame *pxmitframe)
{
/* exclude ICV */
- unsigned char crc[4];
+ __le32 crc;
struct arc4context mycontext;
int curfragnum, length, index;
u32 keylength;
@@ -186,18 +186,20 @@ void rtw_wep_encrypt23a(struct rtw_adapter *padapter,
length = pattrib->last_txcmdsz - pattrib->hdrlen -
pattrib->iv_len - pattrib->icv_len;
- *((u32 *)crc) = cpu_to_le32(getcrc32(payload, length));
+ crc = cpu_to_le32(getcrc32(payload, length));
arcfour_init(&mycontext, wepkey, 3 + keylength);
arcfour_encrypt(&mycontext, payload, payload, length);
- arcfour_encrypt(&mycontext, payload + length, crc, 4);
+ arcfour_encrypt(&mycontext, payload + length,
+ (char *)&crc, 4);
} else {
length = pxmitpriv->frag_len - pattrib->hdrlen -
pattrib->iv_len - pattrib->icv_len;
- *((u32 *)crc) = cpu_to_le32(getcrc32(payload, length));
+ crc = cpu_to_le32(getcrc32(payload, length));
arcfour_init(&mycontext, wepkey, 3 + keylength);
arcfour_encrypt(&mycontext, payload, payload, length);
- arcfour_encrypt(&mycontext, payload + length, crc, 4);
+ arcfour_encrypt(&mycontext, payload + length,
+ (char *)&crc, 4);
pframe += pxmitpriv->frag_len;
pframe = PTR_ALIGN(pframe, 4);
@@ -243,8 +245,8 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter,
arcfour_encrypt(&mycontext, payload, payload, length);
/* calculate icv and compare the icv */
- actual_crc = le32_to_cpu(getcrc32(payload, length - 4));
- expected_crc = le32_to_cpu(get_unaligned_le32(&payload[length - 4]));
+ actual_crc = getcrc32(payload, length - 4);
+ expected_crc = get_unaligned_le32(&payload[length - 4]);
if (actual_crc != expected_crc) {
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
@@ -602,11 +604,10 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
u32 pnh;
u8 rc4key[16];
u8 ttkey[16];
- u8 crc[4];
+ __le32 crc;
u8 hw_hdr_offset = 0;
struct arc4context mycontext;
int curfragnum, length;
- u32 prwskeylen;
u8 *pframe, *payload, *iv, *prwskey;
union pn48 dot11txpn;
struct sta_info *stainfo;
@@ -653,8 +654,6 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
else
prwskey = &stainfo->dot118021x_UncstKey.skey[0];
- prwskeylen = 16;
-
/* 4 start to encrypt each fragment */
for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) {
iv = pframe + pattrib->hdrlen;
@@ -679,11 +678,12 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
"pattrib->iv_len =%x, pattrib->icv_len =%x\n",
pattrib->iv_len,
pattrib->icv_len);
- *((u32 *)crc) = cpu_to_le32(getcrc32(payload, length));
+ crc = cpu_to_le32(getcrc32(payload, length));
arcfour_init(&mycontext, rc4key, 16);
arcfour_encrypt(&mycontext, payload, payload, length);
- arcfour_encrypt(&mycontext, payload + length, crc, 4);
+ arcfour_encrypt(&mycontext, payload + length,
+ (char *)&crc, 4);
} else {
length = (pxmitpriv->frag_len -
@@ -691,10 +691,11 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
pattrib->iv_len -
pattrib->icv_len);
- *((u32 *)crc) = cpu_to_le32(getcrc32(payload, length));
+ crc = cpu_to_le32(getcrc32(payload, length));
arcfour_init(&mycontext, rc4key, 16);
arcfour_encrypt(&mycontext, payload, payload, length);
- arcfour_encrypt(&mycontext, payload + length, crc, 4);
+ arcfour_encrypt(&mycontext, payload + length,
+ (char *)&crc, 4);
pframe += pxmitpriv->frag_len;
pframe = PTR_ALIGN(pframe, 4);
@@ -715,7 +716,6 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
u32 actual_crc, expected_crc;
struct arc4context mycontext;
int length;
- u32 prwskeylen;
u8 *pframe, *payload, *iv, *prwskey;
union pn48 dot11txpn;
struct sta_info *stainfo;
@@ -745,12 +745,10 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
goto exit;
}
prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey;
- prwskeylen = 16;
} else {
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
"%s: stainfo!= NULL!!!\n", __func__);
prwskey = &stainfo->dot118021x_UncstKey.skey[0];
- prwskeylen = 16;
}
iv = pframe + prxattrib->hdrlen;
@@ -769,8 +767,8 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
arcfour_init(&mycontext, rc4key, 16);
arcfour_encrypt(&mycontext, payload, payload, length);
- actual_crc = le32_to_cpu(getcrc32(payload, length - 4));
- expected_crc = le32_to_cpu(get_unaligned_le32(&payload[length - 4]));
+ actual_crc = getcrc32(payload, length - 4);
+ expected_crc = get_unaligned_le32(&payload[length - 4]);
if (actual_crc != expected_crc) {
RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
@@ -1284,7 +1282,6 @@ int rtw_aes_encrypt23a(struct rtw_adapter *padapter,
{ /* exclude ICV */
/* Intermediate Buffers */
int curfragnum, length;
- u32 prwskeylen;
u8 *pframe, *prwskey;
u8 hw_hdr_offset = 0;
struct sta_info *stainfo;
@@ -1331,8 +1328,6 @@ int rtw_aes_encrypt23a(struct rtw_adapter *padapter,
else
prwskey = &stainfo->dot118021x_UncstKey.skey[0];
- prwskeylen = 16;
-
for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) {
/* 4 the last fragment */
if ((curfragnum + 1) == pattrib->nr_frags) {