Module: sip-router Branch: master Commit: 82a2e00d83e3c991e5275c78d6e75cf28e780e62 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=82a2e00d...
Author: Henning Westerholt henning.westerholt@1und1.de Committer: Henning Westerholt henning.westerholt@1und1.de Date: Fri Jun 24 00:25:09 2011 +0200
doxygen: convert existing documentation to doxygen, small whitespace cleanup
---
md5.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++---------------- md5.h | 76 +++++++++++++++++++++++++++++++++++------------------ 2 files changed, 119 insertions(+), 49 deletions(-)
diff --git a/md5.c b/md5.c index 92f3273..1c628df 100644 --- a/md5.c +++ b/md5.c @@ -23,7 +23,7 @@
/*! * \file - * \brief SIP-router core :: + * \brief SIP-router core :: md5 hash support * \ingroup core * Module: \ref core */ @@ -34,9 +34,11 @@ #include "md5.h"
-/* Constants for MD5Transform routine. +/** + * \brief Constants for MD5Transform routine. */
+/*@{ */ #define S11 7 #define S12 12 #define S13 17 @@ -53,6 +55,7 @@ #define S42 10 #define S43 15 #define S44 21 +/*@} */
static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char [64])); static void Encode PROTO_LIST @@ -66,20 +69,30 @@ 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. +/** + * \brief 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. +/** + * \brief 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. +/** + * \brief FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. + * + * FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. + * 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)); \ @@ -100,11 +113,16 @@ Rotation is separate from addition to prevent recomputation. (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } +/*@} */
-/* MD5 initialization. Begins an MD5 operation, writing a new context. +/** + * \brief MD5 context initialization + * + * MD5 context initialization. Begins an MD5 operation, writing a new context. + * \param context initialized context */ void MD5Init (context) -MD5_CTX *context; /* context */ +MD5_CTX *context; { context->count[0] = context->count[1] = 0; /* Load magic initialization constants. @@ -115,14 +133,20 @@ MD5_CTX *context; /* context */ context->state[3] = 0x10325476; }
-/* MD5 block update operation. Continues an MD5 message-digest - operation, processing another message block, and updating the - context. +/** + * \brief MD5 block update operation + * + * MD5 block update operation. Continues an MD5 message-digest + * operation, processing another message block, and updating the + * context. + * \param context context + * \param input input block + * \param inputLen length of input block */ void MD5Update (context, input, inputLen) -MD5_CTX *context; /* context */ -unsigned char *input; /* input block */ -unsigned int inputLen; /* length of input block */ +MD5_CTX *context; +unsigned char *input; +unsigned int inputLen; { unsigned int i, index, partLen;
@@ -159,12 +183,17 @@ unsigned int inputLen; /* length of input block */ inputLen-i); }
-/* MD5 finalization. Ends an MD5 message-digest operation, writing the - the message digest and zeroizing the context. +/** + * \brief MD5 finalization + * + * MD5 finalization. Ends an MD5 message-digest operation, writing the + * the message digest and zeroizing the context. + * \param digest message digest + * \param context context */ void MD5Final (digest, context) -unsigned char digest[16]; /* message digest */ -MD5_CTX *context; /* context */ +unsigned char digest[16]; +MD5_CTX *context; { unsigned char bits[8]; unsigned int index, padLen; @@ -189,7 +218,12 @@ MD5_CTX *context; /* context */ memset ((POINTER)context, 0, sizeof (*context)); }
-/* MD5 basic transformation. Transforms state based on block. +/** + * \brief MD5 basic transformation + * + * MD5 basic transformation. Transforms state based on block. + * \param state transformed state + * \param block block input for transformation */ static void MD5Transform (state, block) UINT4 state[4]; @@ -281,8 +315,14 @@ unsigned char block[64]; memset ((POINTER)x, 0, sizeof (x)); }
-/* Encodes input (UINT4) into output (unsigned char). Assumes len is - a multiple of 4. +/** + * \brief Encodes input (UINT4) into output (unsigned char) + * + * Encodes input (UINT4) into output (unsigned char). Assumes len is + * a multiple of 4. + * \param output output character + * \param input integer input + * \param len length of output */ static void Encode (output, input, len) unsigned char *output; @@ -299,8 +339,14 @@ unsigned int len; } }
-/* Decodes input (unsigned char) into output (UINT4). Assumes len is - a multiple of 4. +/** + * \brief Decodes input (unsigned char) into output (UINT4) + * + * Decodes input (unsigned char) into output (UINT4). Assumes len is + * a multiple of 4. + * \param output output integer + * \param input input character + * \param len length of input */ static void Decode (output, input, len) UINT4 *output; diff --git a/md5.h b/md5.h index ac53da7..756a96e 100644 --- a/md5.h +++ b/md5.h @@ -1,28 +1,24 @@ -/* MD5.H - header file for MD5C.C - * $Id$ - */ - - -/* 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. */
#ifndef MD5_H @@ -30,16 +26,44 @@ documentation and/or software.
#include "md5global.h"
-/* MD5 context. */ +/** + * \brief MD5 context + */ typedef struct { UINT4 state[4]; /* state (ABCD) */ UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer[64]; /* input buffer */ } MD5_CTX;
+/** + * \brief MD5 context initialization + * + * MD5 context initialization. Begins an MD5 operation, writing a new context. + * \param context initialized context + */ void MD5Init PROTO_LIST ((MD5_CTX *)); + +/** + * \brief MD5 block update operation + * + * MD5 block update operation. Continues an MD5 message-digest + * operation, processing another message block, and updating the + * context. + * \param context context + * \param input input block + * \param inputLen length of input block + */ void MD5Update PROTO_LIST ((MD5_CTX *, unsigned char *, unsigned int)); + + /** + * \brief MD5 finalization + * + * MD5 finalization. Ends an MD5 message-digest operation, writing the + * the message digest and zeroizing the context. + * \param digest message digest + * \param context context + */ void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *));
#endif /* MD5_H */