Delete #include "autoconf.h" from other header files. It's
[freeradius.git] / src / include / md5.h
1 /*
2  * md5.h        Structures and prototypes for md5.
3  *
4  * Version:     $Id$
5  * License:             LGPL, but largely derived from a public domain source.
6  *
7  */
8
9 #ifndef _LRAD_MD5_H
10 #define _LRAD_MD5_H
11
12 #ifdef HAVE_INTTYPES_H
13 #include <inttypes.h>
14 #endif
15
16 #ifdef HAVE_SYS_TYPES_H
17 #include <sys/types.h>
18 #endif
19
20 #ifdef HAVE_STDINT_H
21 #include <stdint.h>
22 #endif
23
24 #include <string.h>
25 /*
26  *  FreeRADIUS defines to ensure globally unique MD5 function names,
27  *  so that we don't pick up vendor-specific broken MD5 libraries.
28  */
29 #define MD5_CTX         lrad_MD5_CTX
30 #define MD5Init         lrad_MD5Init
31 #define MD5Update       lrad_MD5Update
32 #define MD5Final        lrad_MD5Final
33 #define MD5Transform    lrad_MD5Transform
34
35
36 /*  The below was retrieved from
37  *  http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/crypto/md5.h?rev=1.1
38  *  With the following changes: uint64_t => uint32_t[2]
39  *  Commented out #include <sys/cdefs.h>
40  *  Commented out the __BEGIN and __END _DECLS, and the __attributes.
41  */
42
43 /*
44  * This code implements the MD5 message-digest algorithm.
45  * The algorithm is due to Ron Rivest.  This code was
46  * written by Colin Plumb in 1993, no copyright is claimed.
47  * This code is in the public domain; do with it what you wish.
48  *
49  * Equivalent code is available from RSA Data Security, Inc.
50  * This code has been tested against that, and is equivalent,
51  * except that you don't need to include two pages of legalese
52  * with every copy.
53  */
54
55 #define MD5_BLOCK_LENGTH                64
56 #define MD5_DIGEST_LENGTH               16
57
58 typedef struct lrad_MD5Context {
59         uint32_t state[4];                      /* state */
60         uint32_t count[2];                      /* number of bits, mod 2^64 */
61         uint8_t buffer[MD5_BLOCK_LENGTH];       /* input buffer */
62 } lrad_MD5_CTX;
63
64 /* include <sys/cdefs.h> */
65
66 /* __BEGIN_DECLS */
67 void     lrad_MD5Init(lrad_MD5_CTX *);
68 void     lrad_MD5Update(lrad_MD5_CTX *, const uint8_t *, size_t)
69 /*              __attribute__((__bounded__(__string__,2,3)))*/;
70 void     lrad_MD5Final(uint8_t [MD5_DIGEST_LENGTH], lrad_MD5_CTX *)
71 /*              __attribute__((__bounded__(__minbytes__,1,MD5_DIGEST_LENGTH)))*/;
72 void     lrad_MD5Transform(uint32_t [4], const uint8_t [MD5_BLOCK_LENGTH])
73 /*              __attribute__((__bounded__(__minbytes__,1,4)))*/
74 /*              __attribute__((__bounded__(__minbytes__,2,MD5_BLOCK_LENGTH)))*/;
75 /* __END_DECLS */
76
77 #endif /* _LRAD_MD5_H */