X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fmd5.c;h=6737a3ea155a7a29787ed805ca0c2875d3a3ce0e;hp=a40d2898c3c13415361e4952b43202e1d7ac7cbe;hb=ced6090a330d3d83d0bce709f756aa3d7d65fea4;hpb=337338b404931f06f0db2119c9e145e8ca5a9860 diff --git a/uip/md5.c b/uip/md5.c index a40d289..6737a3e 100644 --- a/uip/md5.c +++ b/uip/md5.c @@ -1,40 +1,40 @@ /* - * md5.c -- md5 message digest algorithm - * taken from RFC-1321/Appendix A.3 - */ +** md5.c -- md5 message digest algorithm +** taken from RFC-1321/Appendix A.3 +*/ /* - * MD5C.C -- RSA Data Security, Inc., MD5 message-digest algorithm - */ +** MD5C.C -- RSA Data Security, Inc., MD5 message-digest algorithm +*/ /* - * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All - * rights reserved. - * - * License to copy and use this software is granted provided that it - * is identified as the "RSA Data Security, Inc. MD5 Message-Digest - * Algorithm" in all material mentioning or referencing this software - * or this function. - * - * License is also granted to make and use derivative works provided - * that such works are identified as "derived from the RSA Data - * Security, Inc. MD5 Message-Digest Algorithm" in all material - * mentioning or referencing the derived work. - * - * RSA Data Security, Inc. makes no representations concerning either - * the merchantability of this software or the suitability of this - * software for any particular purpose. It is provided "as is" - * without express or implied warranty of any kind. - * - * These notices must be retained in any copies of any part of this - * documentation and/or software. - */ +** Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All +** rights reserved. +** +** License to copy and use this software is granted provided that it +** is identified as the "RSA Data Security, Inc. MD5 Message-Digest +** Algorithm" in all material mentioning or referencing this software +** or this function. +** +** License is also granted to make and use derivative works provided +** that such works are identified as "derived from the RSA Data +** Security, Inc. MD5 Message-Digest Algorithm" in all material +** mentioning or referencing the derived work. +** +** RSA Data Security, Inc. makes no representations concerning either +** the merchantability of this software or the suitability of this +** software for any particular purpose. It is provided "as is" +** without express or implied warranty of any kind. +** +** These notices must be retained in any copies of any part of this +** documentation and/or software. +*/ #include /* - * Constants for MD5Transform routine. - */ +** Constants for MD5Transform routine. +*/ #define S11 7 #define S12 12 #define S13 17 @@ -62,20 +62,22 @@ static unsigned char PADDING[64] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -/* F, G, H and I are basic MD5 functions. - */ +/* +** F, G, H and I are basic MD5 functions. +*/ #define F(x, y, z) (((x) & (y)) | ((~x) & (z))) #define G(x, y, z) (((x) & (z)) | ((y) & (~z))) #define H(x, y, z) ((x) ^ (y) ^ (z)) #define I(x, y, z) ((y) ^ ((x) | (~z))) -/* ROTATE_LEFT rotates x left n bits. - */ +/* +** ROTATE_LEFT rotates x left n bits. +*/ #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) /* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. - * Rotation is separate from addition to prevent recomputation. - */ +** 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) = ROTATE_LEFT ((a), (s)); \ @@ -97,24 +99,27 @@ static unsigned char PADDING[64] = { (a) += (b); \ } -/* MD5 initialization. Begins an MD5 operation, writing a new context. - */ +/* +** MD5 initialization. Begins an MD5 operation, writing a new context. +*/ void MD5Init (context) MD5_CTX *context; /* context */ { context->count[0] = context->count[1] = 0; - /* Load magic initialization constants. - */ + /* + ** Load magic initialization constants. + */ context->state[0] = 0x67452301; context->state[1] = 0xefcdab89; context->state[2] = 0x98badcfe; context->state[3] = 0x10325476; } -/* MD5 block update operation. Continues an MD5 message-digest - * operation, processing another message block, and updating the - * context. - */ +/* +** MD5 block update operation. Continues an MD5 message-digest +** operation, processing another message block, and updating the +** context. +*/ void MD5Update (context, input, inputLen) MD5_CTX *context; /* context */ unsigned char *input; /* input block */ @@ -149,9 +154,9 @@ unsigned int inputLen; /* length of input block */ } /* - * MD5 finalization. Ends an MD5 message-digest operation, writing the - * the message digest and zeroizing the context. - */ +** MD5 finalization. Ends an MD5 message-digest operation, writing the +** the message digest and zeroizing the context. +*/ void MD5Final (digest, context) unsigned char digest[16]; /* message digest */ MD5_CTX *context; /* context */ @@ -162,8 +167,7 @@ MD5_CTX *context; /* context */ /* Save number of bits */ Encode (bits, context->count, 8); - /* Pad out to 56 mod 64. - */ + /* Pad out to 56 mod 64. */ index = (unsigned int)((context->count[0] >> 3) & 0x3f); padLen = (index < 56) ? (56 - index) : (120 - index); MD5Update (context, PADDING, padLen); @@ -177,8 +181,9 @@ MD5_CTX *context; /* context */ memset ((POINTER)context, 0, sizeof(*context)); } -/* MD5 basic transformation. Transforms state based on block. - */ +/* +** MD5 basic transformation. Transforms state based on block. +*/ static void MD5Transform (state, block) UINT4 state[4]; unsigned char block[64]; @@ -268,9 +273,10 @@ unsigned char block[64]; memset ((POINTER)x, 0, sizeof(x)); } -/* Encodes input (UINT4) into output (unsigned char). Assumes len is - * a multiple of 4. - */ +/* +** 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; @@ -286,9 +292,10 @@ unsigned int len; } } -/* Decodes input (unsigned char) into output (UINT4). Assumes len is - * a multiple of 4. - */ +/* +** 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;