4 * \brief MD4 message digest algorithm (hash function)
\r
6 * \warning MD4 is considered a weak message digest and its use constitutes a
\r
7 * security risk. We recommend considering stronger message digests
\r
11 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
\r
12 * SPDX-License-Identifier: Apache-2.0
\r
14 * Licensed under the Apache License, Version 2.0 (the "License"); you may
\r
15 * not use this file except in compliance with the License.
\r
16 * You may obtain a copy of the License at
\r
18 * http://www.apache.org/licenses/LICENSE-2.0
\r
20 * Unless required by applicable law or agreed to in writing, software
\r
21 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
\r
22 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
23 * See the License for the specific language governing permissions and
\r
24 * limitations under the License.
\r
26 * This file is part of mbed TLS (https://tls.mbed.org)
\r
29 #ifndef MBEDTLS_MD4_H
\r
30 #define MBEDTLS_MD4_H
\r
32 #if !defined(MBEDTLS_CONFIG_FILE)
\r
35 #include MBEDTLS_CONFIG_FILE
\r
41 /* MBEDTLS_ERR_MD4_HW_ACCEL_FAILED is deprecated and should not be used. */
\r
42 #define MBEDTLS_ERR_MD4_HW_ACCEL_FAILED -0x002D /**< MD4 hardware accelerator failed */
\r
48 #if !defined(MBEDTLS_MD4_ALT)
\r
49 // Regular implementation
\r
53 * \brief MD4 context structure
\r
55 * \warning MD4 is considered a weak message digest and its use
\r
56 * constitutes a security risk. We recommend considering
\r
57 * stronger message digests instead.
\r
60 typedef struct mbedtls_md4_context
\r
62 uint32_t total[2]; /*!< number of bytes processed */
\r
63 uint32_t state[4]; /*!< intermediate digest state */
\r
64 unsigned char buffer[64]; /*!< data block being processed */
\r
66 mbedtls_md4_context;
\r
68 #else /* MBEDTLS_MD4_ALT */
\r
69 #include "md4_alt.h"
\r
70 #endif /* MBEDTLS_MD4_ALT */
\r
73 * \brief Initialize MD4 context
\r
75 * \param ctx MD4 context to be initialized
\r
77 * \warning MD4 is considered a weak message digest and its use
\r
78 * constitutes a security risk. We recommend considering
\r
79 * stronger message digests instead.
\r
82 void mbedtls_md4_init( mbedtls_md4_context *ctx );
\r
85 * \brief Clear MD4 context
\r
87 * \param ctx MD4 context to be cleared
\r
89 * \warning MD4 is considered a weak message digest and its use
\r
90 * constitutes a security risk. We recommend considering
\r
91 * stronger message digests instead.
\r
94 void mbedtls_md4_free( mbedtls_md4_context *ctx );
\r
97 * \brief Clone (the state of) an MD4 context
\r
99 * \param dst The destination context
\r
100 * \param src The context to be cloned
\r
102 * \warning MD4 is considered a weak message digest and its use
\r
103 * constitutes a security risk. We recommend considering
\r
104 * stronger message digests instead.
\r
107 void mbedtls_md4_clone( mbedtls_md4_context *dst,
\r
108 const mbedtls_md4_context *src );
\r
111 * \brief MD4 context setup
\r
113 * \param ctx context to be initialized
\r
115 * \return 0 if successful
\r
117 * \warning MD4 is considered a weak message digest and its use
\r
118 * constitutes a security risk. We recommend considering
\r
119 * stronger message digests instead.
\r
121 int mbedtls_md4_starts_ret( mbedtls_md4_context *ctx );
\r
124 * \brief MD4 process buffer
\r
126 * \param ctx MD4 context
\r
127 * \param input buffer holding the data
\r
128 * \param ilen length of the input data
\r
130 * \return 0 if successful
\r
132 * \warning MD4 is considered a weak message digest and its use
\r
133 * constitutes a security risk. We recommend considering
\r
134 * stronger message digests instead.
\r
137 int mbedtls_md4_update_ret( mbedtls_md4_context *ctx,
\r
138 const unsigned char *input,
\r
142 * \brief MD4 final digest
\r
144 * \param ctx MD4 context
\r
145 * \param output MD4 checksum result
\r
147 * \return 0 if successful
\r
149 * \warning MD4 is considered a weak message digest and its use
\r
150 * constitutes a security risk. We recommend considering
\r
151 * stronger message digests instead.
\r
154 int mbedtls_md4_finish_ret( mbedtls_md4_context *ctx,
\r
155 unsigned char output[16] );
\r
158 * \brief MD4 process data block (internal use only)
\r
160 * \param ctx MD4 context
\r
161 * \param data buffer holding one block of data
\r
163 * \return 0 if successful
\r
165 * \warning MD4 is considered a weak message digest and its use
\r
166 * constitutes a security risk. We recommend considering
\r
167 * stronger message digests instead.
\r
170 int mbedtls_internal_md4_process( mbedtls_md4_context *ctx,
\r
171 const unsigned char data[64] );
\r
173 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
\r
174 #if defined(MBEDTLS_DEPRECATED_WARNING)
\r
175 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
\r
177 #define MBEDTLS_DEPRECATED
\r
180 * \brief MD4 context setup
\r
182 * \deprecated Superseded by mbedtls_md4_starts_ret() in 2.7.0
\r
184 * \param ctx context to be initialized
\r
186 * \warning MD4 is considered a weak message digest and its use
\r
187 * constitutes a security risk. We recommend considering
\r
188 * stronger message digests instead.
\r
191 MBEDTLS_DEPRECATED void mbedtls_md4_starts( mbedtls_md4_context *ctx );
\r
194 * \brief MD4 process buffer
\r
196 * \deprecated Superseded by mbedtls_md4_update_ret() in 2.7.0
\r
198 * \param ctx MD4 context
\r
199 * \param input buffer holding the data
\r
200 * \param ilen length of the input data
\r
202 * \warning MD4 is considered a weak message digest and its use
\r
203 * constitutes a security risk. We recommend considering
\r
204 * stronger message digests instead.
\r
207 MBEDTLS_DEPRECATED void mbedtls_md4_update( mbedtls_md4_context *ctx,
\r
208 const unsigned char *input,
\r
212 * \brief MD4 final digest
\r
214 * \deprecated Superseded by mbedtls_md4_finish_ret() in 2.7.0
\r
216 * \param ctx MD4 context
\r
217 * \param output MD4 checksum result
\r
219 * \warning MD4 is considered a weak message digest and its use
\r
220 * constitutes a security risk. We recommend considering
\r
221 * stronger message digests instead.
\r
224 MBEDTLS_DEPRECATED void mbedtls_md4_finish( mbedtls_md4_context *ctx,
\r
225 unsigned char output[16] );
\r
228 * \brief MD4 process data block (internal use only)
\r
230 * \deprecated Superseded by mbedtls_internal_md4_process() in 2.7.0
\r
232 * \param ctx MD4 context
\r
233 * \param data buffer holding one block of data
\r
235 * \warning MD4 is considered a weak message digest and its use
\r
236 * constitutes a security risk. We recommend considering
\r
237 * stronger message digests instead.
\r
240 MBEDTLS_DEPRECATED void mbedtls_md4_process( mbedtls_md4_context *ctx,
\r
241 const unsigned char data[64] );
\r
243 #undef MBEDTLS_DEPRECATED
\r
244 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
\r
247 * \brief Output = MD4( input buffer )
\r
249 * \param input buffer holding the data
\r
250 * \param ilen length of the input data
\r
251 * \param output MD4 checksum result
\r
253 * \return 0 if successful
\r
255 * \warning MD4 is considered a weak message digest and its use
\r
256 * constitutes a security risk. We recommend considering
\r
257 * stronger message digests instead.
\r
260 int mbedtls_md4_ret( const unsigned char *input,
\r
262 unsigned char output[16] );
\r
264 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
\r
265 #if defined(MBEDTLS_DEPRECATED_WARNING)
\r
266 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
\r
268 #define MBEDTLS_DEPRECATED
\r
271 * \brief Output = MD4( input buffer )
\r
273 * \deprecated Superseded by mbedtls_md4_ret() in 2.7.0
\r
275 * \param input buffer holding the data
\r
276 * \param ilen length of the input data
\r
277 * \param output MD4 checksum result
\r
279 * \warning MD4 is considered a weak message digest and its use
\r
280 * constitutes a security risk. We recommend considering
\r
281 * stronger message digests instead.
\r
284 MBEDTLS_DEPRECATED void mbedtls_md4( const unsigned char *input,
\r
286 unsigned char output[16] );
\r
288 #undef MBEDTLS_DEPRECATED
\r
289 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
\r
291 #if defined(MBEDTLS_SELF_TEST)
\r
294 * \brief Checkup routine
\r
296 * \return 0 if successful, or 1 if the test failed
\r
298 * \warning MD4 is considered a weak message digest and its use
\r
299 * constitutes a security risk. We recommend considering
\r
300 * stronger message digests instead.
\r
303 int mbedtls_md4_self_test( int verbose );
\r
305 #endif /* MBEDTLS_SELF_TEST */
\r
311 #endif /* mbedtls_md4.h */
\r