Add "extern C {...} to header files for C++ builds.
[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 _FR_MD5_H
10 #define _FR_MD5_H
11
12 #include <freeradius-devel/ident.h>
13 RCSIDH(md5_h, "$Id$")
14
15 #ifdef HAVE_INTTYPES_H
16 #include <inttypes.h>
17 #endif
18
19 #ifdef HAVE_SYS_TYPES_H
20 #include <sys/types.h>
21 #endif
22
23 #ifdef HAVE_STDINT_H
24 #include <stdint.h>
25 #endif
26
27 #include <string.h>
28
29 #ifdef WITH_OPENSSL_MD5
30 #include <openssl/md5.h>
31 #endif
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #ifndef WITH_OPENSSL_MD5
38 /*  The below was retrieved from
39  *  http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/crypto/md5.h?rev=1.1
40  *  With the following changes: uint64_t => uint32_t[2]
41  *  Commented out #include <sys/cdefs.h>
42  *  Commented out the __BEGIN and __END _DECLS, and the __attributes.
43  */
44
45 /*
46  * This code implements the MD5 message-digest algorithm.
47  * The algorithm is due to Ron Rivest.  This code was
48  * written by Colin Plumb in 1993, no copyright is claimed.
49  * This code is in the public domain; do with it what you wish.
50  *
51  * Equivalent code is available from RSA Data Security, Inc.
52  * This code has been tested against that, and is equivalent,
53  * except that you don't need to include two pages of legalese
54  * with every copy.
55  */
56
57 #define MD5_BLOCK_LENGTH                64
58 #define MD5_DIGEST_LENGTH               16
59
60 typedef struct FR_MD5Context {
61         uint32_t state[4];                      /* state */
62         uint32_t count[2];                      /* number of bits, mod 2^64 */
63         uint8_t buffer[MD5_BLOCK_LENGTH];       /* input buffer */
64 } FR_MD5_CTX;
65
66 /* include <sys/cdefs.h> */
67
68 /* __BEGIN_DECLS */
69 void     fr_MD5Init(FR_MD5_CTX *);
70 void     fr_MD5Update(FR_MD5_CTX *, const uint8_t *, size_t)
71 /*              __attribute__((__bounded__(__string__,2,3)))*/;
72 void     fr_MD5Final(uint8_t [MD5_DIGEST_LENGTH], FR_MD5_CTX *)
73 /*              __attribute__((__bounded__(__minbytes__,1,MD5_DIGEST_LENGTH)))*/;
74 void     fr_MD5Transform(uint32_t [4], const uint8_t [MD5_BLOCK_LENGTH])
75 /*              __attribute__((__bounded__(__minbytes__,1,4)))*/
76 /*              __attribute__((__bounded__(__minbytes__,2,MD5_BLOCK_LENGTH)))*/;
77 /* __END_DECLS */
78
79 #else  /* WITH_OPENSSL_HASH */
80
81 #define FR_MD5_CTX      MD5_CTX
82 #define fr_MD5Init      MD5_Init
83 #define fr_MD5Update    MD5_Update
84 #define fr_MD5Final     MD5_Final
85 #define fr_MD5Transform MD5_Transform
86 #endif
87
88 #ifdef __cplusplus
89 }
90 #endif
91
92 #endif /* _FR_MD5_H */