Staging: vt6656: michael.c: Fixed coding style issues
Replaced lots of spaces by real tabs and resolved other minor issues. Signed-off-by: Daniel Kenji Toyama <kenji.toyama@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
f9ea02af48
commit
183cd29562
@ -48,20 +48,23 @@
|
|||||||
|
|
||||||
/*--------------------- Static Functions --------------------------*/
|
/*--------------------- Static Functions --------------------------*/
|
||||||
/*
|
/*
|
||||||
static DWORD s_dwGetUINT32(BYTE * p); // Get DWORD from 4 bytes LSByte first
|
* static DWORD s_dwGetUINT32(BYTE * p); Get DWORD from
|
||||||
static VOID s_vPutUINT32(BYTE* p, DWORD val); // Put DWORD into 4 bytes LSByte first
|
* 4 bytes LSByte first
|
||||||
|
* static VOID s_vPutUINT32(BYTE* p, DWORD val); Put DWORD into
|
||||||
|
* 4 bytes LSByte first
|
||||||
*/
|
*/
|
||||||
static VOID s_vClear(void); // Clear the internal message,
|
static VOID s_vClear(void); /* Clear the internal message,
|
||||||
// resets the object to the state just after construction.
|
* resets the object to the
|
||||||
|
* state just after construction. */
|
||||||
static VOID s_vSetKey(DWORD dwK0, DWORD dwK1);
|
static VOID s_vSetKey(DWORD dwK0, DWORD dwK1);
|
||||||
static VOID s_vAppendByte(BYTE b); // Add a single byte to the internal message
|
static VOID s_vAppendByte(BYTE b); /* Add a single byte to the internal
|
||||||
|
* message */
|
||||||
|
|
||||||
/*--------------------- Export Variables --------------------------*/
|
/*--------------------- Export Variables --------------------------*/
|
||||||
static DWORD L, R; // Current state
|
static DWORD L, R; /* Current state */
|
||||||
|
static DWORD K0, K1; /* Key */
|
||||||
static DWORD K0, K1; // Key
|
static DWORD M; /* Message accumulator (single word) */
|
||||||
static DWORD M; // Message accumulator (single word)
|
static UINT nBytesInM; /* # bytes in M */
|
||||||
static UINT nBytesInM; // # bytes in M
|
|
||||||
|
|
||||||
/*--------------------- Export Functions --------------------------*/
|
/*--------------------- Export Functions --------------------------*/
|
||||||
|
|
||||||
@ -72,9 +75,7 @@ static DWORD s_dwGetUINT32 (BYTE * p)
|
|||||||
DWORD res = 0;
|
DWORD res = 0;
|
||||||
UINT i;
|
UINT i;
|
||||||
for(i=0; i<4; i++ )
|
for(i=0; i<4; i++ )
|
||||||
{
|
|
||||||
res |= (*p++) << (8*i);
|
res |= (*p++) << (8*i);
|
||||||
}
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,8 +83,7 @@ static VOID s_vPutUINT32 (BYTE* p, DWORD val)
|
|||||||
// Convert from DWORD to BYTE[] in a portable way
|
// Convert from DWORD to BYTE[] in a portable way
|
||||||
{
|
{
|
||||||
UINT i;
|
UINT i;
|
||||||
for(i=0; i<4; i++ )
|
for(i=0; i<4; i++ ) {
|
||||||
{
|
|
||||||
*p++ = (BYTE) (val & 0xff);
|
*p++ = (BYTE) (val & 0xff);
|
||||||
val >>= 8;
|
val >>= 8;
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ static VOID s_vPutUINT32 (BYTE* p, DWORD val)
|
|||||||
|
|
||||||
static VOID s_vClear(void)
|
static VOID s_vClear(void)
|
||||||
{
|
{
|
||||||
// Reset the state to the empty message.
|
/* Reset the state to the empty message. */
|
||||||
L = K0;
|
L = K0;
|
||||||
R = K1;
|
R = K1;
|
||||||
nBytesInM = 0;
|
nBytesInM = 0;
|
||||||
@ -101,21 +101,20 @@ static VOID s_vClear (void)
|
|||||||
|
|
||||||
static VOID s_vSetKey(DWORD dwK0, DWORD dwK1)
|
static VOID s_vSetKey(DWORD dwK0, DWORD dwK1)
|
||||||
{
|
{
|
||||||
// Set the key
|
/* Set the key */
|
||||||
K0 = dwK0;
|
K0 = dwK0;
|
||||||
K1 = dwK1;
|
K1 = dwK1;
|
||||||
// and reset the message
|
/* and reset the message */
|
||||||
s_vClear();
|
s_vClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID s_vAppendByte(BYTE b)
|
static VOID s_vAppendByte(BYTE b)
|
||||||
{
|
{
|
||||||
// Append the byte to our word-sized buffer
|
/* Append the byte to our word-sized buffer */
|
||||||
M |= b << (8*nBytesInM);
|
M |= b << (8*nBytesInM);
|
||||||
nBytesInM++;
|
nBytesInM++;
|
||||||
// Process the word if it is full.
|
/* Process the word if it is full. */
|
||||||
if( nBytesInM >= 4 )
|
if (nBytesInM >= 4) {
|
||||||
{
|
|
||||||
L ^= M;
|
L ^= M;
|
||||||
R ^= ROL32(L, 17);
|
R ^= ROL32(L, 17);
|
||||||
L += R;
|
L += R;
|
||||||
@ -125,7 +124,7 @@ static VOID s_vAppendByte (BYTE b)
|
|||||||
L += R;
|
L += R;
|
||||||
R ^= ROR32(L, 2);
|
R ^= ROR32(L, 2);
|
||||||
L += R;
|
L += R;
|
||||||
// Clear the buffer
|
/* Clear the buffer */
|
||||||
M = 0;
|
M = 0;
|
||||||
nBytesInM = 0;
|
nBytesInM = 0;
|
||||||
}
|
}
|
||||||
@ -133,27 +132,26 @@ static VOID s_vAppendByte (BYTE b)
|
|||||||
|
|
||||||
VOID MIC_vInit(DWORD dwK0, DWORD dwK1)
|
VOID MIC_vInit(DWORD dwK0, DWORD dwK1)
|
||||||
{
|
{
|
||||||
// Set the key
|
/* Set the key */
|
||||||
s_vSetKey(dwK0, dwK1);
|
s_vSetKey(dwK0, dwK1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID MIC_vUnInit(void)
|
VOID MIC_vUnInit(void)
|
||||||
{
|
{
|
||||||
// Wipe the key material
|
/* Wipe the key material */
|
||||||
K0 = 0;
|
K0 = 0;
|
||||||
K1 = 0;
|
K1 = 0;
|
||||||
|
|
||||||
// And the other fields as well.
|
/* And the other fields as well. */
|
||||||
//Note that this sets (L,R) to (K0,K1) which is just fine.
|
/* Note that this sets (L,R) to (K0,K1) which is just fine. */
|
||||||
s_vClear();
|
s_vClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID MIC_vAppend(PBYTE src, UINT nBytes)
|
VOID MIC_vAppend(PBYTE src, UINT nBytes)
|
||||||
{
|
{
|
||||||
// This is simple
|
/* This is simple */
|
||||||
while (nBytes > 0)
|
while (nBytes > 0) {
|
||||||
{
|
|
||||||
s_vAppendByte(*src++);
|
s_vAppendByte(*src++);
|
||||||
nBytes--;
|
nBytes--;
|
||||||
}
|
}
|
||||||
@ -161,21 +159,18 @@ VOID MIC_vAppend (PBYTE src, UINT nBytes)
|
|||||||
|
|
||||||
VOID MIC_vGetMIC(PDWORD pdwL, PDWORD pdwR)
|
VOID MIC_vGetMIC(PDWORD pdwL, PDWORD pdwR)
|
||||||
{
|
{
|
||||||
// Append the minimum padding
|
/* Append the minimum padding */
|
||||||
s_vAppendByte(0x5a);
|
s_vAppendByte(0x5a);
|
||||||
s_vAppendByte(0);
|
s_vAppendByte(0);
|
||||||
s_vAppendByte(0);
|
s_vAppendByte(0);
|
||||||
s_vAppendByte(0);
|
s_vAppendByte(0);
|
||||||
s_vAppendByte(0);
|
s_vAppendByte(0);
|
||||||
// and then zeroes until the length is a multiple of 4
|
/* and then zeroes until the length is a multiple of 4 */
|
||||||
while (nBytesInM != 0)
|
while (nBytesInM != 0)
|
||||||
{
|
|
||||||
s_vAppendByte(0);
|
s_vAppendByte(0);
|
||||||
}
|
/* The s_vAppendByte function has already computed the result. */
|
||||||
// The s_vAppendByte function has already computed the result.
|
|
||||||
*pdwL = L;
|
*pdwL = L;
|
||||||
*pdwR = R;
|
*pdwR = R;
|
||||||
// Reset to the empty message.
|
/* Reset to the empty message. */
|
||||||
s_vClear();
|
s_vClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user