1 /* @(#)md5.h	1.11 10/08/27 2008-2010 J. Schilling */
2 /*
3  * MD5 hash code taken from OpenBSD
4  *
5  * Portions Copyright (c) 2008-2010 J. Schilling
6  */
7 
8 /*	$OpenBSD: md5.h,v 1.16 2004/06/22 01:57:30 jfb Exp $	*/
9 
10 /*
11  * This code implements the MD5 message-digest algorithm.
12  * The algorithm is due to Ron Rivest.  This code was
13  * written by Colin Plumb in 1993, no copyright is claimed.
14  * This code is in the public domain; do with it what you wish.
15  *
16  * Equivalent code is available from RSA Data Security, Inc.
17  * This code has been tested against that, and is equivalent,
18  * except that you don't need to include two pages of legalese
19  * with every copy.
20  */
21 
22 #ifndef	_SCHILY_MD5_H
23 #define	_SCHILY_MD5_H
24 
25 #ifndef _SCHILY_MCONFIG_H
26 #include <schily/mconfig.h>
27 #endif
28 #include <schily/utypes.h>
29 
30 #define	MD5_BLOCK_LENGTH		64
31 #define	MD5_DIGEST_LENGTH		16
32 #define	MD5_DIGEST_STRING_LENGTH	(MD5_DIGEST_LENGTH * 2 + 1)
33 
34 typedef struct MD5Context {
35 	UInt32_t state[4];			/* state */
36 	UInt32_t count[2];			/* number of bits, mod 2^64 */
37 	UInt8_t	 buffer[MD5_BLOCK_LENGTH];	/* input buffer */
38 } MD5_CTX;
39 
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 extern void	 MD5Init	__PR((MD5_CTX *));
45 extern void	 MD5Update	__PR((MD5_CTX *, const void *, size_t));
46 extern void	 MD5Pad		__PR((MD5_CTX *));
47 extern void	 MD5Final	__PR((UInt8_t [MD5_DIGEST_LENGTH], MD5_CTX *));
48 extern void	 MD5Transform	__PR((UInt32_t [4],
49 					const UInt8_t [MD5_BLOCK_LENGTH]));
50 extern char	*MD5End		__PR((MD5_CTX *, char *));
51 extern char	*MD5File	__PR((const char *, char *));
52 extern char	*MD5FileChunk	__PR((const char *, char *, off_t, off_t));
53 extern char	*MD5Data	__PR((const UInt8_t *, size_t, char *));
54 
55 #ifdef	__cplusplus
56 }
57 #endif
58 
59 #endif /* _SCHILY_MD5_H */
60