Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8774 | rgimad | 1 | /** |
2 | * \file md5.h |
||
3 | * |
||
4 | * \brief MD5 message digest algorithm (hash function) |
||
5 | * |
||
6 | * \warning MD5 is considered a weak message digest and its use constitutes a |
||
7 | * security risk. We recommend considering stronger message |
||
8 | * digests instead. |
||
9 | */ |
||
10 | /* |
||
11 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved |
||
12 | * SPDX-License-Identifier: GPL-2.0 |
||
13 | * |
||
14 | * This program is free software; you can redistribute it and/or modify |
||
15 | * it under the terms of the GNU General Public License as published by |
||
16 | * the Free Software Foundation; either version 2 of the License, or |
||
17 | * (at your option) any later version. |
||
18 | * |
||
19 | * This program is distributed in the hope that it will be useful, |
||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
22 | * GNU General Public License for more details. |
||
23 | * |
||
24 | * You should have received a copy of the GNU General Public License along |
||
25 | * with this program; if not, write to the Free Software Foundation, Inc., |
||
26 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||
27 | * |
||
28 | * This file is part of mbed TLS (https://tls.mbed.org) |
||
29 | */ |
||
30 | #ifndef MBEDTLS_MD5_H |
||
31 | #define MBEDTLS_MD5_H |
||
32 | |||
33 | #if !defined(MBEDTLS_CONFIG_FILE) |
||
34 | #include "config.h" |
||
35 | #else |
||
36 | #include MBEDTLS_CONFIG_FILE |
||
37 | #endif |
||
38 | |||
39 | #include |
||
40 | #include |
||
41 | |||
42 | /* MBEDTLS_ERR_MD5_HW_ACCEL_FAILED is deprecated and should not be used. */ |
||
43 | #define MBEDTLS_ERR_MD5_HW_ACCEL_FAILED -0x002F /**< MD5 hardware accelerator failed */ |
||
44 | |||
45 | #ifdef __cplusplus |
||
46 | extern "C" { |
||
47 | #endif |
||
48 | |||
49 | #if !defined(MBEDTLS_MD5_ALT) |
||
50 | // Regular implementation |
||
51 | // |
||
52 | |||
53 | /** |
||
54 | * \brief MD5 context structure |
||
55 | * |
||
56 | * \warning MD5 is considered a weak message digest and its use |
||
57 | * constitutes a security risk. We recommend considering |
||
58 | * stronger message digests instead. |
||
59 | * |
||
60 | */ |
||
61 | typedef struct mbedtls_md5_context |
||
62 | { |
||
63 | uint32_t total[2]; /*!< number of bytes processed */ |
||
64 | uint32_t state[4]; /*!< intermediate digest state */ |
||
65 | unsigned char buffer[64]; /*!< data block being processed */ |
||
66 | } |
||
67 | mbedtls_md5_context; |
||
68 | |||
69 | #else /* MBEDTLS_MD5_ALT */ |
||
70 | #include "md5_alt.h" |
||
71 | #endif /* MBEDTLS_MD5_ALT */ |
||
72 | |||
73 | /** |
||
74 | * \brief Initialize MD5 context |
||
75 | * |
||
76 | * \param ctx MD5 context to be initialized |
||
77 | * |
||
78 | * \warning MD5 is considered a weak message digest and its use |
||
79 | * constitutes a security risk. We recommend considering |
||
80 | * stronger message digests instead. |
||
81 | * |
||
82 | */ |
||
83 | void mbedtls_md5_init( mbedtls_md5_context *ctx ); |
||
84 | |||
85 | /** |
||
86 | * \brief Clear MD5 context |
||
87 | * |
||
88 | * \param ctx MD5 context to be cleared |
||
89 | * |
||
90 | * \warning MD5 is considered a weak message digest and its use |
||
91 | * constitutes a security risk. We recommend considering |
||
92 | * stronger message digests instead. |
||
93 | * |
||
94 | */ |
||
95 | void mbedtls_md5_free( mbedtls_md5_context *ctx ); |
||
96 | |||
97 | /** |
||
98 | * \brief Clone (the state of) an MD5 context |
||
99 | * |
||
100 | * \param dst The destination context |
||
101 | * \param src The context to be cloned |
||
102 | * |
||
103 | * \warning MD5 is considered a weak message digest and its use |
||
104 | * constitutes a security risk. We recommend considering |
||
105 | * stronger message digests instead. |
||
106 | * |
||
107 | */ |
||
108 | void mbedtls_md5_clone( mbedtls_md5_context *dst, |
||
109 | const mbedtls_md5_context *src ); |
||
110 | |||
111 | /** |
||
112 | * \brief MD5 context setup |
||
113 | * |
||
114 | * \param ctx context to be initialized |
||
115 | * |
||
116 | * \return 0 if successful |
||
117 | * |
||
118 | * \warning MD5 is considered a weak message digest and its use |
||
119 | * constitutes a security risk. We recommend considering |
||
120 | * stronger message digests instead. |
||
121 | * |
||
122 | */ |
||
123 | int mbedtls_md5_starts_ret( mbedtls_md5_context *ctx ); |
||
124 | |||
125 | /** |
||
126 | * \brief MD5 process buffer |
||
127 | * |
||
128 | * \param ctx MD5 context |
||
129 | * \param input buffer holding the data |
||
130 | * \param ilen length of the input data |
||
131 | * |
||
132 | * \return 0 if successful |
||
133 | * |
||
134 | * \warning MD5 is considered a weak message digest and its use |
||
135 | * constitutes a security risk. We recommend considering |
||
136 | * stronger message digests instead. |
||
137 | * |
||
138 | */ |
||
139 | int mbedtls_md5_update_ret( mbedtls_md5_context *ctx, |
||
140 | const unsigned char *input, |
||
141 | size_t ilen ); |
||
142 | |||
143 | /** |
||
144 | * \brief MD5 final digest |
||
145 | * |
||
146 | * \param ctx MD5 context |
||
147 | * \param output MD5 checksum result |
||
148 | * |
||
149 | * \return 0 if successful |
||
150 | * |
||
151 | * \warning MD5 is considered a weak message digest and its use |
||
152 | * constitutes a security risk. We recommend considering |
||
153 | * stronger message digests instead. |
||
154 | * |
||
155 | */ |
||
156 | int mbedtls_md5_finish_ret( mbedtls_md5_context *ctx, |
||
157 | unsigned char output[16] ); |
||
158 | |||
159 | /** |
||
160 | * \brief MD5 process data block (internal use only) |
||
161 | * |
||
162 | * \param ctx MD5 context |
||
163 | * \param data buffer holding one block of data |
||
164 | * |
||
165 | * \return 0 if successful |
||
166 | * |
||
167 | * \warning MD5 is considered a weak message digest and its use |
||
168 | * constitutes a security risk. We recommend considering |
||
169 | * stronger message digests instead. |
||
170 | * |
||
171 | */ |
||
172 | int mbedtls_internal_md5_process( mbedtls_md5_context *ctx, |
||
173 | const unsigned char data[64] ); |
||
174 | |||
175 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) |
||
176 | #if defined(MBEDTLS_DEPRECATED_WARNING) |
||
177 | #define MBEDTLS_DEPRECATED __attribute__((deprecated)) |
||
178 | #else |
||
179 | #define MBEDTLS_DEPRECATED |
||
180 | #endif |
||
181 | /** |
||
182 | * \brief MD5 context setup |
||
183 | * |
||
184 | * \deprecated Superseded by mbedtls_md5_starts_ret() in 2.7.0 |
||
185 | * |
||
186 | * \param ctx context to be initialized |
||
187 | * |
||
188 | * \warning MD5 is considered a weak message digest and its use |
||
189 | * constitutes a security risk. We recommend considering |
||
190 | * stronger message digests instead. |
||
191 | * |
||
192 | */ |
||
193 | MBEDTLS_DEPRECATED void mbedtls_md5_starts( mbedtls_md5_context *ctx ); |
||
194 | |||
195 | /** |
||
196 | * \brief MD5 process buffer |
||
197 | * |
||
198 | * \deprecated Superseded by mbedtls_md5_update_ret() in 2.7.0 |
||
199 | * |
||
200 | * \param ctx MD5 context |
||
201 | * \param input buffer holding the data |
||
202 | * \param ilen length of the input data |
||
203 | * |
||
204 | * \warning MD5 is considered a weak message digest and its use |
||
205 | * constitutes a security risk. We recommend considering |
||
206 | * stronger message digests instead. |
||
207 | * |
||
208 | */ |
||
209 | MBEDTLS_DEPRECATED void mbedtls_md5_update( mbedtls_md5_context *ctx, |
||
210 | const unsigned char *input, |
||
211 | size_t ilen ); |
||
212 | |||
213 | /** |
||
214 | * \brief MD5 final digest |
||
215 | * |
||
216 | * \deprecated Superseded by mbedtls_md5_finish_ret() in 2.7.0 |
||
217 | * |
||
218 | * \param ctx MD5 context |
||
219 | * \param output MD5 checksum result |
||
220 | * |
||
221 | * \warning MD5 is considered a weak message digest and its use |
||
222 | * constitutes a security risk. We recommend considering |
||
223 | * stronger message digests instead. |
||
224 | * |
||
225 | */ |
||
226 | MBEDTLS_DEPRECATED void mbedtls_md5_finish( mbedtls_md5_context *ctx, |
||
227 | unsigned char output[16] ); |
||
228 | |||
229 | /** |
||
230 | * \brief MD5 process data block (internal use only) |
||
231 | * |
||
232 | * \deprecated Superseded by mbedtls_internal_md5_process() in 2.7.0 |
||
233 | * |
||
234 | * \param ctx MD5 context |
||
235 | * \param data buffer holding one block of data |
||
236 | * |
||
237 | * \warning MD5 is considered a weak message digest and its use |
||
238 | * constitutes a security risk. We recommend considering |
||
239 | * stronger message digests instead. |
||
240 | * |
||
241 | */ |
||
242 | MBEDTLS_DEPRECATED void mbedtls_md5_process( mbedtls_md5_context *ctx, |
||
243 | const unsigned char data[64] ); |
||
244 | |||
245 | #undef MBEDTLS_DEPRECATED |
||
246 | #endif /* !MBEDTLS_DEPRECATED_REMOVED */ |
||
247 | |||
248 | /** |
||
249 | * \brief Output = MD5( input buffer ) |
||
250 | * |
||
251 | * \param input buffer holding the data |
||
252 | * \param ilen length of the input data |
||
253 | * \param output MD5 checksum result |
||
254 | * |
||
255 | * \return 0 if successful |
||
256 | * |
||
257 | * \warning MD5 is considered a weak message digest and its use |
||
258 | * constitutes a security risk. We recommend considering |
||
259 | * stronger message digests instead. |
||
260 | * |
||
261 | */ |
||
262 | int mbedtls_md5_ret( const unsigned char *input, |
||
263 | size_t ilen, |
||
264 | unsigned char output[16] ); |
||
265 | |||
266 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) |
||
267 | #if defined(MBEDTLS_DEPRECATED_WARNING) |
||
268 | #define MBEDTLS_DEPRECATED __attribute__((deprecated)) |
||
269 | #else |
||
270 | #define MBEDTLS_DEPRECATED |
||
271 | #endif |
||
272 | /** |
||
273 | * \brief Output = MD5( input buffer ) |
||
274 | * |
||
275 | * \deprecated Superseded by mbedtls_md5_ret() in 2.7.0 |
||
276 | * |
||
277 | * \param input buffer holding the data |
||
278 | * \param ilen length of the input data |
||
279 | * \param output MD5 checksum result |
||
280 | * |
||
281 | * \warning MD5 is considered a weak message digest and its use |
||
282 | * constitutes a security risk. We recommend considering |
||
283 | * stronger message digests instead. |
||
284 | * |
||
285 | */ |
||
286 | MBEDTLS_DEPRECATED void mbedtls_md5( const unsigned char *input, |
||
287 | size_t ilen, |
||
288 | unsigned char output[16] ); |
||
289 | |||
290 | #undef MBEDTLS_DEPRECATED |
||
291 | #endif /* !MBEDTLS_DEPRECATED_REMOVED */ |
||
292 | |||
293 | #if defined(MBEDTLS_SELF_TEST) |
||
294 | |||
295 | /** |
||
296 | * \brief Checkup routine |
||
297 | * |
||
298 | * \return 0 if successful, or 1 if the test failed |
||
299 | * |
||
300 | * \warning MD5 is considered a weak message digest and its use |
||
301 | * constitutes a security risk. We recommend considering |
||
302 | * stronger message digests instead. |
||
303 | * |
||
304 | */ |
||
305 | int mbedtls_md5_self_test( int verbose ); |
||
306 | |||
307 | #endif /* MBEDTLS_SELF_TEST */ |
||
308 | |||
309 | #ifdef __cplusplus |
||
310 | } |
||
311 | #endif |
||
312 | |||
313 | #endif /* mbedtls_md5.h */>>>> |