staging:vt6655:michael: Whitespace cleanups
Neatening only. git diff -w shows no differences. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
fd0badb8ed
commit
a51ff9058c
2 changed files with 86 additions and 86 deletions
|
@ -48,11 +48,11 @@
|
||||||
|
|
||||||
/*--------------------- Static Functions --------------------------*/
|
/*--------------------- Static Functions --------------------------*/
|
||||||
/*
|
/*
|
||||||
static unsigned long s_dwGetUINT32(unsigned char *p); // Get unsigned long from 4 bytes LSByte first
|
static unsigned long s_dwGetUINT32(unsigned char *p); // Get unsigned long from 4 bytes LSByte first
|
||||||
static void s_vPutUINT32(unsigned char *p, unsigned long val); // Put unsigned long into 4 bytes LSByte first
|
static void s_vPutUINT32(unsigned char *p, unsigned long val); // Put unsigned long 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(unsigned long dwK0, unsigned long dwK1);
|
static void s_vSetKey(unsigned long dwK0, unsigned long dwK1);
|
||||||
static void s_vAppendByte(unsigned char b); // Add a single byte to the internal message
|
static void s_vAppendByte(unsigned char b); // Add a single byte to the internal message
|
||||||
|
|
||||||
|
@ -66,116 +66,116 @@ static unsigned int nBytesInM; // # bytes in M
|
||||||
/*--------------------- Export Functions --------------------------*/
|
/*--------------------- Export Functions --------------------------*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
static unsigned long s_dwGetUINT32 (unsigned char *p)
|
static unsigned long s_dwGetUINT32 (unsigned char *p)
|
||||||
// Convert from unsigned char [] to unsigned long in a portable way
|
// Convert from unsigned char [] to unsigned long in a portable way
|
||||||
{
|
{
|
||||||
unsigned long res = 0;
|
unsigned long res = 0;
|
||||||
unsigned int i;
|
unsigned int 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void s_vPutUINT32 (unsigned char *p, unsigned long val)
|
static void s_vPutUINT32 (unsigned char *p, unsigned long val)
|
||||||
// Convert from unsigned long to unsigned char [] in a portable way
|
// Convert from unsigned long to unsigned char [] in a portable way
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for(i=0; i<4; i++ )
|
for (i=0; i<4; i++)
|
||||||
{
|
{
|
||||||
*p++ = (unsigned char) (val & 0xff);
|
*p++ = (unsigned char) (val & 0xff);
|
||||||
val >>= 8;
|
val >>= 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
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;
|
||||||
M = 0;
|
M = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void s_vSetKey (unsigned long dwK0, unsigned long dwK1)
|
static void s_vSetKey(unsigned long dwK0, unsigned long 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 (unsigned char b)
|
static void s_vAppendByte(unsigned char 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;
|
||||||
R ^= ((L & 0xff00ff00) >> 8) | ((L & 0x00ff00ff) << 8);
|
R ^= ((L & 0xff00ff00) >> 8) | ((L & 0x00ff00ff) << 8);
|
||||||
L += R;
|
L += R;
|
||||||
R ^= ROL32( L, 3 );
|
R ^= ROL32(L, 3);
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MIC_vInit (unsigned long dwK0, unsigned long dwK1)
|
void MIC_vInit(unsigned long dwK0, unsigned long 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 (unsigned char *src, unsigned int nBytes)
|
void MIC_vAppend(unsigned char *src, unsigned int nBytes)
|
||||||
{
|
{
|
||||||
// This is simple
|
// This is simple
|
||||||
while (nBytes > 0)
|
while (nBytes > 0)
|
||||||
{
|
{
|
||||||
s_vAppendByte(*src++);
|
s_vAppendByte(*src++);
|
||||||
nBytes--;
|
nBytes--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MIC_vGetMIC (unsigned long *pdwL, unsigned long *pdwR)
|
void MIC_vGetMIC(unsigned long *pdwL, unsigned long *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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,9 @@ void MIC_vGetMIC(unsigned long *pdwL, unsigned long *pdwR);
|
||||||
/*--------------------- Export Macros ------------------------------*/
|
/*--------------------- Export Macros ------------------------------*/
|
||||||
|
|
||||||
// Rotation functions on 32 bit values
|
// Rotation functions on 32 bit values
|
||||||
#define ROL32( A, n ) \
|
#define ROL32(A, n) \
|
||||||
( ((A) << (n)) | ( ((A)>>(32-(n))) & ( (1UL << (n)) - 1 ) ) )
|
(((A) << (n)) | (((A)>>(32-(n))) & ((1UL << (n)) - 1)))
|
||||||
#define ROR32( A, n ) ROL32( (A), 32-(n) )
|
#define ROR32(A, n) ROL32((A), 32-(n))
|
||||||
|
|
||||||
#endif //__MICHAEL_H__
|
#endif //__MICHAEL_H__
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue