* [PATCH 0/2] staging: rtl8723bs: use of generic CRC-32
@ 2021-05-10 12:46 Fabio Aiuto
2021-05-10 12:46 ` [PATCH 1/2] staging: rtl8723bs: replace private CRC-32 routines with in-kernel ones Fabio Aiuto
2021-05-10 12:46 ` [PATCH 2/2] staging: rtl8723bs: move comments to silence 'line too long' warning Fabio Aiuto
0 siblings, 2 replies; 5+ messages in thread
From: Fabio Aiuto @ 2021-05-10 12:46 UTC (permalink / raw)
To: gregkh; +Cc: linux-staging, linux-kernel
This patchset replaces all private CRC-32 routines with
generic ones.
Fabio Aiuto (2):
staging: rtl8723bs: replace private CRC-32 routines with in-kernel ones
staging: rtl8723bs: move comments to silence 'line too long' warning
drivers/staging/rtl8723bs/core/rtw_security.c | 69 +++----------------
1 file changed, 10 insertions(+), 59 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] staging: rtl8723bs: replace private CRC-32 routines with in-kernel ones
2021-05-10 12:46 [PATCH 0/2] staging: rtl8723bs: use of generic CRC-32 Fabio Aiuto
@ 2021-05-10 12:46 ` Fabio Aiuto
2021-05-10 12:46 ` [PATCH 2/2] staging: rtl8723bs: move comments to silence 'line too long' warning Fabio Aiuto
1 sibling, 0 replies; 5+ messages in thread
From: Fabio Aiuto @ 2021-05-10 12:46 UTC (permalink / raw)
To: gregkh; +Cc: linux-staging, linux-kernel
replace private CRC-32 routines with in-kernel ones.
Signed-off-by: Fabio Aiuto <fabioaiuto83@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_security.c | 66 ++-----------------
1 file changed, 7 insertions(+), 59 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
index 19f96025aea6..bee1b2e2504e 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -4,7 +4,7 @@
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
******************************************************************************/
-#include <linux/crc32poly.h>
+#include <linux/crc32.h>
#include <drv_types.h>
#include <rtw_debug.h>
#include <crypto/aes.h>
@@ -31,58 +31,6 @@ const char *security_type_str(u8 value)
/* WEP related ===== */
-static signed int bcrc32initialized;
-static u32 crc32_table[256];
-
-
-static u8 crc32_reverseBit(u8 data)
-{
- return((u8)((data<<7)&0x80) | ((data<<5)&0x40) | ((data<<3)&0x20) | ((data<<1)&0x10) | ((data>>1)&0x08) | ((data>>3)&0x04) | ((data>>5)&0x02) | ((data>>7)&0x01));
-}
-
-static void crc32_init(void)
-{
- if (bcrc32initialized == 1)
- return;
- else {
- signed int i, j;
- u32 c;
- u8 *p = (u8 *)&c, *p1;
- u8 k;
-
- c = 0x12340000;
-
- for (i = 0; i < 256; ++i) {
- k = crc32_reverseBit((u8)i);
- for (c = ((u32)k) << 24, j = 8; j > 0; --j)
- c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY_BE : (c << 1);
- p1 = (u8 *)&crc32_table[i];
-
- p1[0] = crc32_reverseBit(p[3]);
- p1[1] = crc32_reverseBit(p[2]);
- p1[2] = crc32_reverseBit(p[1]);
- p1[3] = crc32_reverseBit(p[0]);
- }
- bcrc32initialized = 1;
- }
-}
-
-static __le32 getcrc32(u8 *buf, signed 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
*/
@@ -122,7 +70,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
- *((__le32 *)crc) = getcrc32(payload, length);
+ *((__le32 *)crc) = ~crc32_le(~0, payload, length);
arc4_setkey(&mycontext, wepkey, 3 + keylength);
arc4_crypt(&mycontext, payload, payload, length);
@@ -130,7 +78,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
} else {
length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
- *((__le32 *)crc) = getcrc32(payload, length);
+ *((__le32 *)crc) = ~crc32_le(~0, payload, length);
arc4_setkey(&mycontext, wepkey, 3 + keylength);
arc4_crypt(&mycontext, payload, payload, length);
arc4_crypt(&mycontext, payload + length, crc, 4);
@@ -174,7 +122,7 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe)
arc4_crypt(&mycontext, payload, payload, length);
/* calculate icv and compare the icv */
- *((u32 *)crc) = le32_to_cpu(getcrc32(payload, length-4));
+ *((u32 *)crc) = le32_to_cpu(~crc32_le(~0, payload, length - 4));
}
}
@@ -559,7 +507,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *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) = ~crc32_le(~0, payload, length);/* modified by Amy*/
arc4_setkey(&mycontext, rc4key, 16);
arc4_crypt(&mycontext, payload, payload, length);
@@ -567,7 +515,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
} else {
length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
- *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/
+ *((__le32 *)crc) = ~crc32_le(~0, payload, length);/* modified by Amy*/
arc4_setkey(&mycontext, rc4key, 16);
arc4_crypt(&mycontext, payload, payload, length);
arc4_crypt(&mycontext, payload + length, crc, 4);
@@ -670,7 +618,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
arc4_setkey(&mycontext, rc4key, 16);
arc4_crypt(&mycontext, payload, payload, length);
- *((u32 *)crc) = le32_to_cpu(getcrc32(payload, length-4));
+ *((u32 *)crc) = le32_to_cpu(~crc32_le(~0, payload, length - 4));
if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] ||
crc[1] != payload[length - 3] || crc[0] != payload[length - 4])
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] staging: rtl8723bs: move comments to silence 'line too long' warning
2021-05-10 12:46 [PATCH 0/2] staging: rtl8723bs: use of generic CRC-32 Fabio Aiuto
2021-05-10 12:46 ` [PATCH 1/2] staging: rtl8723bs: replace private CRC-32 routines with in-kernel ones Fabio Aiuto
@ 2021-05-10 12:46 ` Fabio Aiuto
2021-05-10 13:00 ` Dan Carpenter
1 sibling, 1 reply; 5+ messages in thread
From: Fabio Aiuto @ 2021-05-10 12:46 UTC (permalink / raw)
To: gregkh; +Cc: linux-staging, linux-kernel
move comments to fix the following post commit hook
checkpatch warnings:
WARNING: line length of 110 exceeds 100 columns
115: FILE: drivers/staging/rtl8723bs/core/rtw_security.c:510:
+ *((__le32 *)crc)
= ~crc32_le(~0, payload, length);/* modified by Amy*/
WARNING: line length of 110 exceeds 100 columns
124: FILE: drivers/staging/rtl8723bs/core/rtw_security.c:518:
+ *((__le32 *)crc)
= ~crc32_le(~0, payload, length);/* modified by Amy*/
Signed-off-by: Fabio Aiuto <fabioaiuto83@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_security.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
index bee1b2e2504e..4d0a86b69f41 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -507,7 +507,8 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *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) = ~crc32_le(~0, payload, length);/* modified by Amy*/
+ /* modified by Amy*/
+ *((__le32 *)crc) = ~crc32_le(~0, payload, length);
arc4_setkey(&mycontext, rc4key, 16);
arc4_crypt(&mycontext, payload, payload, length);
@@ -515,7 +516,9 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
} else {
length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
- *((__le32 *)crc) = ~crc32_le(~0, payload, length);/* modified by Amy*/
+ /* modified by Amy*/
+ *((__le32 *)crc) = ~crc32_le(~0, payload, length);
+
arc4_setkey(&mycontext, rc4key, 16);
arc4_crypt(&mycontext, payload, payload, length);
arc4_crypt(&mycontext, payload + length, crc, 4);
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] staging: rtl8723bs: move comments to silence 'line too long' warning
2021-05-10 12:46 ` [PATCH 2/2] staging: rtl8723bs: move comments to silence 'line too long' warning Fabio Aiuto
@ 2021-05-10 13:00 ` Dan Carpenter
2021-05-10 13:12 ` Fabio Aiuto
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2021-05-10 13:00 UTC (permalink / raw)
To: Fabio Aiuto; +Cc: gregkh, linux-staging, linux-kernel
On Mon, May 10, 2021 at 02:46:19PM +0200, Fabio Aiuto wrote:
> move comments to fix the following post commit hook
> checkpatch warnings:
>
> WARNING: line length of 110 exceeds 100 columns
> 115: FILE: drivers/staging/rtl8723bs/core/rtw_security.c:510:
> + *((__le32 *)crc)
> = ~crc32_le(~0, payload, length);/* modified by Amy*/
Please delete the Amy comments. :P
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] staging: rtl8723bs: move comments to silence 'line too long' warning
2021-05-10 13:00 ` Dan Carpenter
@ 2021-05-10 13:12 ` Fabio Aiuto
0 siblings, 0 replies; 5+ messages in thread
From: Fabio Aiuto @ 2021-05-10 13:12 UTC (permalink / raw)
To: Dan Carpenter; +Cc: gregkh, linux-staging, linux-kernel
On Mon, May 10, 2021 at 04:00:19PM +0300, Dan Carpenter wrote:
> On Mon, May 10, 2021 at 02:46:19PM +0200, Fabio Aiuto wrote:
> > move comments to fix the following post commit hook
> > checkpatch warnings:
> >
> > WARNING: line length of 110 exceeds 100 columns
> > 115: FILE: drivers/staging/rtl8723bs/core/rtw_security.c:510:
> > + *((__le32 *)crc)
> > = ~crc32_le(~0, payload, length);/* modified by Amy*/
>
> Please delete the Amy comments. :P
ok, will fix and submit a v2 :)
>
> regards,
> dan carpenter
>
thank you,
fabio
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-05-10 13:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10 12:46 [PATCH 0/2] staging: rtl8723bs: use of generic CRC-32 Fabio Aiuto
2021-05-10 12:46 ` [PATCH 1/2] staging: rtl8723bs: replace private CRC-32 routines with in-kernel ones Fabio Aiuto
2021-05-10 12:46 ` [PATCH 2/2] staging: rtl8723bs: move comments to silence 'line too long' warning Fabio Aiuto
2021-05-10 13:00 ` Dan Carpenter
2021-05-10 13:12 ` Fabio Aiuto
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).