Adhere to coding style
v2 cover Adhere to coding style
Edit the file to adhere to the kernel coding style. Reported by checkpatch.
v2 changes: Fix some edits put in the wrong patch, thanks to Dan's keen eyes.
Ian To (3):
staging: rtl8723bs: format comments
stagin: rtl8723bs: fix spacing
staging: rtl8723bs: remove extra blank lines
drivers/staging/rtl8723bs/core/rtw_security.c | 279 +++++++++--------- 1 file changed, 133 insertions(+), 146 deletions(-)
Signature · 1 line
2.45.3
PATCH v2 1/3 staging: rtl8723bs: format comments
Some comments were not formatted correctly. Reported by checkpatch.
--- drivers/staging/rtl8723bs/core/rtw_security.c | 92 +++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-)
drivers/staging/rtl8723bs/core/rtw_security.c +46 -46
@@ -30,10 +30,10 @@ const char *security_type_str(u8 value)/* WEP related ===== */ /* -Need to consider the fragment situation -*/ +* Need to consider the fragment situation +*/ void rtw_wep_encrypt (struct adapter *padapter,u8 *pxmitframe) -{/* exclude ICV */ +{union {__le32 f0;unsigned char f1[4 ];
@@ -342,23 +342,23 @@ static const unsigned short Sbox1[2][256] = { /* Sbox for hash (can be in R } }; -/* -********************************************************************** -* Routine: Phase 1 -- generate P1K, given TA, TK, IV32 -* -* Inputs: -* tk[] = temporal key [128 bits] -* ta[] = transmitter's MAC address [ 48 bits] -* iv32 = upper 32 bits of IV [ 32 bits] -* Output: -* p1k[] = Phase 1 key [ 80 bits] -* -* Note: -* This function only needs to be called every 2**16 packets, -* although in theory it could be called every packet. -* -********************************************************************** -*/ +/* +********************************************************************** +* Routine: Phase 1 -- generate P1K, given TA, TK, IV32 +* +* Inputs: +* tk[] = temporal key [128 bits] +* ta[] = transmitter's MAC address [ 48 bits] +* iv32 = upper 32 bits of IV [ 32 bits] +* Output: +* p1k[] = Phase 1 key [ 80 bits] +* +* Note: +* This function only needs to be called every 2**16 packets, +* although in theory it could be called every packet. +* +********************************************************************** +*/ static void phase1 (u16 *p1k,const u8 *tk,const u8 *ta,u32 iv32) {signed int i;
@@ -383,30 +383,29 @@ static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32) } } -/* -********************************************************************** -* Routine: Phase 2 -- generate RC4KEY, given TK, P1K, IV16 -* -* Inputs: -* tk[] = Temporal key [128 bits] -* p1k[] = Phase 1 output key [ 80 bits] -* iv16 = low 16 bits of IV counter [ 16 bits] -* Output: -* rc4key[] = the key used to encrypt the packet [128 bits] -* -* Note: -* The value {TA, IV32, IV16} for Phase1/Phase2 must be unique -* across all packets using the same key TK value. Then, for a -* given value of TK[], this TKIP48 construction guarantees that -* the final RC4KEY value is unique across all packets. -* -* Suggested implementation optimization: if PPK[] is "overlaid" -* appropriately on RC4KEY[], there is no need for the final -* for loop below that copies the PPK[] result into RC4KEY[]. -* -********************************************************************** -*/ +********************************************************************** +* Routine: Phase 2 -- generate RC4KEY, given TK, P1K, IV16 +* +* Inputs: +* tk[] = Temporal key [128 bits] +* p1k[] = Phase 1 output key [ 80 bits] +* iv16 = low 16 bits of IV counter [ 16 bits] +* Output: +* rc4key[] = the key used to encrypt the packet [128 bits] +* +* Note: +* The value {TA, IV32, IV16} for Phase1/Phase2 must be unique +* across all packets using the same key TK value. Then, for a +* given value of TK[], this TKIP48 construction guarantees that +* the final RC4KEY value is unique across all packets. +* +* Suggested implementation optimization: if PPK[] is "overlaid" +* appropriately on RC4KEY[], there is no need for the final +* for loop below that copies the PPK[] result into RC4KEY[]. +* +********************************************************************** +*/ static void phase2 (u8 *rc4key,const u8 *tk,const u16 *p1k,u16 iv16) {signed int i;
@@ -1456,7 +1455,7 @@ static void gf_mulx(u8 *pad) pad[AES_BLOCK_SIZE -1 ] ^=0x87 ; } -/** +/* * omac1_aes_128_vector - One-Key CBC MAC (OMAC1) hash with AES-128 * @key: 128-bit key for the hash operation * @num_elem: Number of elements in the data vector
@@ -1530,7 +1529,7 @@ static int omac1_aes_128_vector(u8 *key, size_t num_elem,return 0 ; } -/** +/* * omac1_aes_128 - One-Key CBC MAC (OMAC1) hash with AES-128 (aka AES-CMAC) * @key: 128-bit key for the hash operation * @data: Data buffer for which a MAC is determined
@@ -1541,7 +1540,8 @@ static int omac1_aes_128_vector(u8 *key, size_t num_elem,* This is a mode for using block cipher (AES in this case) for authentication. * OMAC1 was standardized with the name CMAC by NIST in a Special Publication * (SP) 800-38B. -* modify for CONFIG_IEEE80211W */ +* modify for CONFIG_IEEE80211W +*/ int omac1_aes_128 (u8 *key,u8 *data,size_t data_len,u8 *mac) {return omac1_aes_128_vector (key,1 , &data, &data_len, mac);
Signature · 1 line
2.45.3
PATCH v2 2/3 stagin: rtl8723bs: fix spacing
In reply to Ian ToFixed spacing issues. Reported by checkpatch.
--- drivers/staging/rtl8723bs/core/rtw_security.c | 176 +++++++++--------- 1 file changed, 87 insertions(+), 89 deletions(-)
drivers/staging/rtl8723bs/core/rtw_security.c +87 -89
@@ -61,14 +61,14 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) keylength = psecuritypriv->dot11DefKeylen[psecuritypriv->dot11PrivacyKeyIndex];for (curfragnum =0 ; curfragnum < pattrib->nr_frags; curfragnum++) { - iv = pframe+pattrib->hdrlen; + iv = pframe + pattrib->hdrlen;memcpy (&wepkey[0 ], iv,3 );memcpy (&wepkey[3 ], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0 ], keylength); - payload = pframe+pattrib->iv_len+pattrib->hdrlen; + payload = pframe + pattrib->iv_len + pattrib->hdrlen; -if ((curfragnum+1 ) == pattrib->nr_frags) {/* the last fragment */ +if ((curfragnum +1 ) == pattrib->nr_frags) {/* the last fragment */ - length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; crc.f0 =cpu_to_le32 (~crc32_le (~0 , payload, length));
@@ -77,7 +77,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)arc4_crypt (ctx, payload + length, crc.f1,4 ); }else { - length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; crc.f0 =cpu_to_le32 (~crc32_le (~0 , payload, length));arc4_setkey (ctx, wepkey,3 + keylength);arc4_crypt (ctx, payload, payload, length);
@@ -106,16 +106,16 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe)/* start to decrypt recvframe */ if ((prxattrib->encrypt == _WEP40_) || (prxattrib->encrypt == _WEP104_)) { - iv = pframe+prxattrib->hdrlen; + iv = pframe + prxattrib->hdrlen;/* keyindex =(iv[3]&0x3); */ keyindex = prxattrib->key_index; keylength = psecuritypriv->dot11DefKeylen[keyindex];memcpy (&wepkey[0 ], iv,3 );/* memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0], keylength); */ memcpy (&wepkey[3 ], &psecuritypriv->dot11DefKey[keyindex].skey[0 ], keylength); - length = ((union recv_frame *)precvframe)->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; + length = ((union recv_frame *)precvframe)->u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len; - payload = pframe+prxattrib->iv_len+prxattrib->hdrlen; + payload = pframe + prxattrib->iv_len + prxattrib->hdrlen;/* decrypt payload include icv */ arc4_setkey (ctx, wepkey,3 + keylength);
@@ -147,7 +147,7 @@ static void secmicputuint32(u8 *p, u32 val)long i;for (i =0 ; i <4 ; i++) { - *p++ = (u8) (val &0xff ); + *p++ = (u8)(val &0xff ); val >>=8 ; } }
@@ -173,7 +173,7 @@ void rtw_secmicsetkey(struct mic_data *pmicdata, u8 *key)void rtw_secmicappendbyte (struct mic_data *pmicdata,u8 b) {/* Append the byte to our word-sized buffer */ - pmicdata->M |= ((unsigned long )b) << (8 *pmicdata->nBytesInM); + pmicdata->M |= ((unsigned long )b) << (8 * pmicdata->nBytesInM); pmicdata->nBytesInM++;/* Process the word if it is full. */ if (pmicdata->nBytesInM >=4 ) {
@@ -260,7 +260,7 @@ void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_cod#define Mk16 (hi, lo) ((lo) ^ (((u16)(hi)) << 8))/* select the Nth 16-bit word of the temporal key unsigned char array TK[] */ -#define TK16 (N ) Mk16(tk[2*(N)+1], tk[2*(N)]) +#define TK16 (N ) Mk16(tk[2 * (N) + 1], tk[2 * (N)])/* S-box lookup: 16 bits --> 16 bits */ #define _S_ (v16) (Sbox1[0][Lo8(v16)] ^ Sbox1[1][Hi8(v16)])
@@ -374,11 +374,11 @@ static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32)/* size on the 80-bit block P1K[], using the 128-bit key TK[] */ for (i =0 ; i <PHASE1_LOOP_CNT ; i++) {/* Each add operation here is mod 2**16 */ - p1k[0 ] +=_S_ (p1k[4 ] ^TK16 ((i&1 )+0 )); - p1k[1 ] +=_S_ (p1k[0 ] ^TK16 ((i&1 )+2 )); - p1k[2 ] +=_S_ (p1k[1 ] ^TK16 ((i&1 )+4 )); - p1k[3 ] +=_S_ (p1k[2 ] ^TK16 ((i&1 )+6 )); - p1k[4 ] +=_S_ (p1k[3 ] ^TK16 ((i&1 )+0 )); + p1k[0 ] +=_S_ (p1k[4 ] ^TK16 ((i &1 ) +0 )); + p1k[1 ] +=_S_ (p1k[0 ] ^TK16 ((i &1 ) +2 )); + p1k[2 ] +=_S_ (p1k[1 ] ^TK16 ((i &1 ) +4 )); + p1k[3 ] +=_S_ (p1k[2 ] ^TK16 ((i &1 ) +6 )); + p1k[4 ] +=_S_ (p1k[3 ] ^TK16 ((i &1 ) +0 )); p1k[4 ] += (unsigned short )i;/* avoid "slide attacks" */ } }
@@ -415,7 +415,7 @@ static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16)for (i =0 ; i <5 ; i++)PPK [i] = p1k[i];/* first, copy P1K to PPK */ -PPK [5 ] = p1k[4 ]+iv16;/* next, add in IV16 */ +PPK [5 ] = p1k[4 ] + iv16;/* next, add in IV16 */ /* Bijective non-linear mixing of the 96 bits of PPK[0..5] */ PPK [0 ] +=_S_ (PPK [5 ] ^TK16 (0 ));/* Mix key in each "round" */
@@ -443,15 +443,13 @@ static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16) rc4key[2 ] =Lo8 (iv16); rc4key[3 ] =Lo8 ((PPK [5 ] ^TK16 (0 )) >>1 ); -/* Copy 96 bits of PPK[0..5] to RC4KEY[4..15] (little-endian) */ for (i =0 ; i <6 ; i++) { - rc4key[4 +2 *i] =Lo8 (PPK [i]); - rc4key[5 +2 *i] =Hi8 (PPK [i]); + rc4key[4 +2 * i] =Lo8 (PPK [i]); + rc4key[5 +2 * i] =Hi8 (PPK [i]); } } -/* The hlen isn't include the IV */ u32 rtw_tkip_encrypt (struct adapter *padapter,u8 *pxmitframe) {/* exclude ICV */
@@ -490,20 +488,20 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) prwskey = pattrib->dot118021x_UncstKey.skey;for (curfragnum =0 ; curfragnum < pattrib->nr_frags; curfragnum++) { - iv = pframe+pattrib->hdrlen; - payload = pframe+pattrib->iv_len+pattrib->hdrlen; + iv = pframe + pattrib->hdrlen; + payload = pframe + pattrib->iv_len + pattrib->hdrlen;GET_TKIP_PN (iv, dot11txpn); pnl = (u16)(dot11txpn.val); - pnh = (u32)(dot11txpn.val>>16 ); + pnh = (u32)(dot11txpn.val >>16 );phase1 ((u16 *)&ttkey[0 ], prwskey, &pattrib->ta[0 ], pnh);phase2 (&rc4key[0 ], prwskey, (u16 *)&ttkey[0 ], pnl); -if ((curfragnum+1 ) == pattrib->nr_frags) {/* 4 the last fragment */ - length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; +if ((curfragnum +1 ) == pattrib->nr_frags) {/* 4 the last fragment */ + length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; crc.f0 =cpu_to_le32 (~crc32_le (~0 , payload, length));arc4_setkey (ctx, rc4key,16 );
@@ -511,7 +509,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)arc4_crypt (ctx, payload + length, crc.f1,4 ); }else { - length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; crc.f0 =cpu_to_le32 (~crc32_le (~0 , payload, length));arc4_setkey (ctx, rc4key,16 );
@@ -599,14 +597,14 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) prwskey = &stainfo->dot118021x_UncstKey.skey[0 ]; } - iv = pframe+prxattrib->hdrlen; - payload = pframe+prxattrib->iv_len+prxattrib->hdrlen; - length = ((union recv_frame *)precvframe)->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; + iv = pframe + prxattrib->hdrlen; + payload = pframe + prxattrib->iv_len + prxattrib->hdrlen; + length = ((union recv_frame *)precvframe)->u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len;GET_TKIP_PN (iv, dot11txpn); pnl = (u16)(dot11txpn.val); - pnh = (u32)(dot11txpn.val>>16 ); + pnh = (u32)(dot11txpn.val >>16 );phase1 ((u16 *)&ttkey[0 ], prwskey, &prxattrib->ta[0 ], pnh);phase2 (&rc4key[0 ], prwskey, (unsigned short *)&ttkey[0 ], pnl);
@@ -721,8 +719,8 @@ static void construct_mic_iv(u8 *mic_iv,for (i =8 ; i <14 ; i++) mic_iv[i] = pn_vector[13 - i];/* mic_iv[8:13] = PN[5:0] */ #endif - mic_iv[14 ] = (unsigned char ) (payload_length /256 ); - mic_iv[15 ] = (unsigned char ) (payload_length %256 ); + mic_iv[14 ] = (unsigned char )(payload_length /256 ); + mic_iv[15 ] = (unsigned char )(payload_length %256 ); }/************************************************/
@@ -787,7 +785,7 @@ static void construct_mic_header2(u8 *mic_header2,if (!qc_exists && a4_exists) {for (i =0 ; i <6 ; i++) - mic_header2[8 +i] = mpdu[24 +i];/* A4 */ + mic_header2[8 + i] = mpdu[24 + i];/* A4 */ }if (qc_exists && !a4_exists) {
@@ -797,7 +795,7 @@ static void construct_mic_header2(u8 *mic_header2,if (qc_exists && a4_exists) {for (i =0 ; i <6 ; i++) - mic_header2[8 +i] = mpdu[24 +i];/* A4 */ + mic_header2[8 + i] = mpdu[24 + i];/* A4 */ mic_header2[14 ] = mpdu[30 ] &0x0f ; mic_header2[15 ] = mpdu[31 ] &0x00 ;
@@ -844,8 +842,8 @@ static void construct_ctr_preload(u8 *ctr_preload,for (i =8 ; i <14 ; i++) ctr_preload[i] = pn_vector[13 - i];/* ctr_preload[8:13] = PN[5:0] */ #endif - ctr_preload[14 ] = (unsigned char ) (c /256 );/* Ctr */ - ctr_preload[15 ] = (unsigned char ) (c %256 ); + ctr_preload[14 ] = (unsigned char )(c /256 );/* Ctr */ + ctr_preload[15 ] = (unsigned char )(c %256 ); }/************************************/
@@ -861,7 +859,7 @@ static void bitwise_xor(u8 *ina, u8 *inb, u8 *out) }static signed int aes_cipher (u8 *key,uint hdrlen, -u8 *pframe,uint plen) +u8 *pframe,uint plen) {uint qc_exists, a4_exists, i, j, payload_remainder, num_blocks, payload_index;
@@ -880,7 +878,7 @@ static signed int aes_cipher(u8 *key, uint hdrlen,uint frtype =GetFrameType (pframe);uint frsubtype =GetFrameSubType (pframe); - frsubtype = frsubtype>>4 ; + frsubtype = frsubtype >>4 ;memset ((void *)mic_iv,0 ,16 );memset ((void *)mic_header1,0 ,16 );
@@ -895,9 +893,9 @@ static signed int aes_cipher(u8 *key, uint hdrlen,else a4_exists =1 ; -if (((frtype|frsubtype) ==WIFI_DATA_CFACK ) || - ((frtype|frsubtype) ==WIFI_DATA_CFPOLL ) || - ((frtype|frsubtype) ==WIFI_DATA_CFACKPOLL )) { +if (((frtype | frsubtype) ==WIFI_DATA_CFACK ) || + ((frtype | frsubtype) ==WIFI_DATA_CFPOLL ) || + ((frtype | frsubtype) ==WIFI_DATA_CFACKPOLL )) { qc_exists =1 ;if (hdrlen !=WLAN_HDR_A3_QOS_LEN ) hdrlen +=2 ;
@@ -916,11 +914,11 @@ static signed int aes_cipher(u8 *key, uint hdrlen, } pn_vector[0 ] = pframe[hdrlen]; - pn_vector[1 ] = pframe[hdrlen+1 ]; - pn_vector[2 ] = pframe[hdrlen+4 ]; - pn_vector[3 ] = pframe[hdrlen+5 ]; - pn_vector[4 ] = pframe[hdrlen+6 ]; - pn_vector[5 ] = pframe[hdrlen+7 ]; + pn_vector[1 ] = pframe[hdrlen +1 ]; + pn_vector[2 ] = pframe[hdrlen +4 ]; + pn_vector[3 ] = pframe[hdrlen +5 ]; + pn_vector[4 ] = pframe[hdrlen +6 ]; + pn_vector[5 ] = pframe[hdrlen +7 ]; construct_mic_iv(mic_iv, qc_exists,
@@ -976,12 +974,12 @@ static signed int aes_cipher(u8 *key, uint hdrlen,/* Insert MIC into payload */ for (j =0 ; j <8 ; j++) - pframe[payload_index+j] = mic[j]; + pframe[payload_index + j] = mic[j]; payload_index = hdrlen +8 ;for (i =0 ; i < num_blocks; i++) {construct_ctr_preload (ctr_preload, a4_exists, qc_exists, pframe,/* message, */ - pn_vector, i+1 , frtype); + pn_vector, i +1 , frtype);/* add for CONFIG_IEEE80211W, none 11w also can use */ aes128k128d (key, ctr_preload, aes_out);bitwise_xor (aes_out, &pframe[payload_index], chain_buffer);
@@ -993,13 +991,13 @@ static signed int aes_cipher(u8 *key, uint hdrlen,/* If there is a short final block, then pad it,*/ /* encrypt it and copy the unpadded part back */ construct_ctr_preload (ctr_preload, a4_exists, qc_exists, pframe,/* message, */ - pn_vector, num_blocks+1 , frtype); + pn_vector, num_blocks +1 , frtype);/* add for CONFIG_IEEE80211W, none 11w also can use */ for (j =0 ; j <16 ; j++) padded_buffer[j] =0x00 ;for (j =0 ; j < payload_remainder; j++) - padded_buffer[j] = pframe[payload_index+j]; + padded_buffer[j] = pframe[payload_index + j];aes128k128d (key, ctr_preload, aes_out);bitwise_xor (aes_out, padded_buffer, chain_buffer);
@@ -1015,7 +1013,7 @@ static signed int aes_cipher(u8 *key, uint hdrlen,for (j =0 ; j <16 ; j++) padded_buffer[j] =0x00 ;for (j =0 ; j <8 ; j++) - padded_buffer[j] = pframe[j+hdrlen+8 +plen]; + padded_buffer[j] = pframe[j + hdrlen +8 + plen];aes128k128d (key, ctr_preload, aes_out);bitwise_xor (aes_out, padded_buffer, chain_buffer);
@@ -1055,12 +1053,12 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) prwskey = pattrib->dot118021x_UncstKey.skey;for (curfragnum =0 ; curfragnum < pattrib->nr_frags; curfragnum++) { -if ((curfragnum+1 ) == pattrib->nr_frags) {/* 4 the last fragment */ - length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; +if ((curfragnum +1 ) == pattrib->nr_frags) {/* 4 the last fragment */ + length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;aes_cipher (prwskey, pattrib->hdrlen, pframe, length); }else { - length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;aes_cipher (prwskey, pattrib->hdrlen, pframe, length); pframe += pxmitpriv->frag_len;
@@ -1072,7 +1070,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) }static signed int aes_decipher (u8 *key,uint hdrlen, -u8 *pframe,uint plen) +u8 *pframe,uint plen) {static u8 message[MAX_MSG_SIZE ]; uint qc_exists, a4_exists, i, j, payload_remainder,
@@ -1093,7 +1091,7 @@ static signed int aes_decipher(u8 *key, uint hdrlen,uint frtype =GetFrameType (pframe);uint frsubtype =GetFrameSubType (pframe); - frsubtype = frsubtype>>4 ; + frsubtype = frsubtype >>4 ;memset ((void *)mic_iv,0 ,16 );memset ((void *)mic_header1,0 ,16 );
@@ -1105,9 +1103,9 @@ static signed int aes_decipher(u8 *key, uint hdrlen,/* start to decrypt the payload */ - num_blocks = (plen-8 ) /16 ;/* plen including LLC, payload_length and mic) */ + num_blocks = (plen -8 ) /16 ;/* plen including LLC, payload_length and mic) */ - payload_remainder = (plen-8 ) %16 ; + payload_remainder = (plen -8 ) %16 ; pn_vector[0 ] = pframe[hdrlen]; pn_vector[1 ] = pframe[hdrlen +1 ];
@@ -1121,9 +1119,9 @@ static signed int aes_decipher(u8 *key, uint hdrlen,else a4_exists =1 ; -if (((frtype|frsubtype) ==WIFI_DATA_CFACK ) || - ((frtype|frsubtype) ==WIFI_DATA_CFPOLL ) || - ((frtype|frsubtype) ==WIFI_DATA_CFACKPOLL )) { +if (((frtype | frsubtype) ==WIFI_DATA_CFACK ) || + ((frtype | frsubtype) ==WIFI_DATA_CFPOLL ) || + ((frtype | frsubtype) ==WIFI_DATA_CFACKPOLL )) { qc_exists =1 ;if (hdrlen !=WLAN_HDR_A3_QOS_LEN ) hdrlen +=2 ;
@@ -1162,13 +1160,13 @@ static signed int aes_decipher(u8 *key, uint hdrlen,/* If there is a short final block, then pad it,*/ /* encrypt it and copy the unpadded part back */ construct_ctr_preload (ctr_preload, a4_exists, qc_exists, pframe, pn_vector, - num_blocks+1 , frtype); + num_blocks +1 , frtype);/* add for CONFIG_IEEE80211W, none 11w also can use */ for (j =0 ; j <16 ; j++) padded_buffer[j] =0x00 ;for (j =0 ; j < payload_remainder; j++) - padded_buffer[j] = pframe[payload_index+j]; + padded_buffer[j] = pframe[payload_index + j];aes128k128d (key, ctr_preload, aes_out);bitwise_xor (aes_out, padded_buffer, chain_buffer);
@@ -1177,25 +1175,25 @@ static signed int aes_decipher(u8 *key, uint hdrlen, }/* start to calculate the mic */ -if ((hdrlen + plen+8 ) <=MAX_MSG_SIZE ) -memcpy ((void *)message, pframe, (hdrlen + plen+8 ));/* 8 is for ext iv len */ +if ((hdrlen + plen +8 ) <=MAX_MSG_SIZE ) +memcpy ((void *)message, pframe, (hdrlen + plen +8 ));/* 8 is for ext iv len */ pn_vector[0 ] = pframe[hdrlen]; - pn_vector[1 ] = pframe[hdrlen+1 ]; - pn_vector[2 ] = pframe[hdrlen+4 ]; - pn_vector[3 ] = pframe[hdrlen+5 ]; - pn_vector[4 ] = pframe[hdrlen+6 ]; - pn_vector[5 ] = pframe[hdrlen+7 ]; + pn_vector[1 ] = pframe[hdrlen +1 ]; + pn_vector[2 ] = pframe[hdrlen +4 ]; + pn_vector[3 ] = pframe[hdrlen +5 ]; + pn_vector[4 ] = pframe[hdrlen +6 ]; + pn_vector[5 ] = pframe[hdrlen +7 ]; -construct_mic_iv (mic_iv, qc_exists, a4_exists, message, plen-8 , pn_vector, frtype); +construct_mic_iv (mic_iv, qc_exists, a4_exists, message, plen -8 , pn_vector, frtype);/* add for CONFIG_IEEE80211W, none 11w also can use */ construct_mic_header1 (mic_header1, hdrlen, message, frtype);/* add for CONFIG_IEEE80211W, none 11w also can use */ construct_mic_header2 (mic_header2, message, a4_exists, qc_exists); - payload_remainder = (plen-8 ) %16 ; - num_blocks = (plen-8 ) /16 ; + payload_remainder = (plen -8 ) %16 ; + num_blocks = (plen -8 ) /16 ;/* Find start of payload */ payload_index = (hdrlen +8 );
@@ -1230,11 +1228,11 @@ static signed int aes_decipher(u8 *key, uint hdrlen,/* Insert MIC into payload */ for (j =0 ; j <8 ; j++) - message[payload_index+j] = mic[j]; + message[payload_index + j] = mic[j]; payload_index = hdrlen +8 ;for (i =0 ; i < num_blocks; i++) { -construct_ctr_preload (ctr_preload, a4_exists, qc_exists, message, pn_vector, i+1 , +construct_ctr_preload (ctr_preload, a4_exists, qc_exists, message, pn_vector, i +1 , frtype);/* add for CONFIG_IEEE80211W, none 11w also can use */ aes128k128d (key, ctr_preload, aes_out);
@@ -1247,13 +1245,13 @@ static signed int aes_decipher(u8 *key, uint hdrlen,/* If there is a short final block, then pad it,*/ /* encrypt it and copy the unpadded part back */ construct_ctr_preload (ctr_preload, a4_exists, qc_exists, message, pn_vector, - num_blocks+1 , frtype); + num_blocks +1 , frtype);/* add for CONFIG_IEEE80211W, none 11w also can use */ for (j =0 ; j <16 ; j++) padded_buffer[j] =0x00 ;for (j =0 ; j < payload_remainder; j++) - padded_buffer[j] = message[payload_index+j]; + padded_buffer[j] = message[payload_index + j];aes128k128d (key, ctr_preload, aes_out);bitwise_xor (aes_out, padded_buffer, chain_buffer);
@@ -1268,7 +1266,7 @@ static signed int aes_decipher(u8 *key, uint hdrlen,for (j =0 ; j <16 ; j++) padded_buffer[j] =0x00 ;for (j =0 ; j <8 ; j++) - padded_buffer[j] = message[j+hdrlen+8 +plen-8 ]; + padded_buffer[j] = message[j + hdrlen +8 + plen -8 ];aes128k128d (key, ctr_preload, aes_out);bitwise_xor (aes_out, padded_buffer, chain_buffer);
@@ -1355,7 +1353,7 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) prwskey = &stainfo->dot118021x_UncstKey.skey[0 ]; } - length = ((union recv_frame *)precvframe)->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; + length = ((union recv_frame *)precvframe)->u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len; res =aes_decipher (prwskey, prxattrib->hdrlen, pframe, length);
@@ -1380,7 +1378,7 @@ u32 rtw_BIP_verify(struct adapter *padapter, u8 *precvframe)__le16 le_tmp;__le64 le_tmp64; - ori_len = pattrib->pkt_len-WLAN_HDR_A3_LEN +BIP_AAD_SIZE ; + ori_len = pattrib->pkt_len -WLAN_HDR_A3_LEN +BIP_AAD_SIZE ;BIP_AAD =rtw_zmalloc (ori_len);if (!BIP_AAD )
@@ -1391,28 +1389,28 @@ u32 rtw_BIP_verify(struct adapter *padapter, u8 *precvframe)/* mapping to wlan header */ pwlanhdr = (struct ieee80211_hdr *)pframe;/* save the frame body + MME */ -memcpy (BIP_AAD +BIP_AAD_SIZE , pframe+WLAN_HDR_A3_LEN , pattrib->pkt_len-WLAN_HDR_A3_LEN ); +memcpy (BIP_AAD +BIP_AAD_SIZE , pframe +WLAN_HDR_A3_LEN , pattrib->pkt_len -WLAN_HDR_A3_LEN );/* find MME IE pointer */ - p =rtw_get_ie (BIP_AAD +BIP_AAD_SIZE ,WLAN_EID_MMIE , &len, pattrib->pkt_len-WLAN_HDR_A3_LEN ); + p =rtw_get_ie (BIP_AAD +BIP_AAD_SIZE ,WLAN_EID_MMIE , &len, pattrib->pkt_len -WLAN_HDR_A3_LEN );/* Baron */ if (p) {u16 keyid =0 ;u64 temp_ipn =0 ;/* save packet number */ -memcpy (&le_tmp64, p+4 ,6 ); +memcpy (&le_tmp64, p +4 ,6 ); temp_ipn =le64_to_cpu (le_tmp64);/* BIP packet number should bigger than previous BIP packet */ if (temp_ipn <= pmlmeext->mgnt_80211w_IPN_rx) goto BIP_exit;/* copy key index */ -memcpy (&le_tmp, p+2 ,2 ); +memcpy (&le_tmp, p +2 ,2 ); keyid =le16_to_cpu (le_tmp);if (keyid != padapter->securitypriv.dot11wBIPKeyid) goto BIP_exit;/* clear the MIC field of MME to zero */ -memset (p+2 +len-8 ,0 ,8 ); +memset (p +2 + len -8 ,0 ,8 );/* conscruct AAD, copy frame control field */ memcpy (BIP_AAD , &pwlanhdr->frame_control,2 );
@@ -1420,14 +1418,14 @@ u32 rtw_BIP_verify(struct adapter *padapter, u8 *precvframe)ClearPwrMgt (BIP_AAD );ClearMData (BIP_AAD );/* conscruct AAD, copy address 1 to address 3 */ -memcpy (BIP_AAD +2 , pwlanhdr->addr1,18 ); +memcpy (BIP_AAD +2 , pwlanhdr->addr1,18 );if (omac1_aes_128 (padapter->securitypriv.dot11wBIPKey[padapter->securitypriv.dot11wBIPKeyid].skey ,BIP_AAD , ori_len, mic)) goto BIP_exit;/* MIC field should be last 8 bytes of packet (packet without FCS) */ -if (!memcmp (mic, pframe+pattrib->pkt_len-8 ,8 )) { +if (!memcmp (mic, pframe + pattrib->pkt_len -8 ,8 )) { pmlmeext->mgnt_80211w_IPN_rx = temp_ipn; res = _SUCCESS; }else {
@@ -1573,7 +1571,7 @@ u8 rtw_handle_tkip_countermeasure(struct adapter *adapter, const char *caller)if (securitypriv->btkip_countermeasure) {unsigned long passing_ms =jiffies_to_msecs (jiffies - securitypriv->btkip_countermeasure_time); -if (passing_ms >60 *1000 ) { +if (passing_ms >60 *1000 ) { netdev_dbg(adapter->pnetdev, "%s(%s) countermeasure time:%lus > 60s\n", caller, ADPT_ARG(adapter),
Signature · 1 line
2.45.3
PATCH v2 3/3 staging: rtl8723bs: remove extra blank lines
In reply to Ian ToRepeated blank lines were present and removed. Reported by checkpatch.
--- drivers/staging/rtl8723bs/core/rtw_security.c | 11 ----------- 1 file changed, 11 deletions(-)
drivers/staging/rtl8723bs/core/rtw_security.c +0 -11
@@ -123,7 +123,6 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe)/* calculate icv and compare the icv */ *((u32 *)crc) = ~crc32_le (~0 , payload, length -4 ); - } }
@@ -219,10 +218,8 @@ void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst)secmicclear (pmicdata); } -void rtw_seccalctkipmic (u8 *key,u8 *header,u8 *data,u32 data_len,u8 *mic_code,u8 pri) { -struct mic_data micdata;u8 priority[4 ] = {0x0 ,0x0 ,0x0 ,0x0 };
@@ -245,7 +242,6 @@ void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_cod }rtw_secmicappend (&micdata, &priority[0 ],4 ); -rtw_secmicappend (&micdata, data, data_len);rtw_secgetmic (&micdata, mic_code);
@@ -305,7 +301,6 @@ static const unsigned short Sbox1[2][256] = { /* Sbox for hash (can be in R 0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A, }, - {/* second half of table is unsigned char-reversed version of first! */ 0xA5C6 ,0x84F8 ,0x99EE ,0x8DF6 ,0x0DFF ,0xBDD6 ,0xB1DE ,0x5491 , 0x5060, 0x0302, 0xA9CE, 0x7D56, 0x19E7, 0x62B5, 0xE64D, 0x9AEC,
@@ -480,7 +475,6 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)/* 4 start to encrypt each fragment */ if (pattrib->encrypt == _TKIP_) { - {if (is_multicast_ether_addr (pattrib->ra)) prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;
@@ -525,7 +519,6 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)return res; } -/* The hlen isn't include the IV */ u32 rtw_tkip_decrypt (struct adapter *padapter,u8 *precvframe) {/* exclude ICV */
@@ -627,11 +620,8 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)return res; } -/* 3 =====AES related ===== */ - -#define MAX_MSG_SIZE 2048/*****************************/
@@ -664,7 +654,6 @@ static void construct_ctr_preload(u8 *ctr_preload,static void aes128k128d (u8 *key,u8 *data,u8 *ciphertext); -/****************************************/ /* aes128k128d() */ /* Performs a 128 bit AES encrypt with */
Signature · 1 line
2.45.3
Greg KH
maintainerRe: [PATCH v2 1/3] staging: rtl8723bs: format comments
In reply to Ian ToQuoted 38 lines · Ian To
Some comments were not formatted correctly. Reported by checkpatch.
Signed-off-by Ian To <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_security.c | 92 +++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-)drivers/staging/rtl8723bs/core/rtw_security.c +3
-12@@ -30,10 +30,10 @@ const char *security_type_str(u8 value)/* WEP related ===== */ /* -Need to consider the fragment situation -*/ +* Need to consider the fragment situation +*/ void rtw_wep_encrypt (struct adapter *padapter,u8 *pxmitframe) -{/* exclude ICV */ +{union {__le32 f0;unsigned char f1[4 ];@@ -342,23 +342,23 @@ static const unsigned short Sbox1[2][256] = { /* Sbox for hash (can be in R } }; -/* -********************************************************************** -* Routine: Phase 1 -- generate P1K, given TA, TK, IV32 -* -* Inputs: -* tk[] = temporal key [128 bits] -* ta[] = transmitter's MAC address [ 48 bits] -* iv32 = upper 32 bits of IV [ 32 bits] -* Output:
drivers/staging/rtl8723bs/core/rtw_security.c static const unsigned short Sbox1[2][256] = { /* Sbox for hash (can be in R · line 346
Quoted 10 lines
drivers/staging/rtl8723bs/core/rtw_security.c +2
-8-* p1k[] = Phase 1 key [ 80 bits] -* -* Note: -* This function only needs to be called every 2**16 packets, -* although in theory it could be called every packet. -* -********************************************************************** -*/ +/* +**********************************************************************
Why the long line of **** ?
That should not be needed.
drivers/staging/rtl8723bs/core/rtw_security.c static const unsigned short Sbox1[2][256] = { /* Sbox for hash (can be in R · line 347
Quoted 2 lines
drivers/staging/rtl8723bs/core/rtw_security.c +1
-1-/** +/*
Why are you removing kerneldoc comment style?
drivers/staging/rtl8723bs/core/rtw_security.c static int omac1_aes_128_vector(u8 *key, size_t num_elem, · line 1532
Quoted 9 lines
drivers/staging/rtl8723bs/core/rtw_security.c +1
-1* omac1_aes_128_vector - One-Key CBC MAC (OMAC1) hash with AES-128 * @key: 128-bit key for the hash operation * @num_elem: Number of elements in the data vector @@ -1530,7 +1529,7 @@ static int omac1_aes_128_vector(u8 *key, size_t num_elem,return 0 ; } -/** +/*
Same here?
thanks,
greg k-h
Greg KH
maintainerRe: [PATCH v2 2/3] stagin: rtl8723bs: fix spacing
In reply to Ian ToQuoted 6 lines · Ian To
Fixed spacing issues. Reported by checkpatch.
Signed-off-by Ian To <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_security.c | 176 +++++++++--------- 1 file changed, 87 insertions(+), 89 deletions(-)
Subject line needs a spelling check :(
thanks,
greg k-h
Greg KH
maintainerRe: [PATCH v2 3/3] staging: rtl8723bs: remove extra blank lines
In reply to Ian ToQuoted 12 lines · Ian To
Repeated blank lines were present and removed. Reported by checkpatch.
Signed-off-by Ian To <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_security.c | 11 ----------- 1 file changed, 11 deletions(-)drivers/staging/rtl8723bs/core/rtw_security.c +0
-0
drivers/staging/rtl8723bs/core/rtw_security.c void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) · line 126
Quoted 5 lines
drivers/staging/rtl8723bs/core/rtw_security.c +0
-1@@ -123,7 +123,6 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe)/* calculate icv and compare the icv */ *((u32 *)crc) = ~crc32_le (~0 , payload, length -4 ); - }
This was not a "repeated blank line".
drivers/staging/rtl8723bs/core/rtw_security.c void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst) · line 225
Quoted 13 lines
drivers/staging/rtl8723bs/core/rtw_security.c +0
-2}@@ -219,10 +218,8 @@ void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst)secmicclear (pmicdata); } -void rtw_seccalctkipmic (u8 *key,u8 *header,u8 *data,u32 data_len,u8 *mic_code,u8 pri) { -struct mic_data micdata;u8 priority[4 ] = {0x0 ,0x0 ,0x0 ,0x0 };
Neither was that :(
I've stopped reviewing here.
thanks,
greg k-h