#define S43 15
#define S44 21
-static void MD5Transform PROTO_LIST((UINT4[4], const unsigned char[64]));
-static void Encode PROTO_LIST
- ((unsigned char *, UINT4 *, unsigned int));
-static void Decode PROTO_LIST
- ((UINT4 *, const unsigned char *, unsigned int));
-static void MD5_memcpy PROTO_LIST((_POINTER, _POINTER, unsigned int));
-static void MD5_memset PROTO_LIST((_POINTER, int, unsigned int));
+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 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) + (UINT4)(ac); \
+ (a) += F ((b), (c), (d)) + (x) + (php_uint32)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
- (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) += G ((b), (c), (d)) + (x) + (php_uint32)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
- (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) += H ((b), (c), (d)) + (x) + (php_uint32)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
- (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) += I ((b), (c), (d)) + (x) + (php_uint32)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
- if ((context->count[0] += ((UINT4) inputLen << 3))
- < ((UINT4) inputLen << 3))
+ if ((context->count[0] += ((php_uint32) inputLen << 3))
+ < ((php_uint32) inputLen << 3))
context->count[1]++;
- context->count[1] += ((UINT4) inputLen >> 29);
+ context->count[1] += ((php_uint32) inputLen >> 29);
partLen = 64 - index;
/* Transform as many times as possible.
*/
if (inputLen >= partLen) {
- MD5_memcpy
- ((_POINTER) & context->buffer[index], (_POINTER) input, partLen);
+ memcpy
+ ((unsigned char*) & context->buffer[index], (unsigned char*) input, partLen);
MD5Transform(context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
i = 0;
/* Buffer remaining input */
- MD5_memcpy
- ((_POINTER) & context->buffer[index], (_POINTER) & input[i],
+ memcpy
+ ((unsigned char*) & context->buffer[index], (unsigned char*) & input[i],
inputLen - i);
}
/* Zeroize sensitive information.
*/
- MD5_memset((_POINTER) context, 0, sizeof(*context));
+ memset((unsigned char*) context, 0, sizeof(*context));
}
/* MD5 basic transformation. Transforms state based on block.
*/
static void MD5Transform(state, block)
-UINT4 state[4];
+php_uint32 state[4];
const unsigned char block[64];
{
- UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
+ php_uint32 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
Decode(x, block, 64);
state[3] += d;
/* Zeroize sensitive information. */
- MD5_memset((_POINTER) x, 0, sizeof(x));
+ memset((unsigned char*) x, 0, sizeof(x));
}
-/* Encodes input (UINT4) into output (unsigned char). Assumes len is
+/* Encodes input (php_uint32) into output (unsigned char). Assumes len is
a multiple of 4.
*/
static void Encode(output, input, len)
unsigned char *output;
-UINT4 *input;
+php_uint32 *input;
unsigned int len;
{
unsigned int i, j;
}
}
-/* Decodes input (unsigned char) into output (UINT4). Assumes len is
+/* Decodes input (unsigned char) into output (php_uint32). Assumes len is
a multiple of 4.
*/
static void Decode(output, input, len)
-UINT4 *output;
+php_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] = ((UINT4) input[j]) | (((UINT4) input[j + 1]) << 8) |
- (((UINT4) input[j + 2]) << 16) | (((UINT4) input[j + 3]) << 24);
-}
-
-/* Note: Replace "for loop" with standard memcpy if possible.
- */
-
-static void MD5_memcpy(output, input, len)
-_POINTER output;
-_POINTER input;
-unsigned int len;
-{
- unsigned int i;
-
- for (i = 0; i < len; i++)
- output[i] = input[i];
-}
-
-/* Note: Replace "for loop" with standard memset if possible.
- */
-static void MD5_memset(output, value, len)
-_POINTER output;
-int value;
-unsigned int len;
-{
- unsigned int i;
-
- for (i = 0; i < len; i++)
- ((char *) output)[i] = (char) value;
+ output[i] = ((php_uint32) input[j]) | (((php_uint32) input[j + 1]) << 8) |
+ (((php_uint32) input[j + 2]) << 16) | (((php_uint32) input[j + 3]) << 24);
}
/*
+++ /dev/null
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.02 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_02.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-/* GLOBAL.H - RSAREF types and constants
- */
-
-/* PROTOTYPES should be set to one if and only if the compiler supports
- function argument prototyping.
- The following makes PROTOTYPES default to 0 if it has not already
- been defined with C compiler flags.
- */
-#ifndef PROTOTYPES
-#define PROTOTYPES 1 /* PHP has prototypes everywhere */
-#endif
-
-/* _POINTER defines a generic pointer type */
-typedef unsigned char *_POINTER;
-
-/* UINT2 defines a two byte word */
-typedef unsigned short int UINT2;
-
-/* UINT4 defines a four byte word */
-#if SIZEOF_INT == 4
-typedef unsigned int UINT4;
-#elif SIZEOF_LONG == 4
-typedef unsigned long UINT4;
-#endif
-
-/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
- If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
- returns an empty list.
- */
-#if PROTOTYPES
-#define PROTO_LIST(list) list
-#else
-#define PROTO_LIST(list) ()
-#endif