Mbed OS Reference
Loading...
Searching...
No Matches
mbedtls/include/mbedtls/md4.h
Go to the documentation of this file.
1/**
2 * \file md4.h
3 *
4 * \brief MD4 message digest algorithm (hash function)
5 *
6 * \warning MD4 is considered a weak message digest and its use constitutes a
7 * security risk. We recommend considering stronger message digests
8 * instead.
9 */
10/*
11 * Copyright The Mbed TLS Contributors
12 * SPDX-License-Identifier: Apache-2.0
13 *
14 * Licensed under the Apache License, Version 2.0 (the "License"); you may
15 * not use this file except in compliance with the License.
16 * You may obtain a copy of the License at
17 *
18 * http://www.apache.org/licenses/LICENSE-2.0
19 *
20 * Unless required by applicable law or agreed to in writing, software
21 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
22 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 * See the License for the specific language governing permissions and
24 * limitations under the License.
25 *
26 */
27#ifndef MBEDTLS_MD4_H
28#define MBEDTLS_MD4_H
29
30#if !defined(MBEDTLS_CONFIG_FILE)
31#include "mbedtls/config.h"
32#else
33#include MBEDTLS_CONFIG_FILE
34#endif
35
36#include <stddef.h>
37#include <stdint.h>
38
39/**
40 * \ingroup mbedtls_md_module
41 * \{
42 */
43
44/* MBEDTLS_ERR_MD4_HW_ACCEL_FAILED is deprecated and should not be used. */
45#define MBEDTLS_ERR_MD4_HW_ACCEL_FAILED -0x002D /**< MD4 hardware accelerator failed */
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51#if !defined(MBEDTLS_MD4_ALT)
52// Regular implementation
53//
54
55/**
56 * \brief MD4 context structure
57 *
58 * \warning MD4 is considered a weak message digest and its use
59 * constitutes a security risk. We recommend considering
60 * stronger message digests instead.
61 *
62 */
63typedef struct mbedtls_md4_context
64{
65 uint32_t total[2]; /*!< number of bytes processed */
66 uint32_t state[4]; /*!< intermediate digest state */
67 unsigned char buffer[64]; /*!< data block being processed */
68}
70
71#else /* MBEDTLS_MD4_ALT */
72#include "md4_alt.h"
73#endif /* MBEDTLS_MD4_ALT */
74
75/**
76 * \brief Initialize MD4 context
77 *
78 * \param ctx MD4 context to be initialized
79 *
80 * \warning MD4 is considered a weak message digest and its use
81 * constitutes a security risk. We recommend considering
82 * stronger message digests instead.
83 *
84 */
86
87/**
88 * \brief Clear MD4 context
89 *
90 * \param ctx MD4 context to be cleared
91 *
92 * \warning MD4 is considered a weak message digest and its use
93 * constitutes a security risk. We recommend considering
94 * stronger message digests instead.
95 *
96 */
98
99/**
100 * \brief Clone (the state of) an MD4 context
101 *
102 * \param dst The destination context
103 * \param src The context to be cloned
104 *
105 * \warning MD4 is considered a weak message digest and its use
106 * constitutes a security risk. We recommend considering
107 * stronger message digests instead.
108 *
109 */
111 const mbedtls_md4_context *src );
112
113/**
114 * \brief MD4 context setup
115 *
116 * \param ctx context to be initialized
117 *
118 * \return 0 if successful
119 *
120 * \warning MD4 is considered a weak message digest and its use
121 * constitutes a security risk. We recommend considering
122 * stronger message digests instead.
123 */
125
126/**
127 * \brief MD4 process buffer
128 *
129 * \param ctx MD4 context
130 * \param input buffer holding the data
131 * \param ilen length of the input data
132 *
133 * \return 0 if successful
134 *
135 * \warning MD4 is considered a weak message digest and its use
136 * constitutes a security risk. We recommend considering
137 * stronger message digests instead.
138 *
139 */
141 const unsigned char *input,
142 size_t ilen );
143
144/**
145 * \brief MD4 final digest
146 *
147 * \param ctx MD4 context
148 * \param output MD4 checksum result
149 *
150 * \return 0 if successful
151 *
152 * \warning MD4 is considered a weak message digest and its use
153 * constitutes a security risk. We recommend considering
154 * stronger message digests instead.
155 *
156 */
158 unsigned char output[16] );
159
160/**
161 * \brief MD4 process data block (internal use only)
162 *
163 * \param ctx MD4 context
164 * \param data buffer holding one block of data
165 *
166 * \return 0 if successful
167 *
168 * \warning MD4 is considered a weak message digest and its use
169 * constitutes a security risk. We recommend considering
170 * stronger message digests instead.
171 *
172 */
174 const unsigned char data[64] );
175
176#if !defined(MBEDTLS_DEPRECATED_REMOVED)
177#if defined(MBEDTLS_DEPRECATED_WARNING)
178#define MBEDTLS_DEPRECATED __attribute__((deprecated))
179#else
180#define MBEDTLS_DEPRECATED
181#endif
182/**
183 * \brief MD4 context setup
184 *
185 * \deprecated Superseded by mbedtls_md4_starts_ret() in 2.7.0
186 *
187 * \param ctx context to be initialized
188 *
189 * \warning MD4 is considered a weak message digest and its use
190 * constitutes a security risk. We recommend considering
191 * stronger message digests instead.
192 *
193 */
194MBEDTLS_DEPRECATED void mbedtls_md4_starts( mbedtls_md4_context *ctx );
195
196/**
197 * \brief MD4 process buffer
198 *
199 * \deprecated Superseded by mbedtls_md4_update_ret() in 2.7.0
200 *
201 * \param ctx MD4 context
202 * \param input buffer holding the data
203 * \param ilen length of the input data
204 *
205 * \warning MD4 is considered a weak message digest and its use
206 * constitutes a security risk. We recommend considering
207 * stronger message digests instead.
208 *
209 */
210MBEDTLS_DEPRECATED void mbedtls_md4_update( mbedtls_md4_context *ctx,
211 const unsigned char *input,
212 size_t ilen );
213
214/**
215 * \brief MD4 final digest
216 *
217 * \deprecated Superseded by mbedtls_md4_finish_ret() in 2.7.0
218 *
219 * \param ctx MD4 context
220 * \param output MD4 checksum result
221 *
222 * \warning MD4 is considered a weak message digest and its use
223 * constitutes a security risk. We recommend considering
224 * stronger message digests instead.
225 *
226 */
227MBEDTLS_DEPRECATED void mbedtls_md4_finish( mbedtls_md4_context *ctx,
228 unsigned char output[16] );
229
230/**
231 * \brief MD4 process data block (internal use only)
232 *
233 * \deprecated Superseded by mbedtls_internal_md4_process() in 2.7.0
234 *
235 * \param ctx MD4 context
236 * \param data buffer holding one block of data
237 *
238 * \warning MD4 is considered a weak message digest and its use
239 * constitutes a security risk. We recommend considering
240 * stronger message digests instead.
241 *
242 */
243MBEDTLS_DEPRECATED void mbedtls_md4_process( mbedtls_md4_context *ctx,
244 const unsigned char data[64] );
245
246#undef MBEDTLS_DEPRECATED
247#endif /* !MBEDTLS_DEPRECATED_REMOVED */
248
249/**
250 * \brief Output = MD4( input buffer )
251 *
252 * \param input buffer holding the data
253 * \param ilen length of the input data
254 * \param output MD4 checksum result
255 *
256 * \return 0 if successful
257 *
258 * \warning MD4 is considered a weak message digest and its use
259 * constitutes a security risk. We recommend considering
260 * stronger message digests instead.
261 *
262 */
263int mbedtls_md4_ret( const unsigned char *input,
264 size_t ilen,
265 unsigned char output[16] );
266
267#if !defined(MBEDTLS_DEPRECATED_REMOVED)
268#if defined(MBEDTLS_DEPRECATED_WARNING)
269#define MBEDTLS_DEPRECATED __attribute__((deprecated))
270#else
271#define MBEDTLS_DEPRECATED
272#endif
273/**
274 * \brief Output = MD4( input buffer )
275 *
276 * \deprecated Superseded by mbedtls_md4_ret() in 2.7.0
277 *
278 * \param input buffer holding the data
279 * \param ilen length of the input data
280 * \param output MD4 checksum result
281 *
282 * \warning MD4 is considered a weak message digest and its use
283 * constitutes a security risk. We recommend considering
284 * stronger message digests instead.
285 *
286 */
287MBEDTLS_DEPRECATED void mbedtls_md4( const unsigned char *input,
288 size_t ilen,
289 unsigned char output[16] );
290
291#undef MBEDTLS_DEPRECATED
292#endif /* !MBEDTLS_DEPRECATED_REMOVED */
293
294#if defined(MBEDTLS_SELF_TEST)
295
296/**
297 * \brief Checkup routine
298 *
299 * \return 0 if successful, or 1 if the test failed
300 *
301 * \warning MD4 is considered a weak message digest and its use
302 * constitutes a security risk. We recommend considering
303 * stronger message digests instead.
304 *
305 */
306int mbedtls_md4_self_test( int verbose );
307
308#endif /* MBEDTLS_SELF_TEST */
309
310#ifdef __cplusplus
311}
312#endif
313
314/// \}
315
316#endif /* mbedtls_md4.h */
Configuration options (set of defines)
int mbedtls_md4_ret(const unsigned char *input, size_t ilen, unsigned char output[16])
Output = MD4( input buffer )
int mbedtls_md4_starts_ret(mbedtls_md4_context *ctx)
MD4 context setup.
void mbedtls_md4(const unsigned char *input, size_t ilen, unsigned char output[16])
Output = MD4( input buffer )
void mbedtls_md4_free(mbedtls_md4_context *ctx)
Clear MD4 context.
void mbedtls_md4_starts(mbedtls_md4_context *ctx)
MD4 context setup.
void mbedtls_md4_update(mbedtls_md4_context *ctx, const unsigned char *input, size_t ilen)
MD4 process buffer.
int mbedtls_md4_update_ret(mbedtls_md4_context *ctx, const unsigned char *input, size_t ilen)
MD4 process buffer.
void mbedtls_md4_finish(mbedtls_md4_context *ctx, unsigned char output[16])
MD4 final digest.
void mbedtls_md4_process(mbedtls_md4_context *ctx, const unsigned char data[64])
MD4 process data block (internal use only)
int mbedtls_md4_finish_ret(mbedtls_md4_context *ctx, unsigned char output[16])
MD4 final digest.
void mbedtls_md4_init(mbedtls_md4_context *ctx)
Initialize MD4 context.
void mbedtls_md4_clone(mbedtls_md4_context *dst, const mbedtls_md4_context *src)
Clone (the state of) an MD4 context.
int mbedtls_internal_md4_process(mbedtls_md4_context *ctx, const unsigned char data[64])
MD4 process data block (internal use only)
MD4 context structure.