masqmail

diff src/md5/md5c.c @ 10:26e34ae9a3e3

changed indention and line wrapping to a more consistent style
author meillo@marmaro.de
date Mon, 27 Oct 2008 16:23:10 +0100
parents 08114f7dcc23
children
line diff
     1.1 --- a/src/md5/md5c.c	Mon Oct 27 16:21:27 2008 +0100
     1.2 +++ b/src/md5/md5c.c	Mon Oct 27 16:23:10 2008 +0100
     1.3 @@ -45,18 +45,16 @@
     1.4  #define S43 15
     1.5  #define S44 21
     1.6  
     1.7 -static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char [64]));
     1.8 -static void Encode PROTO_LIST
     1.9 -  ((unsigned char *, UINT4 *, unsigned int));
    1.10 -static void Decode PROTO_LIST
    1.11 -  ((UINT4 *, unsigned char *, unsigned int));
    1.12 -static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int));
    1.13 -static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int));
    1.14 +static void MD5Transform PROTO_LIST((UINT4[4], unsigned char[64]));
    1.15 +static void Encode PROTO_LIST((unsigned char *, UINT4 *, unsigned int));
    1.16 +static void Decode PROTO_LIST((UINT4 *, unsigned char *, unsigned int));
    1.17 +static void MD5_memcpy PROTO_LIST((POINTER, POINTER, unsigned int));
    1.18 +static void MD5_memset PROTO_LIST((POINTER, int, unsigned int));
    1.19  
    1.20  static unsigned char PADDING[64] = {
    1.21 -  0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    1.22 -  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    1.23 -  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    1.24 +	0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    1.25 +	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    1.26 +	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    1.27  };
    1.28  
    1.29  /* F, G, H and I are basic MD5 functions.
    1.30 @@ -96,239 +94,239 @@
    1.31  
    1.32  /* MD5 initialization. Begins an MD5 operation, writing a new context.
    1.33   */
    1.34 -void MD5Init (context)
    1.35 -MD5_CTX *context;                                        /* context */
    1.36 +void
    1.37 +MD5Init(context)
    1.38 +MD5_CTX *context;  /* context */
    1.39  {
    1.40 -  context->count[0] = context->count[1] = 0;
    1.41 -  /* Load magic initialization constants.
    1.42 -*/
    1.43 -  context->state[0] = 0x67452301;
    1.44 -  context->state[1] = 0xefcdab89;
    1.45 -  context->state[2] = 0x98badcfe;
    1.46 -  context->state[3] = 0x10325476;
    1.47 +	context->count[0] = context->count[1] = 0;
    1.48 +	/* Load magic initialization constants. */
    1.49 +	context->state[0] = 0x67452301;
    1.50 +	context->state[1] = 0xefcdab89;
    1.51 +	context->state[2] = 0x98badcfe;
    1.52 +	context->state[3] = 0x10325476;
    1.53  }
    1.54  
    1.55  /* MD5 block update operation. Continues an MD5 message-digest
    1.56    operation, processing another message block, and updating the
    1.57    context.
    1.58   */
    1.59 -void MD5Update (context, input, inputLen)
    1.60 -MD5_CTX *context;                                        /* context */
    1.61 -unsigned char *input;                                /* input block */
    1.62 -unsigned int inputLen;                     /* length of input block */
    1.63 +void
    1.64 +MD5Update(context, input, inputLen)
    1.65 +MD5_CTX *context;  /* context */
    1.66 +unsigned char *input;  /* input block */
    1.67 +unsigned int inputLen;  /* length of input block */
    1.68  {
    1.69 -  unsigned int i, index, partLen;
    1.70 +	unsigned int i, index, partLen;
    1.71  
    1.72 -  /* Compute number of bytes mod 64 */
    1.73 -  index = (unsigned int)((context->count[0] >> 3) & 0x3F);
    1.74 +	/* Compute number of bytes mod 64 */
    1.75 +	index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
    1.76  
    1.77 -  /* Update number of bits */
    1.78 -  if ((context->count[0] += ((UINT4)inputLen << 3))
    1.79 -   < ((UINT4)inputLen << 3))
    1.80 - context->count[1]++;
    1.81 -  context->count[1] += ((UINT4)inputLen >> 29);
    1.82 +	/* Update number of bits */
    1.83 +	if ((context->count[0] += ((UINT4) inputLen << 3)) < ((UINT4) inputLen << 3))
    1.84 +		context->count[1]++;
    1.85 +	context->count[1] += ((UINT4) inputLen >> 29);
    1.86  
    1.87 -  partLen = 64 - index;
    1.88 +	partLen = 64 - index;
    1.89  
    1.90 -  /* Transform as many times as possible.
    1.91 -*/
    1.92 -  if (inputLen >= partLen) {
    1.93 - MD5_memcpy
    1.94 -   ((POINTER)&context->buffer[index], (POINTER)input, partLen);
    1.95 - MD5Transform (context->state, context->buffer);
    1.96 +	/* Transform as many times as possible.
    1.97 +	 */
    1.98 +	if (inputLen >= partLen) {
    1.99 +		MD5_memcpy((POINTER) & context->buffer[index], (POINTER) input, partLen);
   1.100 +		MD5Transform(context->state, context->buffer);
   1.101  
   1.102 - for (i = partLen; i + 63 < inputLen; i += 64)
   1.103 -   MD5Transform (context->state, &input[i]);
   1.104 +		for (i = partLen; i + 63 < inputLen; i += 64)
   1.105 +			MD5Transform(context->state, &input[i]);
   1.106  
   1.107 - index = 0;
   1.108 -  }
   1.109 -  else
   1.110 - i = 0;
   1.111 +		index = 0;
   1.112 +	} else
   1.113 +		i = 0;
   1.114  
   1.115 -  /* Buffer remaining input */
   1.116 -  MD5_memcpy
   1.117 - ((POINTER)&context->buffer[index], (POINTER)&input[i],
   1.118 -  inputLen-i);
   1.119 +	/* Buffer remaining input */
   1.120 +	MD5_memcpy((POINTER) & context->buffer[index], (POINTER) & input[i], inputLen - i);
   1.121  }
   1.122  
   1.123  /* MD5 finalization. Ends an MD5 message-digest operation, writing the
   1.124    the message digest and zeroizing the context.
   1.125   */
   1.126 -void MD5Final (digest, context)
   1.127 -unsigned char digest[16];                         /* message digest */
   1.128 -MD5_CTX *context;                                       /* context */
   1.129 +void
   1.130 +MD5Final(digest, context)
   1.131 +unsigned char digest[16];  /* message digest */
   1.132 +MD5_CTX *context;  /* context */
   1.133  {
   1.134 -  unsigned char bits[8];
   1.135 -  unsigned int index, padLen;
   1.136 +	unsigned char bits[8];
   1.137 +	unsigned int index, padLen;
   1.138  
   1.139 -  /* Save number of bits */
   1.140 -  Encode (bits, context->count, 8);
   1.141 +	/* Save number of bits */
   1.142 +	Encode(bits, context->count, 8);
   1.143  
   1.144 -  /* Pad out to 56 mod 64.
   1.145 -*/
   1.146 -  index = (unsigned int)((context->count[0] >> 3) & 0x3f);
   1.147 -  padLen = (index < 56) ? (56 - index) : (120 - index);
   1.148 -  MD5Update (context, PADDING, padLen);
   1.149 +	/* Pad out to 56 mod 64.
   1.150 +	 */
   1.151 +	index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
   1.152 +	padLen = (index < 56) ? (56 - index) : (120 - index);
   1.153 +	MD5Update(context, PADDING, padLen);
   1.154  
   1.155 -  /* Append length (before padding) */
   1.156 -  MD5Update (context, bits, 8);
   1.157 +	/* Append length (before padding) */
   1.158 +	MD5Update(context, bits, 8);
   1.159  
   1.160 -  /* Store state in digest */
   1.161 -  Encode (digest, context->state, 16);
   1.162 +	/* Store state in digest */
   1.163 +	Encode(digest, context->state, 16);
   1.164  
   1.165 -  /* Zeroize sensitive information.
   1.166 -*/
   1.167 -  MD5_memset ((POINTER)context, 0, sizeof (*context));
   1.168 +	/* Zeroize sensitive information.
   1.169 +	 */
   1.170 +	MD5_memset((POINTER) context, 0, sizeof(*context));
   1.171  }
   1.172  
   1.173  /* MD5 basic transformation. Transforms state based on block.
   1.174   */
   1.175 -static void MD5Transform (state, block)
   1.176 +static void
   1.177 +MD5Transform(state, block)
   1.178  UINT4 state[4];
   1.179  unsigned char block[64];
   1.180  {
   1.181 -  UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
   1.182 +	UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
   1.183  
   1.184 -  Decode (x, block, 64);
   1.185 +	Decode(x, block, 64);
   1.186  
   1.187 -  /* Round 1 */
   1.188 -  FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
   1.189 -  FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
   1.190 -  FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
   1.191 -  FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
   1.192 -  FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
   1.193 -  FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
   1.194 -  FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
   1.195 -  FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
   1.196 -  FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
   1.197 -  FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
   1.198 -  FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
   1.199 -  FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
   1.200 -  FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
   1.201 -  FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
   1.202 -  FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
   1.203 -  FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
   1.204 +	/* Round 1 */
   1.205 +	FF(a, b, c, d, x[0], S11, 0xd76aa478);  /* 1 */
   1.206 +	FF(d, a, b, c, x[1], S12, 0xe8c7b756);  /* 2 */
   1.207 +	FF(c, d, a, b, x[2], S13, 0x242070db);  /* 3 */
   1.208 +	FF(b, c, d, a, x[3], S14, 0xc1bdceee);  /* 4 */
   1.209 +	FF(a, b, c, d, x[4], S11, 0xf57c0faf);  /* 5 */
   1.210 +	FF(d, a, b, c, x[5], S12, 0x4787c62a);  /* 6 */
   1.211 +	FF(c, d, a, b, x[6], S13, 0xa8304613);  /* 7 */
   1.212 +	FF(b, c, d, a, x[7], S14, 0xfd469501);  /* 8 */
   1.213 +	FF(a, b, c, d, x[8], S11, 0x698098d8);  /* 9 */
   1.214 +	FF(d, a, b, c, x[9], S12, 0x8b44f7af);  /* 10 */
   1.215 +	FF(c, d, a, b, x[10], S13, 0xffff5bb1);  /* 11 */
   1.216 +	FF(b, c, d, a, x[11], S14, 0x895cd7be);  /* 12 */
   1.217 +	FF(a, b, c, d, x[12], S11, 0x6b901122);  /* 13 */
   1.218 +	FF(d, a, b, c, x[13], S12, 0xfd987193);  /* 14 */
   1.219 +	FF(c, d, a, b, x[14], S13, 0xa679438e);  /* 15 */
   1.220 +	FF(b, c, d, a, x[15], S14, 0x49b40821);  /* 16 */
   1.221  
   1.222 - /* Round 2 */
   1.223 -  GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
   1.224 -  GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
   1.225 -  GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
   1.226 -  GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
   1.227 -  GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
   1.228 -  GG (d, a, b, c, x[10], S22,  0x2441453); /* 22 */
   1.229 -  GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
   1.230 -  GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
   1.231 -  GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
   1.232 -  GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
   1.233 -  GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
   1.234 -  GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
   1.235 -  GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
   1.236 -  GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
   1.237 -  GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
   1.238 -  GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
   1.239 +	/* Round 2 */
   1.240 +	GG(a, b, c, d, x[1], S21, 0xf61e2562);  /* 17 */
   1.241 +	GG(d, a, b, c, x[6], S22, 0xc040b340);  /* 18 */
   1.242 +	GG(c, d, a, b, x[11], S23, 0x265e5a51);  /* 19 */
   1.243 +	GG(b, c, d, a, x[0], S24, 0xe9b6c7aa);  /* 20 */
   1.244 +	GG(a, b, c, d, x[5], S21, 0xd62f105d);  /* 21 */
   1.245 +	GG(d, a, b, c, x[10], S22, 0x2441453);  /* 22 */
   1.246 +	GG(c, d, a, b, x[15], S23, 0xd8a1e681);  /* 23 */
   1.247 +	GG(b, c, d, a, x[4], S24, 0xe7d3fbc8);  /* 24 */
   1.248 +	GG(a, b, c, d, x[9], S21, 0x21e1cde6);  /* 25 */
   1.249 +	GG(d, a, b, c, x[14], S22, 0xc33707d6);  /* 26 */
   1.250 +	GG(c, d, a, b, x[3], S23, 0xf4d50d87);  /* 27 */
   1.251 +	GG(b, c, d, a, x[8], S24, 0x455a14ed);  /* 28 */
   1.252 +	GG(a, b, c, d, x[13], S21, 0xa9e3e905);  /* 29 */
   1.253 +	GG(d, a, b, c, x[2], S22, 0xfcefa3f8);  /* 30 */
   1.254 +	GG(c, d, a, b, x[7], S23, 0x676f02d9);  /* 31 */
   1.255 +	GG(b, c, d, a, x[12], S24, 0x8d2a4c8a);  /* 32 */
   1.256  
   1.257 -  /* Round 3 */
   1.258 -  HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
   1.259 -  HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
   1.260 -  HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
   1.261 -  HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
   1.262 -  HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
   1.263 -  HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
   1.264 -  HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
   1.265 -  HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
   1.266 -  HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
   1.267 -  HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
   1.268 -  HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
   1.269 -  HH (b, c, d, a, x[ 6], S34,  0x4881d05); /* 44 */
   1.270 -  HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
   1.271 -  HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
   1.272 -  HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
   1.273 -  HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
   1.274 +	/* Round 3 */
   1.275 +	HH(a, b, c, d, x[5], S31, 0xfffa3942);  /* 33 */
   1.276 +	HH(d, a, b, c, x[8], S32, 0x8771f681);  /* 34 */
   1.277 +	HH(c, d, a, b, x[11], S33, 0x6d9d6122);  /* 35 */
   1.278 +	HH(b, c, d, a, x[14], S34, 0xfde5380c);  /* 36 */
   1.279 +	HH(a, b, c, d, x[1], S31, 0xa4beea44);  /* 37 */
   1.280 +	HH(d, a, b, c, x[4], S32, 0x4bdecfa9);  /* 38 */
   1.281 +	HH(c, d, a, b, x[7], S33, 0xf6bb4b60);  /* 39 */
   1.282 +	HH(b, c, d, a, x[10], S34, 0xbebfbc70);  /* 40 */
   1.283 +	HH(a, b, c, d, x[13], S31, 0x289b7ec6);  /* 41 */
   1.284 +	HH(d, a, b, c, x[0], S32, 0xeaa127fa);  /* 42 */
   1.285 +	HH(c, d, a, b, x[3], S33, 0xd4ef3085);  /* 43 */
   1.286 +	HH(b, c, d, a, x[6], S34, 0x4881d05);  /* 44 */
   1.287 +	HH(a, b, c, d, x[9], S31, 0xd9d4d039);  /* 45 */
   1.288 +	HH(d, a, b, c, x[12], S32, 0xe6db99e5);  /* 46 */
   1.289 +	HH(c, d, a, b, x[15], S33, 0x1fa27cf8);  /* 47 */
   1.290 +	HH(b, c, d, a, x[2], S34, 0xc4ac5665);  /* 48 */
   1.291  
   1.292 -  /* Round 4 */
   1.293 -  II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
   1.294 -  II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
   1.295 -  II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
   1.296 -  II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
   1.297 -  II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
   1.298 -  II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
   1.299 -  II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
   1.300 -  II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
   1.301 -  II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
   1.302 -  II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
   1.303 -  II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
   1.304 -  II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
   1.305 -  II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
   1.306 -  II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
   1.307 -  II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
   1.308 -  II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
   1.309 +	/* Round 4 */
   1.310 +	II(a, b, c, d, x[0], S41, 0xf4292244);  /* 49 */
   1.311 +	II(d, a, b, c, x[7], S42, 0x432aff97);  /* 50 */
   1.312 +	II(c, d, a, b, x[14], S43, 0xab9423a7);  /* 51 */
   1.313 +	II(b, c, d, a, x[5], S44, 0xfc93a039);  /* 52 */
   1.314 +	II(a, b, c, d, x[12], S41, 0x655b59c3);  /* 53 */
   1.315 +	II(d, a, b, c, x[3], S42, 0x8f0ccc92);  /* 54 */
   1.316 +	II(c, d, a, b, x[10], S43, 0xffeff47d);  /* 55 */
   1.317 +	II(b, c, d, a, x[1], S44, 0x85845dd1);  /* 56 */
   1.318 +	II(a, b, c, d, x[8], S41, 0x6fa87e4f);  /* 57 */
   1.319 +	II(d, a, b, c, x[15], S42, 0xfe2ce6e0);  /* 58 */
   1.320 +	II(c, d, a, b, x[6], S43, 0xa3014314);  /* 59 */
   1.321 +	II(b, c, d, a, x[13], S44, 0x4e0811a1);  /* 60 */
   1.322 +	II(a, b, c, d, x[4], S41, 0xf7537e82);  /* 61 */
   1.323 +	II(d, a, b, c, x[11], S42, 0xbd3af235);  /* 62 */
   1.324 +	II(c, d, a, b, x[2], S43, 0x2ad7d2bb);  /* 63 */
   1.325 +	II(b, c, d, a, x[9], S44, 0xeb86d391);  /* 64 */
   1.326  
   1.327 -  state[0] += a;
   1.328 -  state[1] += b;
   1.329 -  state[2] += c;
   1.330 -  state[3] += d;
   1.331 +	state[0] += a;
   1.332 +	state[1] += b;
   1.333 +	state[2] += c;
   1.334 +	state[3] += d;
   1.335  
   1.336 -  /* Zeroize sensitive information.
   1.337 -*/
   1.338 -  MD5_memset ((POINTER)x, 0, sizeof (x));
   1.339 +	/* Zeroize sensitive information. */
   1.340 +	MD5_memset((POINTER) x, 0, sizeof(x));
   1.341  }
   1.342  
   1.343  /* Encodes input (UINT4) into output (unsigned char). Assumes len is
   1.344    a multiple of 4.
   1.345   */
   1.346 -static void Encode (output, input, len)
   1.347 +static void
   1.348 +Encode(output, input, len)
   1.349  unsigned char *output;
   1.350  UINT4 *input;
   1.351  unsigned int len;
   1.352  {
   1.353 -  unsigned int i, j;
   1.354 +	unsigned int i, j;
   1.355  
   1.356 -  for (i = 0, j = 0; j < len; i++, j += 4) {
   1.357 - output[j] = (unsigned char)(input[i] & 0xff);
   1.358 - output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
   1.359 - output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
   1.360 - output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
   1.361 -  }
   1.362 +	for (i = 0, j = 0; j < len; i++, j += 4) {
   1.363 +		output[j] = (unsigned char) (input[i] & 0xff);
   1.364 +		output[j + 1] = (unsigned char) ((input[i] >> 8) & 0xff);
   1.365 +		output[j + 2] = (unsigned char) ((input[i] >> 16) & 0xff);
   1.366 +		output[j + 3] = (unsigned char) ((input[i] >> 24) & 0xff);
   1.367 +	}
   1.368  }
   1.369  
   1.370  /* Decodes input (unsigned char) into output (UINT4). Assumes len is
   1.371    a multiple of 4.
   1.372   */
   1.373 -static void Decode (output, input, len)
   1.374 +static void
   1.375 +Decode(output, input, len)
   1.376  UINT4 *output;
   1.377  unsigned char *input;
   1.378  unsigned int len;
   1.379  {
   1.380 -  unsigned int i, j;
   1.381 +	unsigned int i, j;
   1.382  
   1.383 -  for (i = 0, j = 0; j < len; i++, j += 4)
   1.384 - output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
   1.385 -   (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
   1.386 +	for (i = 0, j = 0; j < len; i++, j += 4)
   1.387 +		output[i] = ((UINT4) input[j]) | (((UINT4) input[j + 1]) << 8) | (((UINT4) input[j + 2]) << 16) | (((UINT4) input[j + 3]) << 24);
   1.388  }
   1.389  
   1.390  /* Note: Replace "for loop" with standard memcpy if possible.
   1.391   */
   1.392  
   1.393 -static void MD5_memcpy (output, input, len)
   1.394 +static void
   1.395 +MD5_memcpy(output, input, len)
   1.396  POINTER output;
   1.397  POINTER input;
   1.398  unsigned int len;
   1.399  {
   1.400 -  unsigned int i;
   1.401 +	unsigned int i;
   1.402  
   1.403 -  for (i = 0; i < len; i++)
   1.404 -    output[i] = input[i];
   1.405 +	for (i = 0; i < len; i++)
   1.406 +		output[i] = input[i];
   1.407  }
   1.408  
   1.409  /* Note: Replace "for loop" with standard memset if possible.
   1.410   */
   1.411 -static void MD5_memset (output, value, len)
   1.412 +static void
   1.413 +MD5_memset(output, value, len)
   1.414  POINTER output;
   1.415  int value;
   1.416  unsigned int len;
   1.417  {
   1.418 -  unsigned int i;
   1.419 +	unsigned int i;
   1.420  
   1.421 -  for (i = 0; i < len; i++)
   1.422 - ((char *)output)[i] = (char)value;
   1.423 +	for (i = 0; i < len; i++)
   1.424 +		((char *) output)[i] = (char) value;
   1.425  }