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