aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/ks7010/michael_mic.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/ks7010/michael_mic.c')
-rw-r--r--drivers/staging/ks7010/michael_mic.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c
index 78ae2b8fb7f3..2f535c08e172 100644
--- a/drivers/staging/ks7010/michael_mic.c
+++ b/drivers/staging/ks7010/michael_mic.c
@@ -14,10 +14,11 @@
#include "michael_mic.h"
// Rotation functions on 32 bit values
-#define ROL32( A, n ) ( ((A) << (n)) | ( ((A)>>(32-(n))) & ( (1UL << (n)) - 1 ) ) )
-#define ROR32( A, n ) ROL32( (A), 32-(n) )
+#define ROL32(A, n) (((A) << (n)) | (((A)>>(32-(n))) & ((1UL << (n)) - 1)))
+#define ROR32(A, n) ROL32((A), 32-(n))
// Convert from Byte[] to UInt32 in a portable way
-#define getUInt32( A, B ) (uint32_t)(A[B+0] << 0) + (A[B+1] << 8) + (A[B+2] << 16) + (A[B+3] << 24)
+#define getUInt32(A, B) ((uint32_t)(A[B+0] << 0) \
+ + (A[B+1] << 8) + (A[B+2] << 16) + (A[B+3] << 24))
// Convert from UInt32 to Byte[] in a portable way
#define putUInt32(A, B, C) \
@@ -48,21 +49,22 @@ void MichaelInitializeFunction(struct michel_mic_t *Mic, uint8_t *key)
}
#define MichaelBlockFunction(L, R) \
-do{ \
- R ^= ROL32( L, 17 ); \
+do { \
+ R ^= ROL32(L, 17); \
L += R; \
R ^= ((L & 0xff00ff00) >> 8) | ((L & 0x00ff00ff) << 8); \
L += R; \
- R ^= ROL32( L, 3 ); \
+ R ^= ROL32(L, 3); \
L += R; \
- R ^= ROR32( L, 2 ); \
+ R ^= ROR32(L, 2); \
L += R; \
-}while(0)
+} while (0)
static
void MichaelAppend(struct michel_mic_t *Mic, uint8_t *src, int nBytes)
{
int addlen;
+
if (Mic->nBytesInM) {
addlen = 4 - Mic->nBytesInM;
if (addlen > nBytes)
@@ -96,7 +98,8 @@ void MichaelAppend(struct michel_mic_t *Mic, uint8_t *src, int nBytes)
static
void MichaelGetMIC(struct michel_mic_t *Mic, uint8_t *dst)
{
- uint8_t *data = Mic->M;
+ u8 *data = Mic->M;
+
switch (Mic->nBytesInM) {
case 0:
Mic->L ^= 0x5a;
@@ -122,11 +125,11 @@ void MichaelGetMIC(struct michel_mic_t *Mic, uint8_t *dst)
MichaelClear(Mic);
}
-void MichaelMICFunction(struct michel_mic_t *Mic, uint8_t *Key,
- uint8_t *Data, int Len, uint8_t priority,
- uint8_t *Result)
+void MichaelMICFunction(struct michel_mic_t *Mic, u8 *Key,
+ u8 *Data, int Len, u8 priority,
+ u8 *Result)
{
- uint8_t pad_data[4] = { priority, 0, 0, 0 };
+ u8 pad_data[4] = { priority, 0, 0, 0 };
// Compute the MIC value
/*
* IEEE802.11i page 47