bd71e489660516840e25b2482fd0a3b29b327964
[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 _FR_MD4_H
10 #define _FR_MD4_H
11
12 #include <freeradius-devel/ident.h>
13 RCSIDH(md4_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 void fr_md4_calc (unsigned char *, const unsigned char *, unsigned int);
30
31 #ifndef WITH_OPENSSL_MD4
32 /*  The below was retrieved from
33  *  http://www.openbsd.org/cgi-bin/cvsweb/src/include/md4.h?rev=1.12
34  *  With the following changes: uint64_t => uint32_t[2]
35  *  Commented out #include <sys/cdefs.h>
36  *  Commented out the __BEGIN and __END _DECLS, and the __attributes.
37  *  Commented out MD4End, MD4File, MD4Data
38  *  Commented out header file protection #ifndef,#define,#endif
39  */
40
41 /*      $OpenBSD: md4.h,v 1.12 2004/04/28 16:54:00 millert Exp $        */
42
43 /*
44  * This code implements the MD4 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  * Todd C. Miller modified the MD5 code to do MD4 based on RFC 1186.
49  *
50  * Equivalent code is available from RSA Data Security, Inc.
51  * This code has been tested against that, and is equivalent,
52  * except that you don't need to include two pages of legalese
53  * with every copy.
54  */
55
56 /*#ifndef _MD4_H_*/
57 /*#define _MD4_H_*/
58
59 #define MD4_BLOCK_LENGTH                64
60 #define MD4_DIGEST_LENGTH               16
61 #define MD4_DIGEST_STRING_LENGTH        (MD4_DIGEST_LENGTH * 2 + 1)
62
63 typedef struct FR_MD4Context {
64         uint32_t state[4];                      /* state */
65         uint32_t count[2];                      /* number of bits, mod 2^64 */
66         uint8_t buffer[MD4_BLOCK_LENGTH];       /* input buffer */
67 } FR_MD4_CTX;
68
69 /*#include <sys/cdefs.h>*/
70
71 /*__BEGIN_DECLS*/
72 void     fr_MD4Init(FR_MD4_CTX *);
73 void     fr_MD4Update(FR_MD4_CTX *, const uint8_t *, size_t)
74 /*              __attribute__((__bounded__(__string__,2,3)))*/;
75 void     fr_MD4Final(uint8_t [MD4_DIGEST_LENGTH], FR_MD4_CTX *)
76 /*              __attribute__((__bounded__(__minbytes__,1,MD4_DIGEST_LENGTH)))*/;
77 void     fr_MD4Transform(uint32_t [4], const uint8_t [MD4_BLOCK_LENGTH])
78 /*              __attribute__((__bounded__(__minbytes__,1,4)))
79                 __attribute__((__bounded__(__minbytes__,2,MD4_BLOCK_LENGTH)))*/;
80 /*__END_DECLS*/
81 #else  /* WITH_OPENSSL_MD4 */
82
83 #include <openssl/md4.h>
84
85 #define FR_MD4_CTX      MD4_CTX
86 #define fr_MD4Init      MD4_Init
87 #define fr_MD4Update    MD4_Update
88 #define fr_MD4Final     MD4_Final
89 #define fr_MD4Transform MD4_Transform
90 #endif
91
92 #endif /* _FR_MD4_H */