File: md5utils.c

package info (click to toggle)
kamailio 4.2.0-2+deb8u3
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 56,276 kB
  • sloc: ansic: 552,836; xml: 166,484; sh: 8,659; makefile: 7,676; sql: 6,235; perl: 3,487; yacc: 3,428; python: 1,457; cpp: 1,219; php: 1,047; java: 449; pascal: 194; cs: 40; awk: 27
file content (69 lines) | stat: -rw-r--r-- 1,899 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * 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.
 */

/*!
 * \file
 * \brief SIP-router core :: md5 hash support
 * \ingroup core
 * Module: \ref core
 */

#include <stdio.h>
#include <time.h>
#include <string.h>
#include "md5.h"
#include "md5utils.h"
#include "dprint.h"
#include "ut.h"


/*!
  * \brief Calculate a MD5 digests over a string array
  * 
  * Calculate a MD5 digests over a string array and stores the result in the
  * destination char array. This function assumes 32 bytes in the destination
  * buffer.
  * \param dst destination
  * \param src string input array
  * \param size elements in the input array
  */
void MD5StringArray (char *dst, str src[], int size)
{
	MD5_CTX context;
	unsigned char digest[16];
 	int i;
	int len;
	char *s;

	MD5Init (&context);
	for (i=0; i<size; i++) {
		trim_len( len, s, src[i] );
		if (len > 0)
  			MD5Update (&context, s, len);
  }
  U_MD5Final (digest, &context);

  string2hex(digest, 16, dst );
  DBG("DEBUG: MD5 calculated: %.*s\n", MD5_LEN, dst );

}