]> git.zerfleddert.de Git - proxmark3-svn/blame - common/mbedtls/md5.h
gcc10 compiler fixes:
[proxmark3-svn] / common / mbedtls / md5.h
CommitLineData
700d8687
OM
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 <stddef.h>
40#include <stdint.h>
41
42#define MBEDTLS_ERR_MD5_HW_ACCEL_FAILED -0x002F /**< MD5 hardware accelerator failed */
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48#if !defined(MBEDTLS_MD5_ALT)
49// Regular implementation
50//
51
52/**
53 * \brief MD5 context structure
54 *
55 * \warning MD5 is considered a weak message digest and its use
56 * constitutes a security risk. We recommend considering
57 * stronger message digests instead.
58 *
59 */
60typedef struct mbedtls_md5_context
61{
62 uint32_t total[2]; /*!< number of bytes processed */
63 uint32_t state[4]; /*!< intermediate digest state */
64 unsigned char buffer[64]; /*!< data block being processed */
65}
66mbedtls_md5_context;
67
68#else /* MBEDTLS_MD5_ALT */
69#include "md5_alt.h"
70#endif /* MBEDTLS_MD5_ALT */
71
72/**
73 * \brief Initialize MD5 context
74 *
75 * \param ctx MD5 context to be initialized
76 *
77 * \warning MD5 is considered a weak message digest and its use
78 * constitutes a security risk. We recommend considering
79 * stronger message digests instead.
80 *
81 */
82void mbedtls_md5_init( mbedtls_md5_context *ctx );
83
84/**
85 * \brief Clear MD5 context
86 *
87 * \param ctx MD5 context to be cleared
88 *
89 * \warning MD5 is considered a weak message digest and its use
90 * constitutes a security risk. We recommend considering
91 * stronger message digests instead.
92 *
93 */
94void mbedtls_md5_free( mbedtls_md5_context *ctx );
95
96/**
97 * \brief Clone (the state of) an MD5 context
98 *
99 * \param dst The destination context
100 * \param src The context to be cloned
101 *
102 * \warning MD5 is considered a weak message digest and its use
103 * constitutes a security risk. We recommend considering
104 * stronger message digests instead.
105 *
106 */
107void mbedtls_md5_clone( mbedtls_md5_context *dst,
108 const mbedtls_md5_context *src );
109
110/**
111 * \brief MD5 context setup
112 *
113 * \param ctx context to be initialized
114 *
115 * \return 0 if successful
116 *
117 * \warning MD5 is considered a weak message digest and its use
118 * constitutes a security risk. We recommend considering
119 * stronger message digests instead.
120 *
121 */
122int mbedtls_md5_starts_ret( mbedtls_md5_context *ctx );
123
124/**
125 * \brief MD5 process buffer
126 *
127 * \param ctx MD5 context
128 * \param input buffer holding the data
129 * \param ilen length of the input data
130 *
131 * \return 0 if successful
132 *
133 * \warning MD5 is considered a weak message digest and its use
134 * constitutes a security risk. We recommend considering
135 * stronger message digests instead.
136 *
137 */
138int mbedtls_md5_update_ret( mbedtls_md5_context *ctx,
139 const unsigned char *input,
140 size_t ilen );
141
142/**
143 * \brief MD5 final digest
144 *
145 * \param ctx MD5 context
146 * \param output MD5 checksum result
147 *
148 * \return 0 if successful
149 *
150 * \warning MD5 is considered a weak message digest and its use
151 * constitutes a security risk. We recommend considering
152 * stronger message digests instead.
153 *
154 */
155int mbedtls_md5_finish_ret( mbedtls_md5_context *ctx,
156 unsigned char output[16] );
157
158/**
159 * \brief MD5 process data block (internal use only)
160 *
161 * \param ctx MD5 context
162 * \param data buffer holding one block of data
163 *
164 * \return 0 if successful
165 *
166 * \warning MD5 is considered a weak message digest and its use
167 * constitutes a security risk. We recommend considering
168 * stronger message digests instead.
169 *
170 */
171int mbedtls_internal_md5_process( mbedtls_md5_context *ctx,
172 const unsigned char data[64] );
173
174#if !defined(MBEDTLS_DEPRECATED_REMOVED)
175#if defined(MBEDTLS_DEPRECATED_WARNING)
176#define MBEDTLS_DEPRECATED __attribute__((deprecated))
177#else
178#define MBEDTLS_DEPRECATED
179#endif
180/**
181 * \brief MD5 context setup
182 *
183 * \deprecated Superseded by mbedtls_md5_starts_ret() in 2.7.0
184 *
185 * \param ctx context to be initialized
186 *
187 * \warning MD5 is considered a weak message digest and its use
188 * constitutes a security risk. We recommend considering
189 * stronger message digests instead.
190 *
191 */
192MBEDTLS_DEPRECATED void mbedtls_md5_starts( mbedtls_md5_context *ctx );
193
194/**
195 * \brief MD5 process buffer
196 *
197 * \deprecated Superseded by mbedtls_md5_update_ret() in 2.7.0
198 *
199 * \param ctx MD5 context
200 * \param input buffer holding the data
201 * \param ilen length of the input data
202 *
203 * \warning MD5 is considered a weak message digest and its use
204 * constitutes a security risk. We recommend considering
205 * stronger message digests instead.
206 *
207 */
208MBEDTLS_DEPRECATED void mbedtls_md5_update( mbedtls_md5_context *ctx,
209 const unsigned char *input,
210 size_t ilen );
211
212/**
213 * \brief MD5 final digest
214 *
215 * \deprecated Superseded by mbedtls_md5_finish_ret() in 2.7.0
216 *
217 * \param ctx MD5 context
218 * \param output MD5 checksum result
219 *
220 * \warning MD5 is considered a weak message digest and its use
221 * constitutes a security risk. We recommend considering
222 * stronger message digests instead.
223 *
224 */
225MBEDTLS_DEPRECATED void mbedtls_md5_finish( mbedtls_md5_context *ctx,
226 unsigned char output[16] );
227
228/**
229 * \brief MD5 process data block (internal use only)
230 *
231 * \deprecated Superseded by mbedtls_internal_md5_process() in 2.7.0
232 *
233 * \param ctx MD5 context
234 * \param data buffer holding one block of data
235 *
236 * \warning MD5 is considered a weak message digest and its use
237 * constitutes a security risk. We recommend considering
238 * stronger message digests instead.
239 *
240 */
241MBEDTLS_DEPRECATED void mbedtls_md5_process( mbedtls_md5_context *ctx,
242 const unsigned char data[64] );
243
244#undef MBEDTLS_DEPRECATED
245#endif /* !MBEDTLS_DEPRECATED_REMOVED */
246
247/**
248 * \brief Output = MD5( input buffer )
249 *
250 * \param input buffer holding the data
251 * \param ilen length of the input data
252 * \param output MD5 checksum result
253 *
254 * \return 0 if successful
255 *
256 * \warning MD5 is considered a weak message digest and its use
257 * constitutes a security risk. We recommend considering
258 * stronger message digests instead.
259 *
260 */
261int mbedtls_md5_ret( const unsigned char *input,
262 size_t ilen,
263 unsigned char output[16] );
264
265#if !defined(MBEDTLS_DEPRECATED_REMOVED)
266#if defined(MBEDTLS_DEPRECATED_WARNING)
267#define MBEDTLS_DEPRECATED __attribute__((deprecated))
268#else
269#define MBEDTLS_DEPRECATED
270#endif
271/**
272 * \brief Output = MD5( input buffer )
273 *
274 * \deprecated Superseded by mbedtls_md5_ret() in 2.7.0
275 *
276 * \param input buffer holding the data
277 * \param ilen length of the input data
278 * \param output MD5 checksum result
279 *
280 * \warning MD5 is considered a weak message digest and its use
281 * constitutes a security risk. We recommend considering
282 * stronger message digests instead.
283 *
284 */
285MBEDTLS_DEPRECATED void mbedtls_md5( const unsigned char *input,
286 size_t ilen,
287 unsigned char output[16] );
288
289#undef MBEDTLS_DEPRECATED
290#endif /* !MBEDTLS_DEPRECATED_REMOVED */
291
292/**
293 * \brief Checkup routine
294 *
295 * \return 0 if successful, or 1 if the test failed
296 *
297 * \warning MD5 is considered a weak message digest and its use
298 * constitutes a security risk. We recommend considering
299 * stronger message digests instead.
300 *
301 */
302int mbedtls_md5_self_test( int verbose );
303
304#ifdef __cplusplus
305}
306#endif
307
308#endif /* mbedtls_md5.h */
Impressum, Datenschutz