diff options
Diffstat (limited to 'drivers/staging/vt6656/michael.c')
-rw-r--r-- | drivers/staging/vt6656/michael.c | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/drivers/staging/vt6656/michael.c b/drivers/staging/vt6656/michael.c index 4d41981..9a5a0b6 100644 --- a/drivers/staging/vt6656/michael.c +++ b/drivers/staging/vt6656/michael.c @@ -26,8 +26,8 @@ * Date: Sep 4, 2002 * * Functions: - * s_dwGetUINT32 - Convert from BYTE[] to DWORD in a portable way - * s_vPutUINT32 - Convert from DWORD to BYTE[] in a portable way + * s_dwGetUINT32 - Convert from u8[] to u32 in a portable way + * s_vPutUINT32 - Convert from u32 to u8[] in a portable way * s_vClear - Reset the state to the empty message. * s_vSetKey - Set the key. * MIC_vInit - Set the key. @@ -42,49 +42,41 @@ #include "tmacro.h" #include "michael.h" -/*--------------------- Static Definitions -------------------------*/ - -/*--------------------- Static Variables --------------------------*/ - -/*--------------------- Static Functions --------------------------*/ /* - * static DWORD s_dwGetUINT32(BYTE * p); Get DWORD from + * static u32 s_dwGetUINT32(u8 * p); Get u32 from * 4 bytes LSByte first - * static void s_vPutUINT32(BYTE* p, DWORD val); Put DWORD into + * static void s_vPutUINT32(u8* p, u32 val); Put u32 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 +static void s_vSetKey(u32 dwK0, u32 dwK1); +static void s_vAppendByte(u8 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 u32 L, R; /* Current state */ +static u32 K0, K1; /* Key */ +static u32 M; /* Message accumulator (single word) */ static unsigned int nBytesInM; /* # bytes in M */ -/*--------------------- Export Functions --------------------------*/ - /* -static DWORD s_dwGetUINT32 (BYTE * p) -// Convert from BYTE[] to DWORD in a portable way +static u32 s_dwGetUINT32 (u8 * p) +// Convert from u8[] to u32 in a portable way { - DWORD res = 0; + u32 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) -// Convert from DWORD to BYTE[] in a portable way +static void s_vPutUINT32(u8 *p, u32 val) +// Convert from u32 to u8[] in a portable way { unsigned int i; for (i = 0; i < 4; i++) { - *p++ = (BYTE) (val & 0xff); + *p++ = (u8) (val & 0xff); val >>= 8; } } @@ -99,7 +91,7 @@ static void s_vClear(void) M = 0; } -static void s_vSetKey(DWORD dwK0, DWORD dwK1) +static void s_vSetKey(u32 dwK0, u32 dwK1) { /* Set the key */ K0 = dwK0; @@ -108,7 +100,7 @@ static void s_vSetKey(DWORD dwK0, DWORD dwK1) s_vClear(); } -static void s_vAppendByte(BYTE b) +static void s_vAppendByte(u8 b) { /* Append the byte to our word-sized buffer */ M |= b << (8*nBytesInM); @@ -130,13 +122,12 @@ static void s_vAppendByte(BYTE b) } } -void MIC_vInit(DWORD dwK0, DWORD dwK1) +void MIC_vInit(u32 dwK0, u32 dwK1) { /* Set the key */ s_vSetKey(dwK0, dwK1); } - void MIC_vUnInit(void) { /* Wipe the key material */ @@ -148,7 +139,7 @@ void MIC_vUnInit(void) s_vClear(); } -void MIC_vAppend(PBYTE src, unsigned int nBytes) +void MIC_vAppend(u8 * src, unsigned int nBytes) { /* This is simple */ while (nBytes > 0) { @@ -157,7 +148,7 @@ void MIC_vAppend(PBYTE src, unsigned int nBytes) } } -void MIC_vGetMIC(PDWORD pdwL, PDWORD pdwR) +void MIC_vGetMIC(u32 * pdwL, u32 * pdwR) { /* Append the minimum padding */ s_vAppendByte(0x5a); |