diff options
author | Guy Harris <guy@alum.mit.edu> | 2007-02-25 23:25:23 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2007-02-25 23:25:23 +0000 |
commit | 2b75ac83af8e23f8b9d284c143537d7ab5b82487 (patch) | |
tree | 7b5c3f50bc2d9ca7e8cd4f19f5b1dab72867c944 | |
parent | 3496de0ff1cd23c991e86861d01e29d3317fcfcb (diff) |
Eliminate __inline - not all compilers support it.
svn path=/trunk/; revision=20932
-rw-r--r-- | epan/crypt/airpdcap_ccmp.c | 27 | ||||
-rw-r--r-- | epan/crypt/airpdcap_rijndael.h | 17 | ||||
-rw-r--r-- | epan/crypt/airpdcap_tkip.c | 74 |
3 files changed, 35 insertions, 83 deletions
diff --git a/epan/crypt/airpdcap_ccmp.c b/epan/crypt/airpdcap_ccmp.c index 742b8185c0..eeb9b0019b 100644 --- a/epan/crypt/airpdcap_ccmp.c +++ b/epan/crypt/airpdcap_ccmp.c @@ -73,12 +73,16 @@ _b0[14] = (UINT8)((_i >> 8) & 0xff); \ _b0[15] = (UINT8)(_i & 0xff); \ rijndael_encrypt(&key, _b0, _b); \ - xor_block(_pos, _b, _len); \ + XOR_BLOCK(_pos, _b, _len); \ /* Authentication */ \ - xor_block(_a, _pos, _len); \ + XOR_BLOCK(_a, _pos, _len); \ rijndael_encrypt(&key, _a, _a); \ } +#define READ_6(b0, b1, b2, b3, b4, b5) \ + ((((UINT64)((UINT16)((b4 << 0) | (b5 << 8)))) << 32) | \ + ((UINT32)((b0 << 0) | (b1 << 8) | (b2 << 16) | (b3 << 24)))) + #define AIRPDCAP_ADDR_COPY(dst,src) memcpy(dst,src,AIRPDCAP_MAC_LEN) /****************************************************************************/ @@ -98,19 +102,6 @@ static void ccmp_init_blocks( /****************************************************************************/ /* Function definitions */ -static __inline UINT64 READ_6( - UINT8 b0, - UINT8 b1, - UINT8 b2, - UINT8 b3, - UINT8 b4, - UINT8 b5) -{ - UINT32 iv32 = (b0 << 0) | (b1 << 8) | (b2 << 16) | (b3 << 24); - UINT16 iv16 = (UINT16)((b4 << 0) | (b5 << 8)); - return (((UINT64)iv16) << 32) | iv32; -} - static void ccmp_init_blocks( rijndael_ctx *ctx, PAIRPDCAP_MAC_FRAME wh, @@ -203,9 +194,9 @@ static void ccmp_init_blocks( /* Start with the first block and AAD */ rijndael_encrypt(ctx, b0, a); - xor_block(a, aad, AES_BLOCK_LEN); + XOR_BLOCK(a, aad, AES_BLOCK_LEN); rijndael_encrypt(ctx, a, a); - xor_block(a, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); + XOR_BLOCK(a, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN); rijndael_encrypt(ctx, a, a); b0[0] &= 0x07; b0[14] = b0[15] = 0; @@ -246,7 +237,7 @@ INT AirPDcapCcmpDecrypt( return 0; ccmp_init_blocks(&key, wh, *(UINT64 *)PN, data_len, b0, aad, a, b); memcpy(mic, m+len-AIRPDCAP_CCMP_TRAILER, AIRPDCAP_CCMP_TRAILER); - xor_block(mic, b, AIRPDCAP_CCMP_TRAILER); + XOR_BLOCK(mic, b, AIRPDCAP_CCMP_TRAILER); i = 1; pos = (UINT8 *)m + z + AIRPDCAP_CCMP_HEADER; diff --git a/epan/crypt/airpdcap_rijndael.h b/epan/crypt/airpdcap_rijndael.h index aa1ed10e3c..2755d644ed 100644 --- a/epan/crypt/airpdcap_rijndael.h +++ b/epan/crypt/airpdcap_rijndael.h @@ -79,17 +79,14 @@ void rijndael_set_key( /******************************************************************************/ /******************************************************************************/ -/* External function definition */ +/* Block XOR macro definition */ /* */ -static __inline void xor_block( - UINT8 *b, - const UINT8 *a, - size_t len) -{ - INT i; - for (i = 0; i < (INT)len; i++) - b[i] ^= a[i]; -} +#define XOR_BLOCK(b, a, len) \ + { \ + INT i; \ + for (i = 0; i < (INT)(len); i++) \ + (b)[i] ^= (a)[i]; \ + } /* */ /******************************************************************************/ diff --git a/epan/crypt/airpdcap_tkip.c b/epan/crypt/airpdcap_tkip.c index 5bade5802e..fad8790c3e 100644 --- a/epan/crypt/airpdcap_tkip.c +++ b/epan/crypt/airpdcap_tkip.c @@ -115,72 +115,36 @@ static const UINT16 Sbox[256] = { /* TODO: check for little-endian, big-endian */ -/******************************************************************************/ -/* Function definitions */ /* */ /* Note: any functions were copied from FreeBSD source code, RELENG 6, */ /* sys/net80211/ieee80211_crypto_tkip.c */ -static __inline UINT16 RotR1( - UINT16 val) -{ - return (UINT16)((val >> 1) | (val << 15)); -} +/* Converted to macros to avoid using __inline, as not all compilers support it */ +#define RotR1(val) ((UINT16)(((val) >> 1) | ((val) << 15))) -static __inline UINT8 Lo8( - UINT16 val) -{ - return (UINT8)(val & 0xff); -} +#define Lo8(val) ((UINT8)((val) & 0xff)) -static __inline UINT8 Hi8( - UINT16 val) -{ - return (UINT8)(val >> 8); -} +#define Hi8(val) ((UINT8)((val) >> 8)) -static __inline UINT16 Lo16( - UINT32 val) -{ - return (UINT16)(val & 0xffff); -} +#define Lo16(val) ((UINT16)((val) & 0xffff)) -static __inline UINT16 Hi16( - UINT32 val) -{ - return (UINT16)(val >> 16); -} +#define Hi16(val) ((UINT16)((val) >> 16)) -static __inline UINT16 Mk16( - UINT8 hi, - UINT8 lo) -{ - return (UINT16)(lo | (((UINT16) hi) << 8)); -} +#define Mk16(hi, lo) \ + ((UINT16)((lo) | (((UINT16) (hi)) << 8))) -static __inline UINT16 Mk16_le(const UINT16 *v) -{ - return (UINT16)*v; -} +/* XXX - does this assume a little-endian processor? */ +/* For that matter, does it assume a processor that handles unaligned loads? */ +#define Mk16_le(v) ((UINT16)*(v)) -static __inline UINT16 _S_( - UINT16 v) -{ - UINT16 t = Sbox[Hi8(v)]; - return (UINT16)(Sbox[Lo8(v)] ^ ((t << 8) | (t >> 8))); -} +#define _S_(v) \ + ((UINT16)(Sbox[Lo8(v)] ^ ((Sbox[Hi8(v)] << 8) | (Sbox[Hi8(v)] >> 8)))) -static __inline UINT64 READ_6( - UINT8 b0, - UINT8 b1, - UINT8 b2, - UINT8 b3, - UINT8 b4, - UINT8 b5) -{ - UINT32 iv32 = (b0 << 0) | (b1 << 8) | (b2 << 16) | (b3 << 24); - UINT16 iv16 = (UINT16)((b4 << 0) | (b5 << 8)); - return (((UINT64)iv16) << 32) | iv32; -} +#define READ_6(b0, b1, b2, b3, b4, b5) \ + ((((UINT64)((UINT16)((b4 << 0) | (b5 << 8)))) << 32) | \ + ((UINT32)((b0 << 0) | (b1 << 8) | (b2 << 16) | (b3 << 24)))) + +/******************************************************************************/ +/* Function definitions */ void AirPDcapTkipMixingPhase1( UINT16 *TTAK, |