Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5496 | leency | 1 | /** |
2 | * \file md4.h |
||
3 | * |
||
4 | * \brief MD4 message digest algorithm (hash function) |
||
5 | * |
||
6 | * Copyright (C) 2006-2010, Brainspark B.V. |
||
7 | * |
||
8 | * This file is part of PolarSSL (http://www.polarssl.org) |
||
9 | * Lead Maintainer: Paul Bakker |
||
10 | * |
||
11 | * All rights reserved. |
||
12 | * |
||
13 | * This program is free software; you can redistribute it and/or modify |
||
14 | * it under the terms of the GNU General Public License as published by |
||
15 | * the Free Software Foundation; either version 2 of the License, or |
||
16 | * (at your option) any later version. |
||
17 | * |
||
18 | * This program is distributed in the hope that it will be useful, |
||
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
21 | * GNU General Public License for more details. |
||
22 | * |
||
23 | * You should have received a copy of the GNU General Public License along |
||
24 | * with this program; if not, write to the Free Software Foundation, Inc., |
||
25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||
26 | */ |
||
27 | #ifndef POLARSSL_MD4_H |
||
28 | #define POLARSSL_MD4_H |
||
29 | |||
30 | #include |
||
31 | |||
32 | #ifdef _MSC_VER |
||
33 | #include |
||
34 | typedef UINT32 uint32_t; |
||
35 | #else |
||
36 | #include |
||
37 | #endif |
||
38 | |||
39 | #define POLARSSL_ERR_MD4_FILE_IO_ERROR -0x0072 /**< Read/write error in file. */ |
||
40 | |||
41 | /** |
||
42 | * \brief MD4 context structure |
||
43 | */ |
||
44 | typedef struct |
||
45 | { |
||
46 | uint32_t total[2]; /*!< number of bytes processed */ |
||
47 | uint32_t state[4]; /*!< intermediate digest state */ |
||
48 | unsigned char buffer[64]; /*!< data block being processed */ |
||
49 | |||
50 | unsigned char ipad[64]; /*!< HMAC: inner padding */ |
||
51 | unsigned char opad[64]; /*!< HMAC: outer padding */ |
||
52 | } |
||
53 | md4_context; |
||
54 | |||
55 | #ifdef __cplusplus |
||
56 | extern "C" { |
||
57 | #endif |
||
58 | |||
59 | /** |
||
60 | * \brief MD4 context setup |
||
61 | * |
||
62 | * \param ctx context to be initialized |
||
63 | */ |
||
64 | void md4_starts( md4_context *ctx ); |
||
65 | |||
66 | /** |
||
67 | * \brief MD4 process buffer |
||
68 | * |
||
69 | * \param ctx MD4 context |
||
70 | * \param input buffer holding the data |
||
71 | * \param ilen length of the input data |
||
72 | */ |
||
73 | void md4_update( md4_context *ctx, const unsigned char *input, size_t ilen ); |
||
74 | |||
75 | /** |
||
76 | * \brief MD4 final digest |
||
77 | * |
||
78 | * \param ctx MD4 context |
||
79 | * \param output MD4 checksum result |
||
80 | */ |
||
81 | void md4_finish( md4_context *ctx, unsigned char output[16] ); |
||
82 | |||
83 | /** |
||
84 | * \brief Output = MD4( input buffer ) |
||
85 | * |
||
86 | * \param input buffer holding the data |
||
87 | * \param ilen length of the input data |
||
88 | * \param output MD4 checksum result |
||
89 | */ |
||
90 | void md4( const unsigned char *input, size_t ilen, unsigned char output[16] ); |
||
91 | |||
92 | /** |
||
93 | * \brief Output = MD4( file contents ) |
||
94 | * |
||
95 | * \param path input file name |
||
96 | * \param output MD4 checksum result |
||
97 | * |
||
98 | * \return 0 if successful, or POLARSSL_ERR_MD4_FILE_IO_ERROR |
||
99 | */ |
||
100 | int md4_file( const char *path, unsigned char output[16] ); |
||
101 | |||
102 | /** |
||
103 | * \brief MD4 HMAC context setup |
||
104 | * |
||
105 | * \param ctx HMAC context to be initialized |
||
106 | * \param key HMAC secret key |
||
107 | * \param keylen length of the HMAC key |
||
108 | */ |
||
109 | void md4_hmac_starts( md4_context *ctx, const unsigned char *key, size_t keylen ); |
||
110 | |||
111 | /** |
||
112 | * \brief MD4 HMAC process buffer |
||
113 | * |
||
114 | * \param ctx HMAC context |
||
115 | * \param input buffer holding the data |
||
116 | * \param ilen length of the input data |
||
117 | */ |
||
118 | void md4_hmac_update( md4_context *ctx, const unsigned char *input, size_t ilen ); |
||
119 | |||
120 | /** |
||
121 | * \brief MD4 HMAC final digest |
||
122 | * |
||
123 | * \param ctx HMAC context |
||
124 | * \param output MD4 HMAC checksum result |
||
125 | */ |
||
126 | void md4_hmac_finish( md4_context *ctx, unsigned char output[16] ); |
||
127 | |||
128 | /** |
||
129 | * \brief MD4 HMAC context reset |
||
130 | * |
||
131 | * \param ctx HMAC context to be reset |
||
132 | */ |
||
133 | void md4_hmac_reset( md4_context *ctx ); |
||
134 | |||
135 | /** |
||
136 | * \brief Output = HMAC-MD4( hmac key, input buffer ) |
||
137 | * |
||
138 | * \param key HMAC secret key |
||
139 | * \param keylen length of the HMAC key |
||
140 | * \param input buffer holding the data |
||
141 | * \param ilen length of the input data |
||
142 | * \param output HMAC-MD4 result |
||
143 | */ |
||
144 | void md4_hmac( const unsigned char *key, size_t keylen, |
||
145 | const unsigned char *input, size_t ilen, |
||
146 | unsigned char output[16] ); |
||
147 | |||
148 | /** |
||
149 | * \brief Checkup routine |
||
150 | * |
||
151 | * \return 0 if successful, or 1 if the test failed |
||
152 | */ |
||
153 | int md4_self_test( int verbose ); |
||
154 | |||
155 | #ifdef __cplusplus |
||
156 | } |
||
157 | #endif |
||
158 | |||
159 | #endif /* md4.h */>>>>>> |