Port patch from branch_1_1 to the HEAD
[freeradius.git] / src / include / md4.h
1 /*
2  * md4.h        Structures and prototypes for md4.
3  *
4  * Version:     $Id$
5  * License:             LGPL, but largely derived from a public domain source.
6  *
7  */
8
9 #ifndef _LRAD_MD4_H
10 #define _LRAD_MD4_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 /*
27  *  FreeRADIUS defines to ensure globally unique MD4 function names,
28  *  so that we don't pick up other MD4 libraries.
29  */
30 #define MD4_CTX         librad_MD4_CTX
31 #define MD4Init         librad_MD4Init
32 #define MD4Update       librad_MD4Update
33 #define MD4Final        librad_MD4Final
34
35 void md4_calc (unsigned char *, const unsigned char *, unsigned int);
36
37 /*  The below was retrieved from
38  *  http://www.openbsd.org/cgi-bin/cvsweb/src/include/md4.h?rev=1.12
39  *  With the following changes: uint64_t => uint32_t[2]
40  *  Commented out #include <sys/cdefs.h>
41  *  Commented out the __BEGIN and __END _DECLS, and the __attributes.
42  *  Commented out MD4End, MD4File, MD4Data
43  *  Commented out header file protection #ifndef,#define,#endif
44  */
45
46 /*      $OpenBSD: md4.h,v 1.12 2004/04/28 16:54:00 millert Exp $        */
47
48 /*
49  * This code implements the MD4 message-digest algorithm.
50  * The algorithm is due to Ron Rivest.  This code was
51  * written by Colin Plumb in 1993, no copyright is claimed.
52  * This code is in the public domain; do with it what you wish.
53  * Todd C. Miller modified the MD5 code to do MD4 based on RFC 1186.
54  *
55  * Equivalent code is available from RSA Data Security, Inc.
56  * This code has been tested against that, and is equivalent,
57  * except that you don't need to include two pages of legalese
58  * with every copy.
59  */
60
61 /*#ifndef _MD4_H_*/
62 /*#define _MD4_H_*/
63
64 #define MD4_BLOCK_LENGTH                64
65 #define MD4_DIGEST_LENGTH               16
66 #define MD4_DIGEST_STRING_LENGTH        (MD4_DIGEST_LENGTH * 2 + 1)
67
68 typedef struct MD4Context {
69         uint32_t state[4];                      /* state */
70         uint32_t count[2];                      /* number of bits, mod 2^64 */
71         uint8_t buffer[MD4_BLOCK_LENGTH];       /* input buffer */
72 } MD4_CTX;
73
74 /*#include <sys/cdefs.h>*/
75
76 /*__BEGIN_DECLS*/
77 void     MD4Init(MD4_CTX *);
78 void     MD4Update(MD4_CTX *, const uint8_t *, size_t)
79 /*              __attribute__((__bounded__(__string__,2,3)))*/;
80 void     MD4Final(uint8_t [MD4_DIGEST_LENGTH], MD4_CTX *)
81 /*              __attribute__((__bounded__(__minbytes__,1,MD4_DIGEST_LENGTH)))*/;
82 void     MD4Transform(uint32_t [4], const uint8_t [MD4_BLOCK_LENGTH])
83 /*              __attribute__((__bounded__(__minbytes__,1,4)))
84                 __attribute__((__bounded__(__minbytes__,2,MD4_BLOCK_LENGTH)))*/;
85 /*char  *MD4End(MD4_CTX *, char [MD4_DIGEST_STRING_LENGTH])
86                 __attribute__((__bounded__(__minbytes__,2,MD4_DIGEST_STRING_LENGTH)));
87 char    *MD4File(char *, char [MD4_DIGEST_STRING_LENGTH])
88                 __attribute__((__bounded__(__minbytes__,2,MD4_DIGEST_STRING_LENGTH)));
89 char    *MD4Data(const uint8_t *, size_t, char [MD4_DIGEST_STRING_LENGTH])
90                 __attribute__((__bounded__(__string__,1,2)))
91                 __attribute__((__bounded__(__minbytes__,3,MD4_DIGEST_STRING_LENGTH)));*/
92 /*__END_DECLS*/
93
94 #endif /* _LRAD_MD4_H */