* [PATCH v2] staging: rtl8188eu: Replace a custom function with crc32_le()
@ 2021-07-13 18:46 Fabio M. De Francesco
0 siblings, 0 replies; only message in thread
From: Fabio M. De Francesco @ 2021-07-13 18:46 UTC (permalink / raw)
To: Larry Finger, Greg Kroah-Hartman, linux-staging, linux-kernel,
fabioaiuto83
Cc: Fabio M. De Francesco
Use kernel API crc32_le() in place of the custom getcrc32().
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
---
v1 --> v2:
Use cpu_to_le32() to assign native endian return value of crc32_le to
crc.
drivers/staging/rtl8188eu/core/rtw_security.c | 23 ++++---------------
1 file changed, 5 insertions(+), 18 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c
index 1b2cb6196463..e9de61afe881 100644
--- a/drivers/staging/rtl8188eu/core/rtw_security.c
+++ b/drivers/staging/rtl8188eu/core/rtw_security.c
@@ -11,6 +11,7 @@
#include <wifi.h>
#include <osdep_intf.h>
#include <net/lib80211.h>
+#include <linux/types.h>
/* WEP related ===== */
@@ -111,21 +112,6 @@ static void crc32_init(void)
bcrc32initialized = 1;
}
-static __le32 getcrc32(u8 *buf, int len)
-{
- u8 *p;
- u32 crc;
-
- if (bcrc32initialized == 0)
- crc32_init();
-
- crc = 0xffffffff; /* preload shift register, per CRC-32 spec */
-
- for (p = buf; len > 0; ++p, --len)
- crc = crc32_table[(crc ^ *p) & 0xff] ^ (crc >> 8);
- return cpu_to_le32(~crc); /* transmit complement, per CRC-32 spec */
-}
-
/* Need to consider the fragment situation */
void rtw_wep_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe)
{
@@ -609,14 +595,15 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe)
if ((curfragnum + 1) == pattrib->nr_frags) { /* 4 the last fragment */
length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;
- *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/
+ *((__le32 *)crc) = cpu_to_le32(~crc32_le(~0, payload, length));
arcfour_init(&mycontext, rc4key, 16);
arcfour_encrypt(&mycontext, payload, payload, length);
arcfour_encrypt(&mycontext, payload + length, crc, 4);
} else {
length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;
- *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/
+ *((__le32 *)crc) = cpu_to_le32(~crc32_le(~0, payload, length));
+
arcfour_init(&mycontext, rc4key, 16);
arcfour_encrypt(&mycontext, payload, payload, length);
arcfour_encrypt(&mycontext, payload + length, crc, 4);
@@ -682,7 +669,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, struct recv_frame *precvframe)
arcfour_init(&mycontext, rc4key, 16);
arcfour_encrypt(&mycontext, payload, payload, length);
- *((__le32 *)crc) = getcrc32(payload, length - 4);
+ *((__le32 *)crc) = cpu_to_le32(~crc32_le(~0, payload, length - 4));
if (crc[3] != payload[length - 1] ||
crc[2] != payload[length - 2] ||
--
2.32.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-13 18:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-13 18:46 [PATCH v2] staging: rtl8188eu: Replace a custom function with crc32_le() Fabio M. De Francesco
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).