X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fstaging%2Fvt6656%2Fmichael.c;h=671a8cf33e23e38df2f3575c1a1efec112810520;hb=4fd5ec509bd486b5dd8cac1a4d4d7e2cbdf7c546;hp=c930e0cdb853ae1b4429443f0b7d40edf7ed8762;hpb=a87e84b5cdfacf11af4e8a85c4bca9793658536f;p=pandora-kernel.git diff --git a/drivers/staging/vt6656/michael.c b/drivers/staging/vt6656/michael.c index c930e0cdb853..671a8cf33e23 100644 --- a/drivers/staging/vt6656/michael.c +++ b/drivers/staging/vt6656/michael.c @@ -48,20 +48,23 @@ /*--------------------- Static Functions --------------------------*/ /* -static DWORD s_dwGetUINT32(BYTE * p); // Get DWORD from 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, - // resets the object to the state just after construction. -static VOID s_vSetKey(DWORD dwK0, DWORD dwK1); -static VOID s_vAppendByte(BYTE b); // Add a single byte to the internal message + * static DWORD s_dwGetUINT32(BYTE * p); Get DWORD from + * 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, + * resets the object to the + * state just after construction. */ +static void s_vSetKey(DWORD dwK0, DWORD dwK1); +static void s_vAppendByte(BYTE b); /* Add a single byte to the internal + * message */ /*--------------------- Export Variables --------------------------*/ -static DWORD L, R; // Current state - -static DWORD K0, K1; // Key -static DWORD M; // Message accumulator (single word) -static UINT nBytesInM; // # bytes in M +static DWORD L, R; /* Current state */ +static DWORD K0, K1; /* Key */ +static DWORD M; /* Message accumulator (single word) */ +static unsigned int nBytesInM; /* # bytes in M */ /*--------------------- Export Functions --------------------------*/ @@ -69,113 +72,105 @@ static UINT nBytesInM; // # bytes in M static DWORD s_dwGetUINT32 (BYTE * p) // Convert from BYTE[] to DWORD in a portable way { - DWORD res = 0; - UINT i; - for(i=0; i<4; i++ ) - { - res |= (*p++) << (8*i); - } - return res; + DWORD res = 0; + unsigned int i; + for(i=0; i<4; i++ ) + res |= (*p++) << (8*i); + return res; } -static VOID s_vPutUINT32 (BYTE* p, DWORD val) +static void s_vPutUINT32(BYTE *p, DWORD val) // Convert from DWORD to BYTE[] in a portable way { - UINT i; - for(i=0; i<4; i++ ) - { - *p++ = (BYTE) (val & 0xff); - val >>= 8; - } + unsigned int i; + for(i=0; i<4; i++ ) { + *p++ = (BYTE) (val & 0xff); + val >>= 8; + } } */ -static VOID s_vClear (void) +static void s_vClear(void) { - // Reset the state to the empty message. - L = K0; - R = K1; - nBytesInM = 0; - M = 0; + /* Reset the state to the empty message. */ + L = K0; + R = K1; + nBytesInM = 0; + M = 0; } -static VOID s_vSetKey (DWORD dwK0, DWORD dwK1) +static void s_vSetKey(DWORD dwK0, DWORD dwK1) { - // Set the key - K0 = dwK0; - K1 = dwK1; - // and reset the message - s_vClear(); + /* Set the key */ + K0 = dwK0; + K1 = dwK1; + /* and reset the message */ + s_vClear(); } -static VOID s_vAppendByte (BYTE b) +static void s_vAppendByte(BYTE b) { - // Append the byte to our word-sized buffer - M |= b << (8*nBytesInM); - nBytesInM++; - // Process the word if it is full. - if( nBytesInM >= 4 ) - { - L ^= M; - R ^= ROL32( L, 17 ); - L += R; - R ^= ((L & 0xff00ff00) >> 8) | ((L & 0x00ff00ff) << 8); - L += R; - R ^= ROL32( L, 3 ); - L += R; - R ^= ROR32( L, 2 ); - L += R; - // Clear the buffer - M = 0; - nBytesInM = 0; - } + /* Append the byte to our word-sized buffer */ + M |= b << (8*nBytesInM); + nBytesInM++; + /* Process the word if it is full. */ + if (nBytesInM >= 4) { + L ^= M; + R ^= ROL32(L, 17); + L += R; + R ^= ((L & 0xff00ff00) >> 8) | ((L & 0x00ff00ff) << 8); + L += R; + R ^= ROL32(L, 3); + L += R; + R ^= ROR32(L, 2); + L += R; + /* Clear the buffer */ + M = 0; + nBytesInM = 0; + } } -VOID MIC_vInit (DWORD dwK0, DWORD dwK1) +void MIC_vInit(DWORD dwK0, DWORD dwK1) { - // Set the key - s_vSetKey(dwK0, dwK1); + /* Set the key */ + s_vSetKey(dwK0, dwK1); } -VOID MIC_vUnInit (void) +void MIC_vUnInit(void) { - // Wipe the key material - K0 = 0; - K1 = 0; + /* Wipe the key material */ + K0 = 0; + K1 = 0; - // And the other fields as well. - //Note that this sets (L,R) to (K0,K1) which is just fine. - s_vClear(); + /* And the other fields as well. */ + /* Note that this sets (L,R) to (K0,K1) which is just fine. */ + s_vClear(); } -VOID MIC_vAppend (PBYTE src, UINT nBytes) +void MIC_vAppend(PBYTE src, unsigned int nBytes) { - // This is simple - while (nBytes > 0) - { - s_vAppendByte(*src++); - nBytes--; - } + /* This is simple */ + while (nBytes > 0) { + s_vAppendByte(*src++); + nBytes--; + } } -VOID MIC_vGetMIC (PDWORD pdwL, PDWORD pdwR) +void MIC_vGetMIC(PDWORD pdwL, PDWORD pdwR) { - // Append the minimum padding - s_vAppendByte(0x5a); - s_vAppendByte(0); - s_vAppendByte(0); - s_vAppendByte(0); - s_vAppendByte(0); - // and then zeroes until the length is a multiple of 4 - while( nBytesInM != 0 ) - { - s_vAppendByte(0); - } - // The s_vAppendByte function has already computed the result. - *pdwL = L; - *pdwR = R; - // Reset to the empty message. - s_vClear(); + /* Append the minimum padding */ + s_vAppendByte(0x5a); + s_vAppendByte(0); + s_vAppendByte(0); + s_vAppendByte(0); + s_vAppendByte(0); + /* and then zeroes until the length is a multiple of 4 */ + while (nBytesInM != 0) + s_vAppendByte(0); + /* The s_vAppendByte function has already computed the result. */ + *pdwL = L; + *pdwR = R; + /* Reset to the empty message. */ + s_vClear(); } -