rtl8188eu: Change C90 comments to /* */ form

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
This commit is contained in:
Larry Finger 2015-02-19 15:34:32 -06:00
parent 9b5b5c4e12
commit 54abf571c4
21 changed files with 4526 additions and 4764 deletions

View file

@ -26,7 +26,7 @@
#include <osdep_intf.h>
//=====WEP related=====
/* WEP related===== */
#define CRC32_POLY 0x04c11db7
@ -161,7 +161,7 @@ static __le32 getcrc32(u8 *buf, sint len)
Need to consider the fragment situation
*/
void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
{ // exclude ICV
{ /* exclude ICV */
unsigned char crc[4];
struct arc4context mycontext;
@ -169,7 +169,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
sint curfragnum,length;
u32 keylength;
u8 *pframe, *payload,*iv; //,*wepkey
u8 *pframe, *payload,*iv; /* wepkey */
u8 wepkey[16];
u8 hw_hdr_offset=0;
struct pkt_attrib *pattrib = &((struct xmit_frame*)pxmitframe)->attrib;
@ -195,7 +195,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
pframe = ((struct xmit_frame*)pxmitframe)->buf_addr + hw_hdr_offset;
//start to encrypt each fragment
/* start to encrypt each fragment */
if((pattrib->encrypt==_WEP40_)||(pattrib->encrypt==_WEP104_))
{
keylength=psecuritypriv->dot11DefKeylen[psecuritypriv->dot11PrivacyKeyIndex];
@ -208,7 +208,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
payload=pframe+pattrib->iv_len+pattrib->hdrlen;
if((curfragnum+1)==pattrib->nr_frags)
{ //the last fragment
{ /* the last fragment */
length=pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len- pattrib->icv_len;
@ -242,7 +242,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe)
{
// exclude ICV
/* exclude ICV */
u8 crc[4];
struct arc4context mycontext;
sint length;
@ -256,25 +256,25 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe)
pframe=(unsigned char *)((union recv_frame*)precvframe)->u.hdr.rx_data;
//start to decrypt recvframe
/* start to decrypt recvframe */
if((prxattrib->encrypt==_WEP40_)||(prxattrib->encrypt==_WEP104_))
{
iv=pframe+prxattrib->hdrlen;
//keyindex=(iv[3]&0x3);
/* 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[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;
payload=pframe+prxattrib->iv_len+prxattrib->hdrlen;
//decrypt payload include icv
/* decrypt payload include icv */
arcfour_init(&mycontext, wepkey,3+keylength);
arcfour_encrypt(&mycontext, payload, payload, length);
//calculate icv and compare the icv
/* calculate icv and compare the icv */
*((__le32 *)crc)=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])
@ -291,10 +291,10 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe)
}
//3 =====TKIP related=====
/* 3 =====TKIP related===== */
static u32 secmicgetuint32( u8 * p )
// Convert from Byte[] to Us3232 in a portable way
/* Convert from Byte[] to Us3232 in a portable way */
{
s32 i;
u32 res = 0;
@ -308,7 +308,7 @@ static u32 secmicgetuint32( u8 * p )
}
static void secmicputuint32( u8 * p, u32 val )
// Convert from Us3232 to Byte[] in a portable way
/* Convert from Us3232 to Byte[] in a portable way */
{
long i;
;
@ -322,7 +322,7 @@ static void secmicputuint32( u8 * p, u32 val )
static void secmicclear(struct mic_data *pmicdata)
{
// Reset the state to the empty message.
/* Reset the state to the empty message. */
;
pmicdata->L = pmicdata->K0;
pmicdata->R = pmicdata->K1;
@ -333,11 +333,11 @@ static void secmicclear(struct mic_data *pmicdata)
void rtw_secmicsetkey(struct mic_data *pmicdata, u8 * key )
{
// Set the key
/* Set the key */
;
pmicdata->K0 = secmicgetuint32( key );
pmicdata->K1 = secmicgetuint32( key + 4 );
// and reset the message
/* and reset the message */
secmicclear(pmicdata);
;
}
@ -345,10 +345,10 @@ 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
/* Append the byte to our word-sized buffer */
pmicdata->M |= ((unsigned long)b) << (8*pmicdata->nBytesInM);
pmicdata->nBytesInM++;
// Process the word if it is full.
/* Process the word if it is full. */
if( pmicdata->nBytesInM >= 4 )
{
pmicdata->L ^= pmicdata->M;
@ -360,7 +360,7 @@ void rtw_secmicappendbyte(struct mic_data *pmicdata, u8 b )
pmicdata->L += pmicdata->R;
pmicdata->R ^= ROR32( pmicdata->L, 2 );
pmicdata->L += pmicdata->R;
// Clear the buffer
/* Clear the buffer */
pmicdata->M = 0;
pmicdata->nBytesInM = 0;
}
@ -370,7 +370,7 @@ void rtw_secmicappendbyte(struct mic_data *pmicdata, u8 b )
void rtw_secmicappend(struct mic_data *pmicdata, u8 * src, u32 nbytes )
{
;
// This is simple
/* This is simple */
while( nbytes > 0 )
{
rtw_secmicappendbyte(pmicdata, *src++ );
@ -382,21 +382,21 @@ void rtw_secmicappend(struct mic_data *pmicdata, u8 * src, u32 nbytes )
void rtw_secgetmic(struct mic_data *pmicdata, u8 * dst )
{
;
// Append the minimum padding
/* Append the minimum padding */
rtw_secmicappendbyte(pmicdata, 0x5a );
rtw_secmicappendbyte(pmicdata, 0 );
rtw_secmicappendbyte(pmicdata, 0 );
rtw_secmicappendbyte(pmicdata, 0 );
rtw_secmicappendbyte(pmicdata, 0 );
// and then zeroes until the length is a multiple of 4
/* and then zeroes until the length is a multiple of 4 */
while( pmicdata->nBytesInM != 0 )
{
rtw_secmicappendbyte(pmicdata, 0 );
}
// The appendByte function has already computed the result.
/* The appendByte function has already computed the result. */
secmicputuint32( dst, pmicdata->L );
secmicputuint32( dst+4, pmicdata->R );
// Reset to the empty message.
/* Reset to the empty message. */
secmicclear(pmicdata);
;
}
@ -412,16 +412,16 @@ void rtw_seccalctkipmic(u8 * key,u8 *header,u8 *data,u32 data_len,u8 *mic_code,
priority[0]=pri;
/* Michael MIC pseudo header: DA, SA, 3 x 0, Priority */
if(header[1]&1){ //ToDS==1
rtw_secmicappend(&micdata, &header[16], 6); //DA
if(header[1]&2) //From Ds==1
if(header[1]&1){ /* ToDS==1 */
rtw_secmicappend(&micdata, &header[16], 6); /* DA */
if(header[1]&2) /* From Ds==1 */
rtw_secmicappend(&micdata, &header[24], 6);
else
rtw_secmicappend(&micdata, &header[10], 6);
}
else{ //ToDS==0
rtw_secmicappend(&micdata, &header[4], 6); //DA
if(header[1]&2) //From Ds==1
else{ /* ToDS==0 */
rtw_secmicappend(&micdata, &header[4], 6); /* DA */
if(header[1]&2) /* From Ds==1 */
rtw_secmicappend(&micdata, &header[16], 6);
else
rtw_secmicappend(&micdata, &header[10], 6);
@ -647,9 +647,9 @@ static void phase2(u8 *rc4key,const u8 *tk,const u16 *p1k,u16 iv16)
}
//The hlen isn't include the IV
/* The hlen isn't include the IV */
u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
{ // exclude ICV
{ /* exclude ICV */
u16 pnl;
u32 pnh;
u8 rc4key[16];
@ -684,7 +684,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
#endif
pframe = ((struct xmit_frame*)pxmitframe)->buf_addr + hw_hdr_offset;
//4 start to encrypt each fragment
/* 4 start to encrypt each fragment */
if(pattrib->encrypt==_TKIP_){
if(pattrib->psta)
@ -731,7 +731,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
phase2(&rc4key[0],prwskey,(u16 *)&ttkey[0],pnl);
if((curfragnum+1)==pattrib->nr_frags){ //4 the last fragment
if((curfragnum+1)==pattrib->nr_frags){ /* 4 the last fragment */
length=pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len- pattrib->icv_len;
RT_TRACE(_module_rtl871x_security_c_,_drv_info_,("pattrib->iv_len =%x, pattrib->icv_len =%x\n", pattrib->iv_len,pattrib->icv_len));
*((__le32 *)crc)=getcrc32(payload,length);/* modified by Amy*/
@ -769,9 +769,9 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
}
//The hlen isn't include the IV
/* The hlen isn't include the IV */
u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
{ // exclude ICV
{ /* exclude ICV */
u16 pnl;
u32 pnh;
u8 rc4key[16];
@ -786,14 +786,14 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
struct sta_info *stainfo;
struct rx_pkt_attrib *prxattrib = &((union recv_frame *)precvframe)->u.hdr.attrib;
struct security_priv *psecuritypriv=&padapter->securitypriv;
// struct recv_priv *precvpriv=&padapter->recvpriv;
/* struct recv_priv *precvpriv=&padapter->recvpriv; */
u32 res=_SUCCESS;
;
pframe=(unsigned char *)((union recv_frame*)precvframe)->u.hdr.rx_data;
//4 start to decrypt recvframe
/* 4 start to decrypt recvframe */
if(prxattrib->encrypt==_TKIP_){
stainfo=rtw_get_stainfo(&padapter->stapriv ,&prxattrib->ta[0] );
@ -837,8 +837,8 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
no_gkey_bc_cnt = 0;
no_gkey_mc_cnt = 0;
//DBG_871X("rx bc/mc packets, to perform sw rtw_tkip_decrypt\n");
//prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;
/* DBG_871X("rx bc/mc packets, to perform sw rtw_tkip_decrypt\n"); */
/* prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; */
prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey;
prwskeylen=16;
}
@ -861,7 +861,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
phase1((u16 *)&ttkey[0],prwskey,&prxattrib->ta[0],pnh);
phase2(&rc4key[0],prwskey,(unsigned short *)&ttkey[0],pnl);
//4 decrypt payload include icv
/* 4 decrypt payload include icv */
arcfour_init(&mycontext, rc4key,16);
arcfour_encrypt(&mycontext, payload, payload, length);
@ -890,7 +890,7 @@ exit:
}
//3 =====AES related=====
/* 3 =====AES related===== */
@ -947,12 +947,12 @@ static void construct_mic_iv(
u8 *mpdu,
uint payload_length,
u8 * pn_vector,
uint frtype);// add for CONFIG_IEEE80211W, none 11w also can use
uint frtype);/* add for CONFIG_IEEE80211W, none 11w also can use */
static void construct_mic_header1(
u8 *mic_header1,
sint header_length,
u8 *mpdu,
uint frtype);// add for CONFIG_IEEE80211W, none 11w also can use
uint frtype);/* add for CONFIG_IEEE80211W, none 11w also can use */
static void construct_mic_header2(
u8 *mic_header2,
u8 *mpdu,
@ -965,7 +965,7 @@ static void construct_ctr_preload(
u8 *mpdu,
u8 *pn_vector,
sint c,
uint frtype);// add for CONFIG_IEEE80211W, none 11w also can use
uint frtype);/* add for CONFIG_IEEE80211W, none 11w also can use */
static void xor_128(u8 *a, u8 *b, u8 *out);
static void xor_32(u8 *a, u8 *b, u8 *out);
static u8 sbox(u8 a);
@ -1193,7 +1193,7 @@ static void construct_mic_iv(
u8 *mpdu,
uint payload_length,
u8 *pn_vector,
uint frtype// add for CONFIG_IEEE80211W, none 11w also can use
uint frtype/* add for CONFIG_IEEE80211W, none 11w also can use */
)
{
sint i;
@ -1203,10 +1203,10 @@ static void construct_mic_iv(
if (qc_exists && !a4_exists) mic_iv[1] = mpdu[24] & 0x0f; /* mute bits 7-4 */
if (!qc_exists) mic_iv[1] = 0x00;
#ifdef CONFIG_IEEE80211W
//802.11w management frame should set management bit(4)
/* 802.11w management frame should set management bit(4) */
if(frtype == WIFI_MGT_TYPE)
mic_iv[1] |= BIT(4);
#endif //CONFIG_IEEE80211W
#endif /* CONFIG_IEEE80211W */
for (i = 2; i < 8; i++)
mic_iv[i] = mpdu[i + 8]; /* mic_iv[2:7] = A2[0:5] = mpdu[10:15] */
#ifdef CONSISTENT_PN_ORDER
@ -1232,18 +1232,18 @@ static void construct_mic_header1(
u8 *mic_header1,
sint header_length,
u8 *mpdu,
uint frtype// add for CONFIG_IEEE80211W, none 11w also can use
uint frtype/* add for CONFIG_IEEE80211W, none 11w also can use */
)
{
;
mic_header1[0] = (u8)((header_length - 2) / 256);
mic_header1[1] = (u8)((header_length - 2) % 256);
#ifdef CONFIG_IEEE80211W
//802.11w management frame don't AND subtype bits 4,5,6 of frame control field
/* 802.11w management frame don't AND subtype bits 4,5,6 of frame control field */
if(frtype == WIFI_MGT_TYPE)
mic_header1[2] = mpdu[0]; /* Mute CF poll & CF ack bits */
else
#endif //CONFIG_IEEE80211W
#endif /* CONFIG_IEEE80211W */
mic_header1[2] = mpdu[0] & 0xcf; /* Mute CF poll & CF ack bits */
mic_header1[3] = mpdu[1] & 0xc7; /* Mute retry, more data and pwr mgt bits */
@ -1286,7 +1286,6 @@ static void construct_mic_header2(
mic_header2[4] = mpdu[20];
mic_header2[5] = mpdu[21];
//mic_header2[6] = mpdu[22] & 0xf0; /* SC */
mic_header2[6] = 0x00;
mic_header2[7] = 0x00; /* mpdu[23]; */
@ -1329,7 +1328,7 @@ static void construct_ctr_preload(
u8 *mpdu,
u8 *pn_vector,
sint c,
uint frtype // add for CONFIG_IEEE80211W, none 11w also can use
uint frtype /* add for CONFIG_IEEE80211W, none 11w also can use */
)
{
sint i = 0;
@ -1343,10 +1342,10 @@ static void construct_ctr_preload(
if (qc_exists && !a4_exists)
ctr_preload[1] = mpdu[24] & 0x0f;
#ifdef CONFIG_IEEE80211W
//802.11w management frame should set management bit(4)
/* 802.11w management frame should set management bit(4) */
if(frtype == WIFI_MGT_TYPE)
ctr_preload[1] |= BIT(4);
#endif //CONFIG_IEEE80211W
#endif /* CONFIG_IEEE80211W */
for (i = 2; i < 8; i++)
ctr_preload[i] = mpdu[i + 8]; /* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */
#ifdef CONSISTENT_PN_ORDER
@ -1381,7 +1380,6 @@ static void bitwise_xor(u8 *ina, u8 *inb, u8 *out)
static sint aes_cipher(u8 *key, uint hdrlen,
u8 *pframe, uint plen)
{
// /*static*/ unsigned char message[MAX_MSG_SIZE];
uint qc_exists, a4_exists, i, j, payload_remainder,
num_blocks, payload_index;
@ -1396,7 +1394,6 @@ static sint aes_cipher(u8 *key, uint hdrlen,
u8 aes_out[16];
u8 padded_buffer[16];
u8 mic[8];
// uint offset = 0;
uint frtype = GetFrameType(pframe);
uint frsubtype = GetFrameSubType(pframe);
@ -1428,7 +1425,7 @@ static sint aes_cipher(u8 *key, uint hdrlen,
hdrlen += 2;
}
}
// add for CONFIG_IEEE80211W, none 11w also can use
/* add for CONFIG_IEEE80211W, none 11w also can use */
else if ((frtype == WIFI_DATA) &&
((frsubtype == 0x08) ||
(frsubtype == 0x09)||
@ -1455,21 +1452,21 @@ static sint aes_cipher(u8 *key, uint hdrlen,
mic_iv,
qc_exists,
a4_exists,
pframe, //message,
pframe, /* message, */
plen,
pn_vector,
frtype // add for CONFIG_IEEE80211W, none 11w also can use
frtype /* add for CONFIG_IEEE80211W, none 11w also can use */
);
construct_mic_header1(
mic_header1,
hdrlen,
pframe, //message
frtype // add for CONFIG_IEEE80211W, none 11w also can use
pframe, /* message */
frtype /* add for CONFIG_IEEE80211W, none 11w also can use */
);
construct_mic_header2(
mic_header2,
pframe, //message,
pframe, /* message, */
a4_exists,
qc_exists
);
@ -1490,7 +1487,7 @@ static sint aes_cipher(u8 *key, uint hdrlen,
for (i = 0; i < num_blocks; i++)
{
bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);//bitwise_xor(aes_out, &message[payload_index], chain_buffer);
bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);/* bitwise_xor(aes_out, &message[payload_index], chain_buffer); */
payload_index += 16;
aes128k128d(key, chain_buffer, aes_out);
@ -1502,7 +1499,7 @@ static sint aes_cipher(u8 *key, uint hdrlen,
for (j = 0; j < 16; j++) padded_buffer[j] = 0x00;
for (j = 0; j < payload_remainder; j++)
{
padded_buffer[j] = pframe[payload_index++];//padded_buffer[j] = message[payload_index++];
padded_buffer[j] = pframe[payload_index++];/* padded_buffer[j] = message[payload_index++]; */
}
bitwise_xor(aes_out, padded_buffer, chain_buffer);
aes128k128d(key, chain_buffer, aes_out);
@ -1513,7 +1510,7 @@ static sint aes_cipher(u8 *key, uint hdrlen,
/* Insert MIC into payload */
for (j = 0; j < 8; j++)
pframe[payload_index+j] = mic[j]; //message[payload_index+j] = mic[j];
pframe[payload_index+j] = mic[j]; /* message[payload_index+j] = mic[j]; */
payload_index = hdrlen + 8;
for (i=0; i< num_blocks; i++)
@ -1522,13 +1519,13 @@ static sint aes_cipher(u8 *key, uint hdrlen,
ctr_preload,
a4_exists,
qc_exists,
pframe, //message,
pframe, /* message, */
pn_vector,
i+1,
frtype); // add for CONFIG_IEEE80211W, none 11w also can use
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);//bitwise_xor(aes_out, &message[payload_index], chain_buffer);
for (j=0; j<16;j++) pframe[payload_index++] = chain_buffer[j];//for (j=0; j<16;j++) message[payload_index++] = chain_buffer[j];
bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);/* bitwise_xor(aes_out, &message[payload_index], chain_buffer); */
for (j=0; j<16;j++) pframe[payload_index++] = chain_buffer[j];/* for (j=0; j<16;j++) message[payload_index++] = chain_buffer[j]; */
}
if (payload_remainder > 0) /* If there is a short final block, then pad it,*/
@ -1537,19 +1534,19 @@ static sint aes_cipher(u8 *key, uint hdrlen,
ctr_preload,
a4_exists,
qc_exists,
pframe, //message,
pframe, /* message, */
pn_vector,
num_blocks+1,
frtype); // add for CONFIG_IEEE80211W, none 11w also can use
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] = message[payload_index+j];
padded_buffer[j] = pframe[payload_index+j];/* padded_buffer[j] = message[payload_index+j]; */
}
aes128k128d(key, ctr_preload, aes_out);
bitwise_xor(aes_out, padded_buffer, chain_buffer);
for (j=0; j<payload_remainder;j++) pframe[payload_index++] = chain_buffer[j];//for (j=0; j<payload_remainder;j++) message[payload_index++] = chain_buffer[j];
for (j=0; j<payload_remainder;j++) pframe[payload_index++] = chain_buffer[j];/* for (j=0; j<payload_remainder;j++) message[payload_index++] = chain_buffer[j]; */
}
/* Encrypt the MIC */
@ -1557,20 +1554,20 @@ static sint aes_cipher(u8 *key, uint hdrlen,
ctr_preload,
a4_exists,
qc_exists,
pframe, //message,
pframe, /* message, */
pn_vector,
0,
frtype); // add for CONFIG_IEEE80211W, none 11w also can use
frtype); /* add for CONFIG_IEEE80211W, none 11w also can use */
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] = message[j+hdrlen+8+plen];
padded_buffer[j] = pframe[j+hdrlen+8+plen];/* padded_buffer[j] = message[j+hdrlen+8+plen]; */
}
aes128k128d(key, ctr_preload, aes_out);
bitwise_xor(aes_out, padded_buffer, chain_buffer);
for (j=0; j<8;j++) pframe[payload_index++] = chain_buffer[j];//for (j=0; j<8;j++) message[payload_index++] = chain_buffer[j];
for (j=0; j<8;j++) pframe[payload_index++] = chain_buffer[j];/* for (j=0; j<8;j++) message[payload_index++] = chain_buffer[j]; */
;
return _SUCCESS;
}
@ -1580,23 +1577,23 @@ static sint aes_cipher(u8 *key, uint hdrlen,
u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe)
{ // exclude ICV
{ /* exclude ICV */
/*static*/
// unsigned char message[MAX_MSG_SIZE];
/* unsigned char message[MAX_MSG_SIZE]; */
/* Intermediate Buffers */
sint curfragnum,length;
u32 prwskeylen;
u8 *pframe,*prwskey; //, *payload,*iv
u8 *pframe,*prwskey; /* *payload,*iv */
u8 hw_hdr_offset = 0;
struct sta_info *stainfo;
struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib;
struct security_priv *psecuritypriv=&padapter->securitypriv;
struct xmit_priv *pxmitpriv=&padapter->xmitpriv;
// uint offset = 0;
/* uint offset = 0; */
u32 res=_SUCCESS;
;
@ -1616,7 +1613,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe)
pframe = ((struct xmit_frame*)pxmitframe)->buf_addr + hw_hdr_offset;
//4 start to encrypt each fragment
/* 4 start to encrypt each fragment */
if((pattrib->encrypt==_AES_)){
if(pattrib->psta)
@ -1648,7 +1645,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe)
prwskey=&stainfo->dot118021x_UncstKey.skey[0];
}
#ifdef CONFIG_TDLS //swencryption
#ifdef CONFIG_TDLS /* swencryption */
{
struct sta_info *ptdls_sta;
ptdls_sta=rtw_get_stainfo(&padapter->stapriv ,&pattrib->dst[0] );
@ -1658,13 +1655,13 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe)
prwskey=&ptdls_sta->tpk.tk[0];
}
}
#endif //CONFIG_TDLS
#endif /* CONFIG_TDLS */
prwskeylen=16;
for(curfragnum=0;curfragnum<pattrib->nr_frags;curfragnum++){
if((curfragnum+1)==pattrib->nr_frags){ //4 the last fragment
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);
@ -1715,7 +1712,7 @@ static sint aes_decipher(u8 *key, uint hdrlen,
u8 mic[8];
// uint offset = 0;
/* uint offset = 0; */
uint frtype = GetFrameType(pframe);
uint frsubtype = GetFrameSubType(pframe);
;
@ -1730,9 +1727,9 @@ static sint aes_decipher(u8 *key, uint hdrlen,
memset((void *)aes_out, 0, 16);
memset((void *)padded_buffer, 0, 16);
//start to decrypt the payload
/* 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;
@ -1758,7 +1755,7 @@ static sint aes_decipher(u8 *key, uint hdrlen,
hdrlen += 2;
}
}//only for data packet . add for CONFIG_IEEE80211W, none 11w also can use
}/* only for data packet . add for CONFIG_IEEE80211W, none 11w also can use */
else if ((frtype == WIFI_DATA) &&
((frsubtype == 0x08) ||
(frsubtype == 0x09)||
@ -1775,9 +1772,9 @@ static sint aes_decipher(u8 *key, uint hdrlen,
qc_exists = 0;
// now, decrypt pframe with hdrlen offset and plen long
/* now, decrypt pframe with hdrlen offset and plen long */
payload_index = hdrlen + 8; // 8 is for extiv
payload_index = hdrlen + 8; /* 8 is for extiv */
for (i=0; i< num_blocks; i++)
{
@ -1806,7 +1803,7 @@ static sint aes_decipher(u8 *key, uint hdrlen,
pframe,
pn_vector,
num_blocks+1,
frtype // add for CONFIG_IEEE80211W, none 11w also can use
frtype /* add for CONFIG_IEEE80211W, none 11w also can use */
);
for (j = 0; j < 16; j++) padded_buffer[j] = 0x00;
@ -1819,9 +1816,9 @@ static sint aes_decipher(u8 *key, uint hdrlen,
for (j=0; j<payload_remainder;j++) pframe[payload_index++] = chain_buffer[j];
}
//start to calculate the mic
/* 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
memcpy((void *)message, pframe, (hdrlen +plen+8)); /* 8 is for ext iv len */
pn_vector[0]=pframe[hdrlen];
@ -1840,14 +1837,14 @@ static sint aes_decipher(u8 *key, uint hdrlen,
message,
plen-8,
pn_vector,
frtype // add for CONFIG_IEEE80211W, none 11w also can use
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
frtype /* add for CONFIG_IEEE80211W, none 11w also can use */
);
construct_mic_header2(
mic_header2,
@ -1907,7 +1904,7 @@ static sint aes_decipher(u8 *key, uint hdrlen,
message,
pn_vector,
i+1,
frtype); // add for CONFIG_IEEE80211W, none 11w also can use
frtype); /* add for CONFIG_IEEE80211W, none 11w also can use */
aes128k128d(key, ctr_preload, aes_out);
bitwise_xor(aes_out, &message[payload_index], chain_buffer);
for (j=0; j<16;j++) message[payload_index++] = chain_buffer[j];
@ -1922,7 +1919,7 @@ static sint aes_decipher(u8 *key, uint hdrlen,
message,
pn_vector,
num_blocks+1,
frtype); // add for CONFIG_IEEE80211W, none 11w also can use
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++)
@ -1942,7 +1939,7 @@ static sint aes_decipher(u8 *key, uint hdrlen,
message,
pn_vector,
0,
frtype); // add for CONFIG_IEEE80211W, none 11w also can use
frtype); /* add for CONFIG_IEEE80211W, none 11w also can use */
for (j = 0; j < 16; j++) padded_buffer[j] = 0x00;
for (j = 0; j < 8; j++)
@ -1954,7 +1951,7 @@ static sint aes_decipher(u8 *key, uint hdrlen,
bitwise_xor(aes_out, padded_buffer, chain_buffer);
for (j=0; j<8;j++) message[payload_index++] = chain_buffer[j];
//compare the mic
/* compare the mic */
for(i=0;i<8;i++){
if(pframe[hdrlen+8+plen-8+i] != message[hdrlen+8+plen-8+i])
{
@ -1970,16 +1967,16 @@ static sint aes_decipher(u8 *key, uint hdrlen,
}
u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)
{ // exclude ICV
{ /* exclude ICV */
int length;
u8 *pframe,*prwskey; //, *payload,*iv
u8 *pframe,*prwskey; /* *payload,*iv */
struct sta_info *stainfo;
struct rx_pkt_attrib *prxattrib = &((union recv_frame *)precvframe)->u.hdr.attrib;
struct security_priv *psecuritypriv=&padapter->securitypriv;
u32 res=_SUCCESS;
;
pframe=(unsigned char *)((union recv_frame*)precvframe)->u.hdr.rx_data;
//4 start to encrypt each fragment
/* 4 start to encrypt each fragment */
if((prxattrib->encrypt==_AES_)){
stainfo=rtw_get_stainfo(&padapter->stapriv ,&prxattrib->ta[0] );
if (stainfo!=NULL){
@ -1990,7 +1987,7 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)
static u32 no_gkey_bc_cnt = 0;
static u32 no_gkey_mc_cnt = 0;
//in concurrent we should use sw descrypt in group key, so we remove this message
/* in concurrent we should use sw descrypt in group key, so we remove this message */
if (!psecuritypriv->binstallGrpkey) {
res=_FAIL;
@ -2066,29 +2063,29 @@ u32 rtw_BIP_verify(struct adapter *padapter, u8 *precvframe)
DBG_871X("BIP AAD allocate fail\n");
return _FAIL;
}
//PKT start
/* PKT start */
pframe=(unsigned char *)((union recv_frame*)precvframe)->u.hdr.rx_data;
//mapping to wlan header
/* mapping to wlan header */
pwlanhdr = (struct rtw_ieee80211_hdr *)pframe;
//save the frame body + MME
/* save the frame body + MME */
memcpy(BIP_AAD+BIP_AAD_SIZE, pframe+WLAN_HDR_A3_LEN, pattrib->pkt_len-WLAN_HDR_A3_LEN);
//find MME IE pointer
/* find MME IE pointer */
p = rtw_get_ie(BIP_AAD+BIP_AAD_SIZE, _MME_IE_, &len, pattrib->pkt_len-WLAN_HDR_A3_LEN);
//Baron
/* Baron */
if(p)
{
u16 keyid=0;
u64 temp_ipn=0;
//save packet number
/* save packet number */
memcpy(&temp_ipn, p+4, 6);
temp_ipn = le64_to_cpu(temp_ipn);
//BIP packet number should bigger than previous BIP packet
/* BIP packet number should bigger than previous BIP packet */
if(temp_ipn <= pmlmeext->mgnt_80211w_IPN_rx)
{
DBG_871X("replay BIP packet\n");
goto BIP_exit;
}
//copy key index
/* copy key index */
memcpy(&keyid, p+2, 2);
keyid = le16_to_cpu(keyid);
if(keyid != padapter->securitypriv.dot11wBIPKeyid)
@ -2096,41 +2093,41 @@ u32 rtw_BIP_verify(struct adapter *padapter, u8 *precvframe)
DBG_871X("BIP key index error!\n");
goto BIP_exit;
}
//clear the MIC field of MME to zero
/* clear the MIC field of MME to zero */
memset(p+2+len-8, 0, 8);
//conscruct AAD, copy frame control field
/* conscruct AAD, copy frame control field */
memcpy(BIP_AAD, &pwlanhdr->frame_ctl, 2);
ClearRetry(BIP_AAD);
ClearPwrMgt(BIP_AAD);
ClearMData(BIP_AAD);
//conscruct AAD, copy address 1 to address 3
/* conscruct AAD, copy address 1 to address 3 */
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;
/*//management packet content
/*/* management packet content */
{
int pp;
DBG_871X("pkt: ");
for(pp=0;pp< pattrib->pkt_len; pp++)
printk(" %02x ", pframe[pp]);
DBG_871X("\n");
//BIP AAD + management frame body + MME(MIC is zero)
/* BIP AAD + management frame body + MME(MIC is zero) */
DBG_871X("AAD+PKT: ");
for(pp=0;pp< ori_len; pp++)
DBG_871X(" %02x ", BIP_AAD[pp]);
DBG_871X("\n");
//show the MIC result
/* show the MIC result */
DBG_871X("mic: ");
for(pp=0;pp<16; pp++)
DBG_871X(" %02x ", mic[pp]);
DBG_871X("\n");
}
*/
//MIC field should be last 8 bytes of packet (packet without FCS)
/* MIC field should be last 8 bytes of packet (packet without FCS) */
if(_rtw_memcmp(mic, pframe+pattrib->pkt_len-8, 8))
{
pmlmeext->mgnt_80211w_IPN_rx = temp_ipn;
@ -2147,7 +2144,7 @@ BIP_exit:
rtw_mfree(BIP_AAD, ori_len);
return res;
}
#endif //CONFIG_IEEE80211W
#endif /* CONFIG_IEEE80211W */
/* compress 512-bits */
static int sha256_compress(struct sha256_state *md, unsigned char *buf)
@ -2851,7 +2848,7 @@ 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 */
static 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);
@ -3016,16 +3013,16 @@ int tdls_verify_mic(u8 *kck, u8 trans_seq,
rx_ftie = ftie+4;
if (os_memcmp(mic, rx_ftie, 16) == 0) {
//Valid MIC
/* Valid MIC */
return 1;
}
//Invalid MIC
/* Invalid MIC */
DBG_871X( "[%s] Invalid MIC\n", __FUNCTION__);
return 0;
}
#endif //CONFIG_TDLS
#endif /* CONFIG_TDLS */
void rtw_use_tkipkey_handler(void *FunctionContext)
{