]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - common/mbedtls/md5.h
4 * \brief MD5 message digest algorithm (hash function)
6 * \warning MD5 is considered a weak message digest and its use constitutes a
7 * security risk. We recommend considering stronger message
11 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
12 * SPDX-License-Identifier: GPL-2.0
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.
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.
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.
28 * This file is part of mbed TLS (https://tls.mbed.org)
33 #if !defined(MBEDTLS_CONFIG_FILE)
36 #include MBEDTLS_CONFIG_FILE
42 #define MBEDTLS_ERR_MD5_HW_ACCEL_FAILED -0x002F /**< MD5 hardware accelerator failed */
48 #if !defined(MBEDTLS_MD5_ALT)
49 // Regular implementation
53 * \brief MD5 context structure
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.
60 typedef struct mbedtls_md5_context
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 */
68 #else /* MBEDTLS_MD5_ALT */
70 #endif /* MBEDTLS_MD5_ALT */
73 * \brief Initialize MD5 context
75 * \param ctx MD5 context to be initialized
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.
82 void mbedtls_md5_init( mbedtls_md5_context
*ctx
);
85 * \brief Clear MD5 context
87 * \param ctx MD5 context to be cleared
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.
94 void mbedtls_md5_free( mbedtls_md5_context
*ctx
);
97 * \brief Clone (the state of) an MD5 context
99 * \param dst The destination context
100 * \param src The context to be cloned
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.
107 void mbedtls_md5_clone( mbedtls_md5_context
*dst
,
108 const mbedtls_md5_context
*src
);
111 * \brief MD5 context setup
113 * \param ctx context to be initialized
115 * \return 0 if successful
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.
122 int mbedtls_md5_starts_ret( mbedtls_md5_context
*ctx
);
125 * \brief MD5 process buffer
127 * \param ctx MD5 context
128 * \param input buffer holding the data
129 * \param ilen length of the input data
131 * \return 0 if successful
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.
138 int mbedtls_md5_update_ret( mbedtls_md5_context
*ctx
,
139 const unsigned char *input
,
143 * \brief MD5 final digest
145 * \param ctx MD5 context
146 * \param output MD5 checksum result
148 * \return 0 if successful
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.
155 int mbedtls_md5_finish_ret( mbedtls_md5_context
*ctx
,
156 unsigned char output
[16] );
159 * \brief MD5 process data block (internal use only)
161 * \param ctx MD5 context
162 * \param data buffer holding one block of data
164 * \return 0 if successful
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.
171 int mbedtls_internal_md5_process( mbedtls_md5_context
*ctx
,
172 const unsigned char data
[64] );
174 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
175 #if defined(MBEDTLS_DEPRECATED_WARNING)
176 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
178 #define MBEDTLS_DEPRECATED
181 * \brief MD5 context setup
183 * \deprecated Superseded by mbedtls_md5_starts_ret() in 2.7.0
185 * \param ctx context to be initialized
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.
192 MBEDTLS_DEPRECATED
void mbedtls_md5_starts( mbedtls_md5_context
*ctx
);
195 * \brief MD5 process buffer
197 * \deprecated Superseded by mbedtls_md5_update_ret() in 2.7.0
199 * \param ctx MD5 context
200 * \param input buffer holding the data
201 * \param ilen length of the input data
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.
208 MBEDTLS_DEPRECATED
void mbedtls_md5_update( mbedtls_md5_context
*ctx
,
209 const unsigned char *input
,
213 * \brief MD5 final digest
215 * \deprecated Superseded by mbedtls_md5_finish_ret() in 2.7.0
217 * \param ctx MD5 context
218 * \param output MD5 checksum result
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.
225 MBEDTLS_DEPRECATED
void mbedtls_md5_finish( mbedtls_md5_context
*ctx
,
226 unsigned char output
[16] );
229 * \brief MD5 process data block (internal use only)
231 * \deprecated Superseded by mbedtls_internal_md5_process() in 2.7.0
233 * \param ctx MD5 context
234 * \param data buffer holding one block of data
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.
241 MBEDTLS_DEPRECATED
void mbedtls_md5_process( mbedtls_md5_context
*ctx
,
242 const unsigned char data
[64] );
244 #undef MBEDTLS_DEPRECATED
245 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
248 * \brief Output = MD5( input buffer )
250 * \param input buffer holding the data
251 * \param ilen length of the input data
252 * \param output MD5 checksum result
254 * \return 0 if successful
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.
261 int mbedtls_md5_ret( const unsigned char *input
,
263 unsigned char output
[16] );
265 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
266 #if defined(MBEDTLS_DEPRECATED_WARNING)
267 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
269 #define MBEDTLS_DEPRECATED
272 * \brief Output = MD5( input buffer )
274 * \deprecated Superseded by mbedtls_md5_ret() in 2.7.0
276 * \param input buffer holding the data
277 * \param ilen length of the input data
278 * \param output MD5 checksum result
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.
285 MBEDTLS_DEPRECATED
void mbedtls_md5( const unsigned char *input
,
287 unsigned char output
[16] );
289 #undef MBEDTLS_DEPRECATED
290 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
293 * \brief Checkup routine
295 * \return 0 if successful, or 1 if the test failed
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.
302 int mbedtls_md5_self_test( int verbose
);
308 #endif /* mbedtls_md5.h */