From a278e9a74deaf306ed68707f2954c9f2c910a69d Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Sat, 26 Nov 2005 13:15:06 +0000 Subject: [PATCH] - use php_hash_* types # ok with everybody? --- ext/hash/config.m4 | 7 +++- ext/hash/hash_adler32.c | 2 +- ext/hash/hash_gost.c | 14 ++++---- ext/hash/hash_haval.c | 44 ++++++++++++------------ ext/hash/hash_md.c | 36 ++++++++++---------- ext/hash/hash_ripemd.c | 42 +++++++++++------------ ext/hash/hash_salsa.c | 12 +++---- ext/hash/hash_sha.c | 56 +++++++++++++------------------ ext/hash/hash_snefru.c | 14 ++++---- ext/hash/hash_tiger.c | 12 +++---- ext/hash/hash_whirlpool.c | 4 +-- ext/hash/package.xml | 1 + ext/hash/php_hash.h | 1 + ext/hash/php_hash_adler32.h | 2 +- ext/hash/php_hash_crc32.h | 2 +- ext/hash/php_hash_crc32_tables.h | 4 +-- ext/hash/php_hash_gost.h | 4 +-- ext/hash/php_hash_gost_tables.h | 2 +- ext/hash/php_hash_haval.h | 6 ++-- ext/hash/php_hash_md.h | 4 +-- ext/hash/php_hash_ripemd.h | 8 ++--- ext/hash/php_hash_salsa.h | 4 +-- ext/hash/php_hash_sha.h | 18 +++------- ext/hash/php_hash_snefru.h | 4 +-- ext/hash/php_hash_snefru_tables.h | 2 +- ext/hash/php_hash_tiger.h | 15 --------- ext/hash/php_hash_types.h | 40 ++++++++++++++++++++++ ext/hash/php_hash_whirlpool.h | 15 --------- 28 files changed, 186 insertions(+), 189 deletions(-) create mode 100644 ext/hash/php_hash_types.h diff --git a/ext/hash/config.m4 b/ext/hash/config.m4 index ba67f6ecd8..9371ce04b9 100644 --- a/ext/hash/config.m4 +++ b/ext/hash/config.m4 @@ -6,13 +6,18 @@ PHP_ARG_ENABLE(hash, whether to enable hash support, if test "$PHP_HASH" != "no"; then AC_DEFINE(HAVE_HASH_EXT,1,[Have HASH Extension]) + + AC_CHECK_SIZEOF(short, 2) + AC_CHECK_SIZEOF(int, 4) + AC_CHECK_SIZEOF(long, 4) + AC_CHECK_SIZEOF(long long, 8) EXT_HASH_SOURCES="hash.c hash_md.c hash_sha.c hash_ripemd.c hash_haval.c \ hash_tiger.c hash_gost.c hash_snefru.c hash_whirlpool.c hash_adler32.c \ hash_crc32.c" EXT_HASH_HEADERS="php_hash.h php_hash_md.h php_hash_sha.h php_hash_ripemd.h \ php_hash_haval.h php_hash_tiger.h php_hash_gost.h php_hash_snefru.h \ - php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h" + php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h php_hash_types.h" PHP_NEW_EXTENSION(hash, $EXT_HASH_SOURCES, $ext_shared) ifdef([PHP_INSTALL_HEADERS], [ diff --git a/ext/hash/hash_adler32.c b/ext/hash/hash_adler32.c index 368305576a..48b2c873d9 100644 --- a/ext/hash/hash_adler32.c +++ b/ext/hash/hash_adler32.c @@ -29,7 +29,7 @@ PHP_HASH_API void PHP_ADLER32Init(PHP_ADLER32_CTX *context) PHP_HASH_API void PHP_ADLER32Update(PHP_ADLER32_CTX *context, const unsigned char *input, size_t len) { - php_uint32 i, s[2] = { context->state & 0xffff, (context->state >> 16) & 0xffff }; + php_hash_uint32 i, s[2] = { context->state & 0xffff, (context->state >> 16) & 0xffff }; for (i = 0; i < len; ++i) { s[0] = (s[0] + input[i]) % 65521; diff --git a/ext/hash/hash_gost.c b/ext/hash/hash_gost.c index 44b1e10255..e4117d2bcb 100644 --- a/ext/hash/hash_gost.c +++ b/ext/hash/hash_gost.c @@ -207,10 +207,10 @@ AA(v, l, r); \ } -static inline void Gost(php_uint32 state[8], php_uint32 data[8]) +static inline void Gost(php_hash_uint32 state[8], php_hash_uint32 data[8]) { int i; - php_uint32 l, r, t, key[8], u[8], v[8], w[8], s[8], *h = state, *m = data; + php_hash_uint32 l, r, t, key[8], u[8], v[8], w[8], s[8], *h = state, *m = data; memcpy(u, state, sizeof(u)); memcpy(v, data, sizeof(v)); @@ -227,11 +227,11 @@ static inline void Gost(php_uint32 state[8], php_uint32 data[8]) static inline void GostTransform(PHP_GOST_CTX *context, const unsigned char input[32]) { int i, j; - php_uint32 data[8], temp = 0, save = 0; + php_hash_uint32 data[8], temp = 0, save = 0; for (i = 0, j = 0; i < 8; ++i, j += 4) { - data[i] = ((php_uint32) input[j]) | (((php_uint32) input[j + 1]) << 8) | - (((php_uint32) input[j + 2]) << 16) | (((php_uint32) input[j + 3]) << 24); + data[i] = ((php_hash_uint32) input[j]) | (((php_hash_uint32) input[j + 1]) << 8) | + (((php_hash_uint32) input[j + 2]) << 16) | (((php_hash_uint32) input[j + 3]) << 24); save = context->state[i + 8]; context->state[i + 8] += data[i] + temp; temp = ((context->state[i + 8] < data[i]) || (context->state[i + 8] < save)) ? 1 : 0; @@ -245,7 +245,7 @@ PHP_HASH_API void PHP_GOSTInit(PHP_GOST_CTX *context) memset(context, 0, sizeof(*context)); } -static const php_uint32 MAX32 = 0xffffffffLU; +static const php_hash_uint32 MAX32 = 0xffffffffLU; PHP_HASH_API void PHP_GOSTUpdate(PHP_GOST_CTX *context, const unsigned char *input, size_t len) { @@ -281,7 +281,7 @@ PHP_HASH_API void PHP_GOSTUpdate(PHP_GOST_CTX *context, const unsigned char *inp PHP_HASH_API void PHP_GOSTFinal(unsigned char digest[32], PHP_GOST_CTX *context) { - php_uint32 i, j, l[8] = {0}; + php_hash_uint32 i, j, l[8] = {0}; if (context->length) { GostTransform(context, context->buffer); diff --git a/ext/hash/hash_haval.c b/ext/hash/hash_haval.c index e31e27c9b7..0ff42e74e5 100644 --- a/ext/hash/hash_haval.c +++ b/ext/hash/hash_haval.c @@ -31,28 +31,28 @@ static unsigned char PADDING[128] ={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -static php_uint32 D0[8] = { +static php_hash_uint32 D0[8] = { 0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344, 0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89 }; -static php_uint32 K2[32] = { +static php_hash_uint32 K2[32] = { 0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C, 0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917, 0x9216D5D9, 0x8979FB1B, 0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7, 0xB8E1AFED, 0x6A267E96, 0xBA7C9045, 0xF12C7F99, 0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16, 0x636920D8, 0x71574E69, 0xA458FEA3, 0xF4933D7E, 0x0D95748F, 0x728EB658, 0x718BCD58, 0x82154AEE, 0x7B54A41D, 0xC25A59B5 }; -static php_uint32 K3[32] = { +static php_hash_uint32 K3[32] = { 0x9C30D539, 0x2AF26013, 0xC5D1B023, 0x286085F0, 0xCA417918, 0xB8DB38EF, 0x8E79DCB0, 0x603A180E, 0x6C9E0E8B, 0xB01E8A3E, 0xD71577C1, 0xBD314B27, 0x78AF2FDA, 0x55605C60, 0xE65525F3, 0xAA55AB94, 0x57489862, 0x63E81440, 0x55CA396A, 0x2AAB10B6, 0xB4CC5C34, 0x1141E8CE, 0xA15486AF, 0x7C72E993, 0xB3EE1411, 0x636FBC2A, 0x2BA9C55D, 0x741831F6, 0xCE5C3E16, 0x9B87931E, 0xAFD6BA33, 0x6C24CF5C }; -static php_uint32 K4[32] = { +static php_hash_uint32 K4[32] = { 0x7A325381, 0x28958677, 0x3B8F4898, 0x6B4BB9AF, 0xC4BFE81B, 0x66282193, 0x61D809CC, 0xFB21A991, 0x487CAC60, 0x5DEC8032, 0xEF845D5D, 0xE98575B1, 0xDC262302, 0xEB651B88, 0x23893E81, 0xD396ACC5, 0x0F6D6FF3, 0x83F44239, 0x2E0B4482, 0xA4842004, 0x69C8F04A, 0x9E1F9B5E, 0x21C66842, 0xF6E96C9A, 0x670C9C61, 0xABD388F0, 0x6A51A0D2, 0xD8542F68, 0x960FA728, 0xAB5133A3, 0x6EEF0B6C, 0x137A3BE4 }; -static php_uint32 K5[32] = { +static php_hash_uint32 K5[32] = { 0xBA3BF050, 0x7EFB2A98, 0xA1F1651D, 0x39AF0176, 0x66CA593E, 0x82430E88, 0x8CEE8619, 0x456F9FB4, 0x7D84A5C3, 0x3B8B5EBE, 0xE06F75D8, 0x85C12073, 0x401A449F, 0x56C16AA6, 0x4ED3AA62, 0x363F7706, 0x1BFEDF72, 0x429B023D, 0x37D0D724, 0xD00A1248, 0xDB0FEAD3, 0x49F1C09B, 0x075372C9, 0x80991B7B, @@ -95,10 +95,10 @@ static short M7[32] = { 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0 }; /* {{{ Encode - Encodes input (php_uint32) into output (unsigned char). Assumes len is + Encodes input (php_hash_uint32) into output (unsigned char). Assumes len is a multiple of 4. */ -static void Encode(unsigned char *output, php_uint32 *input, unsigned int len) +static void Encode(unsigned char *output, php_hash_uint32 *input, unsigned int len) { unsigned int i, j; @@ -112,16 +112,16 @@ static void Encode(unsigned char *output, php_uint32 *input, unsigned int len) /* }}} */ /* {{{ Decode - Decodes input (unsigned char) into output (php_uint32). Assumes len is + Decodes input (unsigned char) into output (php_hash_uint32). Assumes len is a multiple of 4. */ -static void Decode(php_uint32 *output, const unsigned char *input, unsigned int len) +static void Decode(php_hash_uint32 *output, const unsigned char *input, unsigned int len) { unsigned int i, j; for (i = 0, j = 0; j < len; i++, j += 4) { - output[i] = ((php_uint32) input[j]) | (((php_uint32) input[j + 1]) << 8) | - (((php_uint32) input[j + 2]) << 16) | (((php_uint32) input[j + 3]) << 24); + output[i] = ((php_hash_uint32) input[j]) | (((php_hash_uint32) input[j + 1]) << 8) | + (((php_hash_uint32) input[j + 2]) << 16) | (((php_hash_uint32) input[j + 3]) << 24); } } /* }}} */ @@ -141,10 +141,10 @@ static void Decode(php_uint32 *output, const unsigned char *input, unsigned int /* {{{ PHP_3HAVALTransform */ -static void PHP_3HAVALTransform(php_uint32 state[8], const unsigned char block[128]) +static void PHP_3HAVALTransform(php_hash_uint32 state[8], const unsigned char block[128]) { - php_uint32 E[8]; - php_uint32 x[32]; + php_hash_uint32 E[8]; + php_hash_uint32 x[32]; int i; Decode(x, block, 128); @@ -175,10 +175,10 @@ static void PHP_3HAVALTransform(php_uint32 state[8], const unsigned char block[1 /* {{{ PHP_4HAVALTransform */ -static void PHP_4HAVALTransform(php_uint32 state[8], const unsigned char block[128]) +static void PHP_4HAVALTransform(php_hash_uint32 state[8], const unsigned char block[128]) { - php_uint32 E[8]; - php_uint32 x[32]; + php_hash_uint32 E[8]; + php_hash_uint32 x[32]; int i; Decode(x, block, 128); @@ -212,10 +212,10 @@ static void PHP_4HAVALTransform(php_uint32 state[8], const unsigned char block[1 /* {{{ PHP_5HAVALTransform */ -static void PHP_5HAVALTransform(php_uint32 state[8], const unsigned char block[128]) +static void PHP_5HAVALTransform(php_hash_uint32 state[8], const unsigned char block[128]) { - php_uint32 E[8]; - php_uint32 x[32]; + php_hash_uint32 E[8]; + php_hash_uint32 x[32]; int i; Decode(x, block, 128); @@ -288,10 +288,10 @@ PHP_HASH_API void PHP_HAVALUpdate(PHP_HAVAL_CTX *context, const unsigned char *i /* Compute number of bytes mod 128 */ index = (unsigned int) ((context->count[0] >> 3) & 0x7F); /* Update number of bits */ - if ((context->count[0] += ((php_uint32) inputLen << 3)) < ((php_uint32) inputLen << 3)) { + if ((context->count[0] += ((php_hash_uint32) inputLen << 3)) < ((php_hash_uint32) inputLen << 3)) { context->count[1]++; } - context->count[1] += ((php_uint32) inputLen >> 29); + context->count[1] += ((php_hash_uint32) inputLen >> 29); partLen = 128 - index; diff --git a/ext/hash/hash_md.c b/ext/hash/hash_md.c index 2270b3fd2d..a4f29d6e8a 100644 --- a/ext/hash/hash_md.c +++ b/ext/hash/hash_md.c @@ -162,9 +162,9 @@ PHP_NAMED_FUNCTION(php_if_md5_file) #define S43 15 #define S44 21 -static void MD5Transform(php_uint32[4], const unsigned char[64]); -static void Encode(unsigned char *, php_uint32 *, unsigned int); -static void Decode(php_uint32 *, const unsigned char *, unsigned int); +static void MD5Transform(php_hash_uint32[4], const unsigned char[64]); +static void Encode(unsigned char *, php_hash_uint32 *, unsigned int); +static void Decode(php_hash_uint32 *, const unsigned char *, unsigned int); static unsigned char PADDING[64] = { @@ -188,22 +188,22 @@ static unsigned char PADDING[64] = Rotation is separate from addition to prevent recomputation. */ #define FF(a, b, c, d, x, s, ac) { \ - (a) += F ((b), (c), (d)) + (x) + (php_uint32)(ac); \ + (a) += F ((b), (c), (d)) + (x) + (php_hash_uint32)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define GG(a, b, c, d, x, s, ac) { \ - (a) += G ((b), (c), (d)) + (x) + (php_uint32)(ac); \ + (a) += G ((b), (c), (d)) + (x) + (php_hash_uint32)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define HH(a, b, c, d, x, s, ac) { \ - (a) += H ((b), (c), (d)) + (x) + (php_uint32)(ac); \ + (a) += H ((b), (c), (d)) + (x) + (php_hash_uint32)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define II(a, b, c, d, x, s, ac) { \ - (a) += I ((b), (c), (d)) + (x) + (php_uint32)(ac); \ + (a) += I ((b), (c), (d)) + (x) + (php_hash_uint32)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } @@ -237,10 +237,10 @@ PHP_HASH_API void PHP_MD5Update(PHP_MD5_CTX * context, const unsigned char *inpu index = (unsigned int) ((context->count[0] >> 3) & 0x3F); /* Update number of bits */ - if ((context->count[0] += ((php_uint32) inputLen << 3)) - < ((php_uint32) inputLen << 3)) + if ((context->count[0] += ((php_hash_uint32) inputLen << 3)) + < ((php_hash_uint32) inputLen << 3)) context->count[1]++; - context->count[1] += ((php_uint32) inputLen >> 29); + context->count[1] += ((php_hash_uint32) inputLen >> 29); partLen = 64 - index; @@ -299,10 +299,10 @@ PHP_HASH_API void PHP_MD5Final(unsigned char digest[16], PHP_MD5_CTX * context) * MD5 basic transformation. Transforms state based on block. */ static void MD5Transform(state, block) -php_uint32 state[4]; +php_hash_uint32 state[4]; const unsigned char block[64]; { - php_uint32 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; + php_hash_uint32 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; Decode(x, block, 64); @@ -389,12 +389,12 @@ const unsigned char block[64]; /* }}} */ /* {{{ Encode - Encodes input (php_uint32) into output (unsigned char). Assumes len is + Encodes input (php_hash_uint32) into output (unsigned char). Assumes len is a multiple of 4. */ static void Encode(output, input, len) unsigned char *output; -php_uint32 *input; +php_hash_uint32 *input; unsigned int len; { unsigned int i, j; @@ -409,19 +409,19 @@ unsigned int len; /* }}} */ /* {{{ Decode - Decodes input (unsigned char) into output (php_uint32). Assumes len is + Decodes input (unsigned char) into output (php_hash_uint32). Assumes len is a multiple of 4. */ static void Decode(output, input, len) -php_uint32 *output; +php_hash_uint32 *output; const unsigned char *input; unsigned int len; { unsigned int i, j; for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((php_uint32) input[j]) | (((php_uint32) input[j + 1]) << 8) | - (((php_uint32) input[j + 2]) << 16) | (((php_uint32) input[j + 3]) << 24); + output[i] = ((php_hash_uint32) input[j]) | (((php_hash_uint32) input[j + 1]) << 8) | + (((php_hash_uint32) input[j + 2]) << 16) | (((php_hash_uint32) input[j + 3]) << 24); } /* }}} */ diff --git a/ext/hash/hash_ripemd.c b/ext/hash/hash_ripemd.c index 8c9d313cb4..bccbe1fdd7 100644 --- a/ext/hash/hash_ripemd.c +++ b/ext/hash/hash_ripemd.c @@ -81,9 +81,9 @@ PHP_HASH_API void PHP_RIPEMD160Init(PHP_RIPEMD160_CTX * context) #define F3(x,y,z) (((x) & (z)) | ((y) & (~(z)))) #define F4(x,y,z) ((x) ^ ((y) | (~(z)))) -static php_uint32 K_values[5] = { 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E }; -static php_uint32 KK_values[4] = { 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x00000000 }; -static php_uint32 KK160_values[5] = { 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000 }; +static php_hash_uint32 K_values[5] = { 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E }; +static php_hash_uint32 KK_values[4] = { 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x00000000 }; +static php_hash_uint32 KK160_values[5] = { 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000 }; #define K(n) K_values[ (n) >> 4] #define KK(n) KK_values[(n) >> 4] @@ -122,27 +122,27 @@ static unsigned char SS[80] = { #define ROL(n, x) (((x) << n) | ((x) >> (32 - n))) /* {{{ RIPEMDDecode - Decodes input (unsigned char) into output (php_uint32). Assumes len is + Decodes input (unsigned char) into output (php_hash_uint32). Assumes len is a multiple of 4. */ -static void RIPEMDDecode(php_uint32 *output, const unsigned char *input, unsigned int len) +static void RIPEMDDecode(php_hash_uint32 *output, const unsigned char *input, unsigned int len) { unsigned int i, j; for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((php_uint32) input[j + 0]) | (((php_uint32) input[j + 1]) << 8) | - (((php_uint32) input[j + 2]) << 16) | (((php_uint32) input[j + 3]) << 24); + output[i] = ((php_hash_uint32) input[j + 0]) | (((php_hash_uint32) input[j + 1]) << 8) | + (((php_hash_uint32) input[j + 2]) << 16) | (((php_hash_uint32) input[j + 3]) << 24); } /* }}} */ /* {{{ RIPEMD128Transform * ripemd128 basic transformation. Transforms state based on block. */ -static void RIPEMD128Transform(php_uint32 state[4], const unsigned char block[64]) +static void RIPEMD128Transform(php_hash_uint32 state[4], const unsigned char block[64]) { - php_uint32 a = state[0], b = state[1], c = state[2], d = state[3]; - php_uint32 aa = state[0], bb = state[1], cc = state[2], dd = state[3]; - php_uint32 tmp, x[16]; + php_hash_uint32 a = state[0], b = state[1], c = state[2], d = state[3]; + php_hash_uint32 aa = state[0], bb = state[1], cc = state[2], dd = state[3]; + php_hash_uint32 tmp, x[16]; int j; RIPEMDDecode(x, block, 64); @@ -199,10 +199,10 @@ PHP_HASH_API void PHP_RIPEMD128Update(PHP_RIPEMD128_CTX * context, const unsigne index = (unsigned int) ((context->count[0] >> 3) & 0x3F); /* Update number of bits */ - if ((context->count[0] += ((php_uint32) inputLen << 3)) < ((php_uint32) inputLen << 3)) { + if ((context->count[0] += ((php_hash_uint32) inputLen << 3)) < ((php_hash_uint32) inputLen << 3)) { context->count[1]++; } - context->count[1] += ((php_uint32) inputLen >> 29); + context->count[1] += ((php_hash_uint32) inputLen >> 29); partLen = 64 - index; @@ -229,11 +229,11 @@ PHP_HASH_API void PHP_RIPEMD128Update(PHP_RIPEMD128_CTX * context, const unsigne /* {{{ RIPEMD160Transform * ripemd160 basic transformation. Transforms state based on block. */ -static void RIPEMD160Transform(php_uint32 state[5], const unsigned char block[64]) +static void RIPEMD160Transform(php_hash_uint32 state[5], const unsigned char block[64]) { - php_uint32 a = state[0], b = state[1], c = state[2], d = state[3], e = state[4]; - php_uint32 aa = state[0], bb = state[1], cc = state[2], dd = state[3], ee = state[4]; - php_uint32 tmp, x[16]; + php_hash_uint32 a = state[0], b = state[1], c = state[2], d = state[3], e = state[4]; + php_hash_uint32 aa = state[0], bb = state[1], cc = state[2], dd = state[3], ee = state[4]; + php_hash_uint32 tmp, x[16]; int j; RIPEMDDecode(x, block, 64); @@ -298,10 +298,10 @@ PHP_HASH_API void PHP_RIPEMD160Update(PHP_RIPEMD160_CTX * context, const unsigne index = (unsigned int) ((context->count[0] >> 3) & 0x3F); /* Update number of bits */ - if ((context->count[0] += ((php_uint32) inputLen << 3)) < ((php_uint32) inputLen << 3)) { + if ((context->count[0] += ((php_hash_uint32) inputLen << 3)) < ((php_hash_uint32) inputLen << 3)) { context->count[1]++; } - context->count[1] += ((php_uint32) inputLen >> 29); + context->count[1] += ((php_hash_uint32) inputLen >> 29); partLen = 64 - index; @@ -333,10 +333,10 @@ static unsigned char PADDING[64] = }; /* {{{ RIPEMDEncode - Encodes input (php_uint32) into output (unsigned char). Assumes len is + Encodes input (php_hash_uint32) into output (unsigned char). Assumes len is a multiple of 4. */ -static void RIPEMDEncode(unsigned char *output, php_uint32 *input, unsigned int len) +static void RIPEMDEncode(unsigned char *output, php_hash_uint32 *input, unsigned int len) { unsigned int i, j; diff --git a/ext/hash/hash_salsa.c b/ext/hash/hash_salsa.c index 6657fcc650..28e94920b1 100644 --- a/ext/hash/hash_salsa.c +++ b/ext/hash/hash_salsa.c @@ -43,7 +43,7 @@ D.J.Bernstein */ -static void Salsa10(php_uint32 x[16], php_uint32 in[16]) +static void Salsa10(php_hash_uint32 x[16], php_hash_uint32 in[16]) { int i; @@ -90,7 +90,7 @@ static void Salsa10(php_uint32 x[16], php_uint32 in[16]) D.J.Bernstein */ -static void Salsa20(php_uint32 x[16], php_uint32 in[16]) +static void Salsa20(php_hash_uint32 x[16], php_hash_uint32 in[16]) { int i; @@ -120,15 +120,15 @@ static void Salsa20(php_uint32 x[16], php_uint32 in[16]) static inline void SalsaTransform(PHP_SALSA_CTX *context, const unsigned char input[64]) { - php_uint32 i, j, a[16]; + php_hash_uint32 i, j, a[16]; #if 0 fprintf(stderr, "> INPUT: %.*s\n", 64, input); #endif for (i = 0, j = 0; j < 64; i++, j += 4) { - a[i] = ((php_uint32) input[j + 3]) | (((php_uint32) input[j + 2]) << 8) | - (((php_uint32) input[j + 1]) << 16) | (((php_uint32) input[j]) << 24); + a[i] = ((php_hash_uint32) input[j + 3]) | (((php_hash_uint32) input[j + 2]) << 8) | + (((php_hash_uint32) input[j + 1]) << 16) | (((php_hash_uint32) input[j]) << 24); } if (!context->init) { @@ -178,7 +178,7 @@ PHP_HASH_API void PHP_SALSAUpdate(PHP_SALSA_CTX *context, const unsigned char *i PHP_HASH_API void PHP_SALSAFinal(unsigned char digest[64], PHP_SALSA_CTX *context) { - php_uint32 i, j; + php_hash_uint32 i, j; if (context->length) { SalsaTransform(context, context->buffer); diff --git a/ext/hash/hash_sha.c b/ext/hash/hash_sha.c index 75d283bb28..b6d9e89bcb 100644 --- a/ext/hash/hash_sha.c +++ b/ext/hash/hash_sha.c @@ -22,16 +22,6 @@ #include "php_hash.h" #include "php_hash_sha.h" -#if defined(SIZEOF_LONG) && SIZEOF_LONG >= 8 -#define L64(n) (n) -#else -# ifdef PHP_WIN32 -#define L64(n) (n##i64) -# else -#define L64(n) (n##LL) -# endif -#endif - static unsigned char PADDING[128] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -45,10 +35,10 @@ static unsigned char PADDING[128] = }; /* {{{ SHAEncode32 - Encodes input (php_uint32) into output (unsigned char). Assumes len is + Encodes input (php_hash_uint32) into output (unsigned char). Assumes len is a multiple of 4. */ -static void SHAEncode32(unsigned char *output, php_uint32 *input, unsigned int len) +static void SHAEncode32(unsigned char *output, php_hash_uint32 *input, unsigned int len) { unsigned int i, j; @@ -63,16 +53,16 @@ static void SHAEncode32(unsigned char *output, php_uint32 *input, unsigned int l /* {{{ SHADecode32 - Decodes input (unsigned char) into output (php_uint32). Assumes len is + Decodes input (unsigned char) into output (php_hash_uint32). Assumes len is a multiple of 4. */ -static void SHADecode32(php_uint32 *output, const unsigned char *input, unsigned int len) +static void SHADecode32(php_hash_uint32 *output, const unsigned char *input, unsigned int len) { unsigned int i, j; for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((php_uint32) input[j + 3]) | (((php_uint32) input[j + 2]) << 8) | - (((php_uint32) input[j + 1]) << 16) | (((php_uint32) input[j]) << 24); + output[i] = ((php_hash_uint32) input[j + 3]) | (((php_hash_uint32) input[j + 2]) << 8) | + (((php_hash_uint32) input[j + 1]) << 16) | (((php_hash_uint32) input[j]) << 24); } /* }}} */ @@ -188,22 +178,22 @@ PHP_FUNCTION(sha1_file) /* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. */ #define FF(a, b, c, d, e, w) { \ - (e) += F ((b), (c), (d)) + (w) + (php_uint32)(0x5A827999); \ + (e) += F ((b), (c), (d)) + (w) + (php_hash_uint32)(0x5A827999); \ (e) += ROTATE_LEFT ((a), 5); \ (b) = ROTATE_LEFT((b), 30); \ } #define GG(a, b, c, d, e, w) { \ - (e) += G ((b), (c), (d)) + (w) + (php_uint32)(0x6ED9EBA1); \ + (e) += G ((b), (c), (d)) + (w) + (php_hash_uint32)(0x6ED9EBA1); \ (e) += ROTATE_LEFT ((a), 5); \ (b) = ROTATE_LEFT((b), 30); \ } #define HH(a, b, c, d, e, w) { \ - (e) += H ((b), (c), (d)) + (w) + (php_uint32)(0x8F1BBCDC); \ + (e) += H ((b), (c), (d)) + (w) + (php_hash_uint32)(0x8F1BBCDC); \ (e) += ROTATE_LEFT ((a), 5); \ (b) = ROTATE_LEFT((b), 30); \ } #define II(a, b, c, d, e, w) { \ - (e) += I ((b), (c), (d)) + (w) + (php_uint32)(0xCA62C1D6); \ + (e) += I ((b), (c), (d)) + (w) + (php_hash_uint32)(0xCA62C1D6); \ (e) += ROTATE_LEFT ((a), 5); \ (b) = ROTATE_LEFT((b), 30); \ } @@ -228,10 +218,10 @@ PHP_HASH_API void PHP_SHA1Init(PHP_SHA1_CTX * context) /* {{{ SHA1Transform * SHA1 basic transformation. Transforms state based on block. */ -static void SHA1Transform(php_uint32 state[5], const unsigned char block[64]) +static void SHA1Transform(php_hash_uint32 state[5], const unsigned char block[64]) { - php_uint32 a = state[0], b = state[1], c = state[2]; - php_uint32 d = state[3], e = state[4], x[16], tmp; + php_hash_uint32 a = state[0], b = state[1], c = state[2]; + php_hash_uint32 d = state[3], e = state[4], x[16], tmp; SHADecode32(x, block, 64); @@ -348,10 +338,10 @@ PHP_HASH_API void PHP_SHA1Update(PHP_SHA1_CTX * context, const unsigned char *in index = (unsigned int) ((context->count[0] >> 3) & 0x3F); /* Update number of bits */ - if ((context->count[0] += ((php_uint32) inputLen << 3)) - < ((php_uint32) inputLen << 3)) + if ((context->count[0] += ((php_hash_uint32) inputLen << 3)) + < ((php_hash_uint32) inputLen << 3)) context->count[1]++; - context->count[1] += ((php_uint32) inputLen >> 29); + context->count[1] += ((php_hash_uint32) inputLen >> 29); partLen = 64 - index; @@ -443,7 +433,7 @@ php_hash_ops php_hash_sha256_ops = { /* OM1 */ #define SHA256_F5(x) (ROTR32(17,(x)) ^ ROTR32(19,(x)) ^ SHR(10,(x))) -static php_uint32 SHA256_K[64] = { +static php_hash_uint32 SHA256_K[64] = { 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, @@ -475,11 +465,11 @@ PHP_HASH_API void PHP_SHA256Init(PHP_SHA256_CTX * context) /* {{{ SHA256Transform * SHA256 basic transformation. Transforms state based on block. */ -static void SHA256Transform(php_uint32 state[8], const unsigned char block[64]) +static void SHA256Transform(php_hash_uint32 state[8], const unsigned char block[64]) { - php_uint32 a = state[0], b = state[1], c = state[2], d = state[3]; - php_uint32 e = state[4], f = state[5], g = state[6], h = state[7]; - php_uint32 x[16], T1, T2, W[64]; + php_hash_uint32 a = state[0], b = state[1], c = state[2], d = state[3]; + php_hash_uint32 e = state[4], f = state[5], g = state[6], h = state[7]; + php_hash_uint32 x[16], T1, T2, W[64]; int i; SHADecode32(x, block, 64); @@ -526,10 +516,10 @@ PHP_HASH_API void PHP_SHA256Update(PHP_SHA256_CTX * context, const unsigned char index = (unsigned int) ((context->count[0] >> 3) & 0x3F); /* Update number of bits */ - if ((context->count[0] += ((php_uint32) inputLen << 3)) < ((php_uint32) inputLen << 3)) { + if ((context->count[0] += ((php_hash_uint32) inputLen << 3)) < ((php_hash_uint32) inputLen << 3)) { context->count[1]++; } - context->count[1] += ((php_uint32) inputLen >> 29); + context->count[1] += ((php_hash_uint32) inputLen >> 29); partLen = 64 - index; diff --git a/ext/hash/hash_snefru.c b/ext/hash/hash_snefru.c index edc8d04161..6b1b57b538 100644 --- a/ext/hash/hash_snefru.c +++ b/ext/hash/hash_snefru.c @@ -33,7 +33,7 @@ #endif #if DBG_SNEFRU -void ph(php_uint32 h[16]) +void ph(php_hash_uint32 h[16]) { int i; for (i = 0; i < 16; i++) @@ -41,12 +41,12 @@ void ph(php_uint32 h[16]) } #endif -static inline void Snefru(php_uint32 input[16]) +static inline void Snefru(php_hash_uint32 input[16]) { static int shifts[4] = {16, 8, 16, 24}; int b, index, rshift, lshift; - const php_uint32 *t0,*t1; - php_uint32 SBE,B00,B01,B02,B03,B04,B05,B06,B07,B08,B09,B10,B11,B12,B13,B14,B15; + const php_hash_uint32 *t0,*t1; + php_hash_uint32 SBE,B00,B01,B02,B03,B04,B05,B06,B07,B08,B09,B10,B11,B12,B13,B14,B15; B00 = input[0]; B01 = input[1]; @@ -129,7 +129,7 @@ static inline void SnefruTransform(PHP_SNEFRU_CTX *context, const unsigned char ((input[i+2] & 0xff) << 8) | (input[i+3] & 0xff); } Snefru(context->state); - memset(&context->state[8], 0, sizeof(php_uint32) * 8); + memset(&context->state[8], 0, sizeof(php_hash_uint32) * 8); } PHP_HASH_API void PHP_SNEFRUInit(PHP_SNEFRU_CTX *context) @@ -137,7 +137,7 @@ PHP_HASH_API void PHP_SNEFRUInit(PHP_SNEFRU_CTX *context) memset(context, 0, sizeof(*context)); } -static const php_uint32 MAX32 = 0xffffffffLU; +static const php_hash_uint32 MAX32 = 0xffffffffLU; PHP_HASH_API void PHP_SNEFRUUpdate(PHP_SNEFRU_CTX *context, const unsigned char *input, size_t len) { @@ -173,7 +173,7 @@ PHP_HASH_API void PHP_SNEFRUUpdate(PHP_SNEFRU_CTX *context, const unsigned char PHP_HASH_API void PHP_SNEFRUFinal(unsigned char digest[32], PHP_SNEFRU_CTX *context) { - php_uint32 i, j; + php_hash_uint32 i, j; if (context->length) { SnefruTransform(context, context->buffer); diff --git a/ext/hash/hash_tiger.c b/ext/hash/hash_tiger.c index 57edac3cc5..aa0f12f896 100644 --- a/ext/hash/hash_tiger.c +++ b/ext/hash/hash_tiger.c @@ -32,13 +32,13 @@ #define round(a,b,c,x,mul) \ c ^= x; \ a -= t1[(unsigned char)(c)] ^ \ - t2[(unsigned char)(((php_uint32)(c))>>(2*8))] ^ \ + t2[(unsigned char)(((php_hash_uint32)(c))>>(2*8))] ^ \ t3[(unsigned char)((c)>>(4*8))] ^ \ - t4[(unsigned char)(((php_uint32)((c)>>(4*8)))>>(2*8))] ; \ - b += t4[(unsigned char)(((php_uint32)(c))>>(1*8))] ^ \ - t3[(unsigned char)(((php_uint32)(c))>>(3*8))] ^ \ - t2[(unsigned char)(((php_uint32)((c)>>(4*8)))>>(1*8))] ^ \ - t1[(unsigned char)(((php_uint32)((c)>>(4*8)))>>(3*8))]; \ + t4[(unsigned char)(((php_hash_uint32)((c)>>(4*8)))>>(2*8))] ; \ + b += t4[(unsigned char)(((php_hash_uint32)(c))>>(1*8))] ^ \ + t3[(unsigned char)(((php_hash_uint32)(c))>>(3*8))] ^ \ + t2[(unsigned char)(((php_hash_uint32)((c)>>(4*8)))>>(1*8))] ^ \ + t1[(unsigned char)(((php_hash_uint32)((c)>>(4*8)))>>(3*8))]; \ b *= mul; #define pass(a,b,c,mul) \ diff --git a/ext/hash/hash_whirlpool.c b/ext/hash/hash_whirlpool.c index db53b289b1..2646560715 100644 --- a/ext/hash/hash_whirlpool.c +++ b/ext/hash/hash_whirlpool.c @@ -283,7 +283,7 @@ PHP_HASH_API void PHP_WHIRLPOOLUpdate(PHP_WHIRLPOOL_CTX *context, const unsigned unsigned char *bitLength = context->bitlength; int bufferBits = context->buffer.bits; int bufferPos = context->buffer.pos; - php_uint32 b, carry; + php_hash_uint32 b, carry; int i; /* @@ -291,7 +291,7 @@ PHP_HASH_API void PHP_WHIRLPOOLUpdate(PHP_WHIRLPOOL_CTX *context, const unsigned */ php_hash_uint64 value = sourceBits; for (i = 31, carry = 0; i >= 0 && (carry != 0 || value != L64(0)); i--) { - carry += bitLength[i] + ((php_uint32)value & 0xff); + carry += bitLength[i] + ((php_hash_uint32)value & 0xff); bitLength[i] = (unsigned char)carry; carry >>= 8; value >>= 8; diff --git a/ext/hash/package.xml b/ext/hash/package.xml index e410a934cf..f646d18c54 100644 --- a/ext/hash/package.xml +++ b/ext/hash/package.xml @@ -40,6 +40,7 @@ Initial Release + diff --git a/ext/hash/php_hash.h b/ext/hash/php_hash.h index 17cae45fc9..9e9a27ffaf 100644 --- a/ext/hash/php_hash.h +++ b/ext/hash/php_hash.h @@ -22,6 +22,7 @@ #define PHP_HASH_H #include "php.h" +#include "php_hash_types.h" #define PHP_HASH_EXTNAME "hash" #define PHP_HASH_EXTVER "0.1" diff --git a/ext/hash/php_hash_adler32.h b/ext/hash/php_hash_adler32.h index 297a86a410..154d3ebdad 100644 --- a/ext/hash/php_hash_adler32.h +++ b/ext/hash/php_hash_adler32.h @@ -24,7 +24,7 @@ #include "ext/standard/basic_functions.h" typedef struct { - php_uint32 state; + php_hash_uint32 state; } PHP_ADLER32_CTX; PHP_HASH_API void PHP_ADLER32Init(PHP_ADLER32_CTX *context); diff --git a/ext/hash/php_hash_crc32.h b/ext/hash/php_hash_crc32.h index cb2e1e5f79..cfb83d3986 100644 --- a/ext/hash/php_hash_crc32.h +++ b/ext/hash/php_hash_crc32.h @@ -24,7 +24,7 @@ #include "ext/standard/basic_functions.h" typedef struct { - php_uint32 state; + php_hash_uint32 state; } PHP_CRC32_CTX; PHP_HASH_API void PHP_CRC32Init(PHP_CRC32_CTX *context); diff --git a/ext/hash/php_hash_crc32_tables.h b/ext/hash/php_hash_crc32_tables.h index 1f023aff8f..a9cb87ab54 100644 --- a/ext/hash/php_hash_crc32_tables.h +++ b/ext/hash/php_hash_crc32_tables.h @@ -18,7 +18,7 @@ /* $Id$ */ -static const php_uint32 crc32_table[] = { 0x0, +static const php_hash_uint32 crc32_table[] = { 0x0, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, @@ -72,7 +72,7 @@ static const php_uint32 crc32_table[] = { 0x0, 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 }; -static const php_uint32 crc32b_table[] = { +static const php_hash_uint32 crc32b_table[] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, diff --git a/ext/hash/php_hash_gost.h b/ext/hash/php_hash_gost.h index eea91fcf84..ba9f63dab1 100644 --- a/ext/hash/php_hash_gost.h +++ b/ext/hash/php_hash_gost.h @@ -25,8 +25,8 @@ /* GOST context */ typedef struct { - php_uint32 state[16]; - php_uint32 count[2]; + php_hash_uint32 state[16]; + php_hash_uint32 count[2]; unsigned char length; unsigned char buffer[32]; } PHP_GOST_CTX; diff --git a/ext/hash/php_hash_gost_tables.h b/ext/hash/php_hash_gost_tables.h index 51d85fa828..5d05e593cb 100644 --- a/ext/hash/php_hash_gost_tables.h +++ b/ext/hash/php_hash_gost_tables.h @@ -1,4 +1,4 @@ -static const php_uint32 tables[4][256] = { +static const php_hash_uint32 tables[4][256] = { { /* table 1 */ 0x00072000LU, 0x00075000LU, 0x00074800LU, 0x00071000LU, 0x00076800LU, 0x00074000LU, 0x00070000LU, 0x00077000LU, 0x00073000LU, 0x00075800LU, 0x00070800LU, 0x00076000LU, 0x00073800LU, 0x00077800LU, 0x00072800LU, 0x00071800LU, diff --git a/ext/hash/php_hash_haval.h b/ext/hash/php_hash_haval.h index 67b640cf1a..bf0749ea99 100644 --- a/ext/hash/php_hash_haval.h +++ b/ext/hash/php_hash_haval.h @@ -24,13 +24,13 @@ #include "ext/standard/basic_functions.h" /* HAVAL context. */ typedef struct { - php_uint32 state[8]; - php_uint32 count[2]; + php_hash_uint32 state[8]; + php_hash_uint32 count[2]; unsigned char buffer[128]; char passes; short output; - void (*Transform)(php_uint32 state[8], const unsigned char block[128]); + void (*Transform)(php_hash_uint32 state[8], const unsigned char block[128]); } PHP_HAVAL_CTX; #define PHP_HASH_HAVAL_INIT_DECL(p,b) PHP_HASH_API void PHP_##p##HAVAL##b##Init(PHP_HAVAL_CTX *); \ diff --git a/ext/hash/php_hash_md.h b/ext/hash/php_hash_md.h index 9dea33033a..d0229d7a9e 100644 --- a/ext/hash/php_hash_md.h +++ b/ext/hash/php_hash_md.h @@ -61,8 +61,8 @@ #include "ext/standard/basic_functions.h" /* MD5 context. */ typedef struct { - php_uint32 state[4]; /* state (ABCD) */ - php_uint32 count[2]; /* number of bits, modulo 2^64 (lsb first) */ + php_hash_uint32 state[4]; /* state (ABCD) */ + php_hash_uint32 count[2]; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer[64]; /* input buffer */ } PHP_MD5_CTX; diff --git a/ext/hash/php_hash_ripemd.h b/ext/hash/php_hash_ripemd.h index f6880b93f6..2dfb21cd53 100644 --- a/ext/hash/php_hash_ripemd.h +++ b/ext/hash/php_hash_ripemd.h @@ -24,14 +24,14 @@ /* RIPEMD context. */ typedef struct { - php_uint32 state[4]; /* state (ABCD) */ - php_uint32 count[2]; /* number of bits, modulo 2^64 (lsb first) */ + php_hash_uint32 state[4]; /* state (ABCD) */ + php_hash_uint32 count[2]; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer[64]; /* input buffer */ } PHP_RIPEMD128_CTX; typedef struct { - php_uint32 state[5]; /* state (ABCD) */ - php_uint32 count[2]; /* number of bits, modulo 2^64 (lsb first) */ + php_hash_uint32 state[5]; /* state (ABCD) */ + php_hash_uint32 count[2]; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer[64]; /* input buffer */ } PHP_RIPEMD160_CTX; diff --git a/ext/hash/php_hash_salsa.h b/ext/hash/php_hash_salsa.h index 3b23148f4d..f6297711c0 100644 --- a/ext/hash/php_hash_salsa.h +++ b/ext/hash/php_hash_salsa.h @@ -25,11 +25,11 @@ /* SALSA context */ typedef struct { - php_uint32 state[16]; + php_hash_uint32 state[16]; unsigned char init:1; unsigned char length:7; unsigned char buffer[64]; - void (*Transform)(php_uint32 state[16], php_uint32 data[16]); + void (*Transform)(php_hash_uint32 state[16], php_hash_uint32 data[16]); } PHP_SALSA_CTX; #define PHP_SALSAInit PHP_SALSA20Init diff --git a/ext/hash/php_hash_sha.h b/ext/hash/php_hash_sha.h index 7ff2094125..480392c82a 100644 --- a/ext/hash/php_hash_sha.h +++ b/ext/hash/php_hash_sha.h @@ -36,8 +36,8 @@ /* SHA1 context. */ typedef struct { - php_uint32 state[5]; /* state (ABCD) */ - php_uint32 count[2]; /* number of bits, modulo 2^64 */ + php_hash_uint32 state[5]; /* state (ABCD) */ + php_hash_uint32 count[2]; /* number of bits, modulo 2^64 */ unsigned char buffer[64]; /* input buffer */ } PHP_SHA1_CTX; @@ -52,8 +52,8 @@ PHP_FUNCTION(sha1_file); /* SHA256 context. */ typedef struct { - php_uint32 state[8]; /* state */ - php_uint32 count[2]; /* number of bits, modulo 2^64 */ + php_hash_uint32 state[8]; /* state */ + php_hash_uint32 count[2]; /* number of bits, modulo 2^64 */ unsigned char buffer[64]; /* input buffer */ } PHP_SHA256_CTX; @@ -61,16 +61,6 @@ PHP_HASH_API void PHP_SHA256Init(PHP_SHA256_CTX *); PHP_HASH_API void PHP_SHA256Update(PHP_SHA256_CTX *, const unsigned char *, unsigned int); PHP_HASH_API void PHP_SHA256Final(unsigned char[32], PHP_SHA256_CTX *); -#if defined(SIZEOF_LONG) && SIZEOF_LONG >= 8 -typedef unsigned long php_hash_uint64; -#else -# ifdef PHP_WIN32 -typedef unsigned __int64 php_hash_uint64; -# else -typedef unsigned long long php_hash_uint64; -# endif -#endif - /* SHA384 context */ typedef struct { php_hash_uint64 state[8]; /* state */ diff --git a/ext/hash/php_hash_snefru.h b/ext/hash/php_hash_snefru.h index b5c76f7865..f8c71ba66d 100644 --- a/ext/hash/php_hash_snefru.h +++ b/ext/hash/php_hash_snefru.h @@ -29,8 +29,8 @@ /* SNEFRU context */ typedef struct { - php_uint32 state[16]; - php_uint32 count[2]; + php_hash_uint32 state[16]; + php_hash_uint32 count[2]; unsigned char length; unsigned char buffer[32]; } PHP_SNEFRU_CTX; diff --git a/ext/hash/php_hash_snefru_tables.h b/ext/hash/php_hash_snefru_tables.h index 3d5ed4e10b..a2e572be57 100644 --- a/ext/hash/php_hash_snefru_tables.h +++ b/ext/hash/php_hash_snefru_tables.h @@ -18,7 +18,7 @@ /* $Id$ */ -static const php_uint32 tables[16][256]= { +static const php_hash_uint32 tables[16][256]= { { /* Start of S Box 0 */ diff --git a/ext/hash/php_hash_tiger.h b/ext/hash/php_hash_tiger.h index e3291c3ce1..5e909cb7fc 100644 --- a/ext/hash/php_hash_tiger.h +++ b/ext/hash/php_hash_tiger.h @@ -21,21 +21,6 @@ #ifndef PHP_HASH_TIGER_H #define PHP_HASH_TIGER_H -#include "ext/standard/basic_functions.h" - -#if defined(SIZEOF_LONG) && (SIZEOF_LONG >= 8) -# define L64(n) (n##L) -typedef unsigned long php_hash_uint64; -#else -# ifdef PHP_WIN32 -# define L64(n) (n##i64) -typedef unsigned __int64 php_hash_uint64; -# else -# define L64(n) (n##LL) -typedef unsigned long long php_hash_uint64; -# endif -#endif - /* TIGER context */ typedef struct { php_hash_uint64 state[3]; diff --git a/ext/hash/php_hash_types.h b/ext/hash/php_hash_types.h new file mode 100644 index 0000000000..869a121c57 --- /dev/null +++ b/ext/hash/php_hash_types.h @@ -0,0 +1,40 @@ + +/* $Id$ */ + +#ifndef PHP_HASH_TYPES_H +#define PHP_HASH_TYPES_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifndef _MSC_VER +#if SIZEOF_LONG == 8 +#define L64(x) x +typedef unsigned long php_hash_uint64; +#if SIZEOF_INT == 4 +typedef unsigned int php_hash_uint32; +#elif SIZEOF_SHORT == 4 +typedef unsigned short php_hash_uint32; +#else +#error "Need a 32bit integer type" +#endif +#elif SIZEOF_LONG_LONG == 8 +#define L64(x) x##LL +typedef unsigned long long php_hash_uint64; +#if SIZEOF_INT == 4 +typedef unsigned int php_hash_uint32; +#elif SIZEOF_LONG == 4 +typedef unsigned long php_hash_uint32; +#else +#error "Need a 32bit integer type" +#endif +#endif +#else +#define L64(x) x##i64 +typedef unsigned __int64 php_hash_uint64; +typedef unsigned __int32 php_hash_uint32; +#endif + +#endif + diff --git a/ext/hash/php_hash_whirlpool.h b/ext/hash/php_hash_whirlpool.h index 42e5793e14..56be370778 100644 --- a/ext/hash/php_hash_whirlpool.h +++ b/ext/hash/php_hash_whirlpool.h @@ -21,21 +21,6 @@ #ifndef PHP_HASH_WHIRLPOOL_H #define PHP_HASH_WHIRLPOOL_H -#include "ext/standard/basic_functions.h" - -#if defined(SIZEOF_LONG) && (SIZEOF_LONG >= 8) -# define L64(n) (n##L) -typedef unsigned long php_hash_uint64; -#else -# ifdef PHP_WIN32 -# define L64(n) (n##i64) -typedef unsigned __int64 php_hash_uint64; -# else -# define L64(n) (n##LL) -typedef unsigned long long php_hash_uint64; -# endif -#endif - /* WHIRLPOOL context */ typedef struct { php_hash_uint64 state[8]; -- 2.50.1