diff options
author | Arno Töll <arno@debian.org> | 2012-11-21 23:57:42 +0100 |
---|---|---|
committer | Arno Töll <arno@debian.org> | 2012-11-21 23:57:42 +0100 |
commit | 47236ea4c1d5601fc6bea1b280d36152ec5ff32b (patch) | |
tree | 89c109c0bef460fa747a3413610034002fac1cb4 /src/md5.c | |
parent | dae92c799e85ec3b65f46da6a776e4386bc99d6c (diff) | |
download | lighttpd-47236ea4c1d5601fc6bea1b280d36152ec5ff32b.tar.gz |
Imported Upstream version 1.4.32
Diffstat (limited to 'src/md5.c')
-rw-r--r-- | src/md5.c | 51 |
1 files changed, 16 insertions, 35 deletions
@@ -24,7 +24,7 @@ documentation and/or software. */ #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif #ifndef USE_OPENSSL @@ -52,9 +52,9 @@ documentation and/or software. #define S43 15 #define S44 21 -static void MD5Transform (UINT4 [4], unsigned char [64]); +static void li_MD5Transform (UINT4 [4], const unsigned char [64]); static void Encode (unsigned char *, UINT4 *, unsigned int); -static void Decode (UINT4 *, unsigned char *, unsigned int); +static void Decode (UINT4 *, const unsigned char *, unsigned int); #ifdef HAVE_MEMCPY #define MD5_memcpy(output, input, len) memcpy((output), (input), (len)) @@ -110,8 +110,7 @@ Rotation is separate from addition to prevent recomputation. /* MD5 initialization. Begins an MD5 operation, writing a new context. */ -void MD5_Init (context) -MD5_CTX *context; /* context */ +void li_MD5_Init (li_MD5_CTX *context) { context->count[0] = context->count[1] = 0; /* Load magic initialization constants. @@ -126,12 +125,10 @@ MD5_CTX *context; /* context */ operation, processing another message block, and updating the context. */ -void MD5_Update (context, input, inputLen) -MD5_CTX *context; /* context */ -unsigned char *input; /* input block */ -unsigned int inputLen; /* length of input block */ +void li_MD5_Update (li_MD5_CTX *context, const void *_input, unsigned int inputLen) { unsigned int i, ndx, partLen; + const unsigned char *input = (const unsigned char*) _input; /* Compute number of bytes mod 64 */ ndx = (unsigned int)((context->count[0] >> 3) & 0x3F); @@ -150,10 +147,10 @@ unsigned int inputLen; /* length of input block */ if (inputLen >= partLen) { MD5_memcpy ((POINTER)&context->buffer[ndx], (POINTER)input, partLen); - MD5Transform (context->state, context->buffer); + li_MD5Transform (context->state, context->buffer); for (i = partLen; i + 63 < inputLen; i += 64) - MD5Transform (context->state, &input[i]); + li_MD5Transform (context->state, &input[i]); ndx = 0; } @@ -169,9 +166,7 @@ unsigned int inputLen; /* length of input block */ /* MD5 finalization. Ends an MD5 message-digest operation, writing the the message digest and zeroizing the context. */ -void MD5_Final (digest, context) -unsigned char digest[16]; /* message digest */ -MD5_CTX *context; /* context */ +void li_MD5_Final (unsigned char digest[16], li_MD5_CTX *context) { unsigned char bits[8]; unsigned int ndx, padLen; @@ -183,10 +178,10 @@ MD5_CTX *context; /* context */ */ ndx = (unsigned int)((context->count[0] >> 3) & 0x3f); padLen = (ndx < 56) ? (56 - ndx) : (120 - ndx); - MD5_Update (context, PADDING, padLen); + li_MD5_Update (context, PADDING, padLen); /* Append length (before padding) */ - MD5_Update (context, bits, 8); + li_MD5_Update (context, bits, 8); /* Store state in digest */ Encode (digest, context->state, 16); @@ -198,9 +193,7 @@ MD5_CTX *context; /* context */ /* MD5 basic transformation. Transforms state based on block. */ -static void MD5Transform (state, block) -UINT4 state[4]; -unsigned char block[64]; +static void li_MD5Transform (UINT4 state[4], const unsigned char block[64]) { UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; @@ -293,10 +286,7 @@ unsigned char block[64]; /* Encodes input (UINT4) into output (unsigned char). Assumes len is a multiple of 4. */ -static void Encode (output, input, len) -unsigned char *output; -UINT4 *input; -unsigned int len; +static void Encode (unsigned char *output, UINT4 *input, unsigned int len) { unsigned int i, j; @@ -311,10 +301,7 @@ unsigned int len; /* Decodes input (unsigned char) into output (UINT4). Assumes len is a multiple of 4. */ -static void Decode (output, input, len) -UINT4 *output; -unsigned char *input; -unsigned int len; +static void Decode (UINT4 *output, const unsigned char *input, unsigned int len) { unsigned int i, j; @@ -326,10 +313,7 @@ unsigned int len; /* Note: Replace "for loop" with standard memcpy if possible. */ #ifndef HAVE_MEMCPY -static void MD5_memcpy (output, input, len) -POINTER output; -POINTER input; -unsigned int len; +static void MD5_memcpy (POINTER output, POINTER input, unsigned int len) { unsigned int i; @@ -341,10 +325,7 @@ unsigned int len; /* Note: Replace "for loop" with standard memset if possible. */ #ifndef HAVE_MEMSET -static void MD5_memset (output, value, len) -POINTER output; -int value; -unsigned int len; +static void MD5_memset (POINTER output, int value, unsigned int len) { unsigned int i; |