]> FriiDump Source - friidump.git/blob - libmultihash/md4.h
PFES-REPO-README-001: Refresh canonical documentation
[friidump.git] / libmultihash / md4.h
1 /**
2  * \file md4.h
3  */
4 #ifndef _MD4_H
5 #define _MD4_H
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 /**
12  * \brief          MD4 context structure
13  */
14 typedef struct
15 {
16     unsigned long total[2];     /*!< number of bytes processed  */
17     unsigned long state[4];     /*!< intermediate digest state  */
18     unsigned char buffer[64];   /*!< data block being processed */
19     unsigned char ipad[64];     /*!< HMAC: inner padding        */
20     unsigned char opad[64];     /*!< HMAC: outer padding        */
21 }
22 md4_context;
23
24 /**
25  * \brief          MD4 context setup
26  *
27  * \param ctx      context to be initialized
28  */
29 void md4_starts( md4_context *ctx );
30
31 /**
32  * \brief          MD4 process buffer
33  *
34  * \param ctx      MD4 context
35  * \param input    buffer holding the  data
36  * \param ilen     length of the input data
37  */
38 void md4_update( md4_context *ctx, unsigned char *input, int ilen );
39
40 /**
41  * \brief          MD4 final digest
42  *
43  * \param ctx      MD4 context
44  * \param output   MD4 checksum result
45  */
46 void md4_finish( md4_context *ctx, unsigned char *output );
47
48 /**
49  * \brief          Output = MD4( input buffer )
50  *
51  * \param input    buffer holding the  data
52  * \param ilen     length of the input data
53  * \param output   MD4 checksum result
54  */
55 void md4( unsigned char *input, int ilen,
56           unsigned char *output );
57
58 /**
59  * \brief          Output = MD4( file contents )
60  *
61  * \param path     input file name
62  * \param output   MD4 checksum result
63  *
64  * \return         0 if successful, 1 if fopen failed,
65  *                 or 2 if fread failed
66  */
67 int md4_file( char *path, unsigned char *output );
68
69 /**
70  * \brief          MD4 HMAC context setup
71  *
72  * \param ctx      HMAC context to be initialized
73  * \param key      HMAC secret key
74  * \param keylen   length of the HMAC key
75  */
76 void md4_hmac_starts( md4_context *ctx,
77                       unsigned char *key, int keylen );
78
79 /**
80  * \brief          MD4 HMAC process buffer
81  *
82  * \param ctx      HMAC context
83  * \param input    buffer holding the  data
84  * \param ilen     length of the input data
85  */
86 void md4_hmac_update( md4_context *ctx,
87                       unsigned char *input, int ilen );
88
89 /**
90  * \brief          MD4 HMAC final digest
91  *
92  * \param ctx      HMAC context
93  * \param output   MD4 HMAC checksum result
94  */
95 void md4_hmac_finish( md4_context *ctx, unsigned char *output );
96
97 /**
98  * \brief          Output = HMAC-MD4( hmac key, input buffer )
99  *
100  * \param key      HMAC secret key
101  * \param keylen   length of the HMAC key
102  * \param input    buffer holding the  data
103  * \param ilen     length of the input data
104  * \param output   HMAC-MD4 result
105  */
106 void md4_hmac( unsigned char *key, int keylen,
107                unsigned char *input, int ilen,
108                unsigned char *output );
109
110 /**
111  * \brief          Checkup routine
112  *
113  * \return         0 if successful, or 1 if the test failed
114  */
115 int md4_self_test( int verbose );
116
117 #ifdef __cplusplus
118 }
119 #endif
120
121 #endif /* md4.h */