diff --git a/ChangeLog b/ChangeLog index b08e049a0..01f963537 100644 --- a/ChangeLog +++ b/ChangeLog @@ -52,6 +52,7 @@ Bugfix * If certificate serial is longer than 32 octets, serial number is now appended with '....' after first 28 octets * Improved build support for s390x and sparc64 in bignum.h + * Fixed MS Visual C++ name clash with int64 in sha4.h = Version 1.0.0 released on 2011-07-27 Features diff --git a/include/polarssl/sha4.h b/include/polarssl/sha4.h index 81a69cdcc..06a85f10d 100644 --- a/include/polarssl/sha4.h +++ b/include/polarssl/sha4.h @@ -31,10 +31,10 @@ #if defined(_MSC_VER) || defined(__WATCOMC__) #define UL64(x) x##ui64 - #define int64 __int64 + #define long64 __int64 #else #define UL64(x) x##ULL - #define int64 long long + #define long64 long long #endif /** @@ -42,8 +42,8 @@ */ typedef struct { - unsigned int64 total[2]; /*!< number of bytes processed */ - unsigned int64 state[8]; /*!< intermediate digest state */ + unsigned long64 total[2]; /*!< number of bytes processed */ + unsigned long64 state[8]; /*!< intermediate digest state */ unsigned char buffer[128]; /*!< data block being processed */ unsigned char ipad[128]; /*!< HMAC: inner padding */ diff --git a/library/sha4.c b/library/sha4.c index d22287d7e..ee6cf902a 100644 --- a/library/sha4.c +++ b/library/sha4.c @@ -44,14 +44,14 @@ #ifndef GET_UINT64_BE #define GET_UINT64_BE(n,b,i) \ { \ - (n) = ( (unsigned int64) (b)[(i) ] << 56 ) \ - | ( (unsigned int64) (b)[(i) + 1] << 48 ) \ - | ( (unsigned int64) (b)[(i) + 2] << 40 ) \ - | ( (unsigned int64) (b)[(i) + 3] << 32 ) \ - | ( (unsigned int64) (b)[(i) + 4] << 24 ) \ - | ( (unsigned int64) (b)[(i) + 5] << 16 ) \ - | ( (unsigned int64) (b)[(i) + 6] << 8 ) \ - | ( (unsigned int64) (b)[(i) + 7] ); \ + (n) = ( (unsigned long64) (b)[(i) ] << 56 ) \ + | ( (unsigned long64) (b)[(i) + 1] << 48 ) \ + | ( (unsigned long64) (b)[(i) + 2] << 40 ) \ + | ( (unsigned long64) (b)[(i) + 3] << 32 ) \ + | ( (unsigned long64) (b)[(i) + 4] << 24 ) \ + | ( (unsigned long64) (b)[(i) + 5] << 16 ) \ + | ( (unsigned long64) (b)[(i) + 6] << 8 ) \ + | ( (unsigned long64) (b)[(i) + 7] ); \ } #endif @@ -72,7 +72,7 @@ /* * Round constants */ -static const unsigned int64 K[80] = +static const unsigned long64 K[80] = { UL64(0x428A2F98D728AE22), UL64(0x7137449123EF65CD), UL64(0xB5C0FBCFEC4D3B2F), UL64(0xE9B5DBA58189DBBC), @@ -155,8 +155,8 @@ void sha4_starts( sha4_context *ctx, int is384 ) static void sha4_process( sha4_context *ctx, const unsigned char data[128] ) { int i; - unsigned int64 temp1, temp2, W[80]; - unsigned int64 A, B, C, D, E, F, G, H; + unsigned long64 temp1, temp2, W[80]; + unsigned long64 A, B, C, D, E, F, G, H; #define SHR(x,n) (x >> n) #define ROTR(x,n) (SHR(x,n) | (x << (64 - n))) @@ -235,9 +235,9 @@ void sha4_update( sha4_context *ctx, const unsigned char *input, size_t ilen ) left = (unsigned int) (ctx->total[0] & 0x7F); fill = 128 - left; - ctx->total[0] += (unsigned int64) ilen; + ctx->total[0] += (unsigned long64) ilen; - if( ctx->total[0] < (unsigned int64) ilen ) + if( ctx->total[0] < (unsigned long64) ilen ) ctx->total[1]++; if( left && ilen >= fill ) @@ -282,7 +282,7 @@ static const unsigned char sha4_padding[128] = void sha4_finish( sha4_context *ctx, unsigned char output[64] ) { size_t last, padn; - unsigned int64 high, low; + unsigned long64 high, low; unsigned char msglen[16]; high = ( ctx->total[0] >> 61 )