summaryrefslogtreecommitdiff
path: root/ext/standard/md5.c
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2000-08-21 10:10:31 +0000
committerSascha Schumann <sas@php.net>2000-08-21 10:10:31 +0000
commit6ce467dc134478dd876013c76a36d60a068f55ad (patch)
tree80eede3a93e7b97b073fcb9a519b5951b9bd0ad0 /ext/standard/md5.c
parent19741cc37ad1773a6d4b59392991ff7b90899775 (diff)
downloadphp-git-6ce467dc134478dd876013c76a36d60a068f55ad.tar.gz
Get rid of php_global.h and the associated data types UINT4/_POINTER.
We use php_uint32 now globally. Also removed K&R support from md5.[ch].
Diffstat (limited to 'ext/standard/md5.c')
-rw-r--r--ext/standard/md5.c79
1 files changed, 24 insertions, 55 deletions
diff --git a/ext/standard/md5.c b/ext/standard/md5.c
index 6cb896806b..64bfeb0549 100644
--- a/ext/standard/md5.c
+++ b/ext/standard/md5.c
@@ -104,13 +104,9 @@ PHP_NAMED_FUNCTION(php_if_md5)
#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] =
{
@@ -134,22 +130,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) + (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); \
}
@@ -180,18 +176,18 @@ void PHP_MD5Update(PHP_MD5_CTX * context, const unsigned char *input,
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)
@@ -202,8 +198,8 @@ void PHP_MD5Update(PHP_MD5_CTX * context, const unsigned char *input,
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);
}
@@ -232,16 +228,16 @@ void PHP_MD5Final(unsigned char digest[16], PHP_MD5_CTX * context)
/* 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);
@@ -323,15 +319,15 @@ const unsigned char 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;
@@ -344,46 +340,19 @@ unsigned int len;
}
}
-/* 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);
}
/*