Mbed OS Reference
Loading...
Searching...
No Matches
md2.h
Go to the documentation of this file.
1/**
2 * \file md2.h
3 *
4 * \brief MD2 message digest algorithm (hash function)
5 *
6 * \warning MD2 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_MD2_H
28#define MBEDTLS_MD2_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
38/**
39 * \ingroup mbedtls_md_module
40 * \{
41 */
42
43/* MBEDTLS_ERR_MD2_HW_ACCEL_FAILED is deprecated and should not be used. */
44#define MBEDTLS_ERR_MD2_HW_ACCEL_FAILED -0x002B /**< MD2 hardware accelerator failed */
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50#if !defined(MBEDTLS_MD2_ALT)
51// Regular implementation
52//
53
54/**
55 * \brief MD2 context structure
56 *
57 * \warning MD2 is considered a weak message digest and its use
58 * constitutes a security risk. We recommend considering
59 * stronger message digests instead.
60 *
61 */
62typedef struct mbedtls_md2_context
63{
64 unsigned char cksum[16]; /*!< checksum of the data block */
65 unsigned char state[48]; /*!< intermediate digest state */
66 unsigned char buffer[16]; /*!< data block being processed */
67 size_t left; /*!< amount of data in buffer */
68}
70
71#else /* MBEDTLS_MD2_ALT */
72#include "md2_alt.h"
73#endif /* MBEDTLS_MD2_ALT */
74
75/**
76 * \brief Initialize MD2 context
77 *
78 * \param ctx MD2 context to be initialized
79 *
80 * \warning MD2 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 MD2 context
89 *
90 * \param ctx MD2 context to be cleared
91 *
92 * \warning MD2 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 MD2 context
101 *
102 * \param dst The destination context
103 * \param src The context to be cloned
104 *
105 * \warning MD2 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_md2_context *src );
112
113/**
114 * \brief MD2 context setup
115 *
116 * \param ctx context to be initialized
117 *
118 * \return 0 if successful
119 *
120 * \warning MD2 is considered a weak message digest and its use
121 * constitutes a security risk. We recommend considering
122 * stronger message digests instead.
123 *
124 */
126
127/**
128 * \brief MD2 process buffer
129 *
130 * \param ctx MD2 context
131 * \param input buffer holding the data
132 * \param ilen length of the input data
133 *
134 * \return 0 if successful
135 *
136 * \warning MD2 is considered a weak message digest and its use
137 * constitutes a security risk. We recommend considering
138 * stronger message digests instead.
139 *
140 */
142 const unsigned char *input,
143 size_t ilen );
144
145/**
146 * \brief MD2 final digest
147 *
148 * \param ctx MD2 context
149 * \param output MD2 checksum result
150 *
151 * \return 0 if successful
152 *
153 * \warning MD2 is considered a weak message digest and its use
154 * constitutes a security risk. We recommend considering
155 * stronger message digests instead.
156 *
157 */
159 unsigned char output[16] );
160
161/**
162 * \brief MD2 process data block (internal use only)
163 *
164 * \param ctx MD2 context
165 *
166 * \return 0 if successful
167 *
168 * \warning MD2 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
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 MD2 context setup
183 *
184 * \deprecated Superseded by mbedtls_md2_starts_ret() in 2.7.0
185 *
186 * \param ctx context to be initialized
187 *
188 * \warning MD2 is considered a weak message digest and its use
189 * constitutes a security risk. We recommend considering
190 * stronger message digests instead.
191 *
192 */
193MBEDTLS_DEPRECATED void mbedtls_md2_starts( mbedtls_md2_context *ctx );
194
195/**
196 * \brief MD2 process buffer
197 *
198 * \deprecated Superseded by mbedtls_md2_update_ret() in 2.7.0
199 *
200 * \param ctx MD2 context
201 * \param input buffer holding the data
202 * \param ilen length of the input data
203 *
204 * \warning MD2 is considered a weak message digest and its use
205 * constitutes a security risk. We recommend considering
206 * stronger message digests instead.
207 *
208 */
209MBEDTLS_DEPRECATED void mbedtls_md2_update( mbedtls_md2_context *ctx,
210 const unsigned char *input,
211 size_t ilen );
212
213/**
214 * \brief MD2 final digest
215 *
216 * \deprecated Superseded by mbedtls_md2_finish_ret() in 2.7.0
217 *
218 * \param ctx MD2 context
219 * \param output MD2 checksum result
220 *
221 * \warning MD2 is considered a weak message digest and its use
222 * constitutes a security risk. We recommend considering
223 * stronger message digests instead.
224 *
225 */
226MBEDTLS_DEPRECATED void mbedtls_md2_finish( mbedtls_md2_context *ctx,
227 unsigned char output[16] );
228
229/**
230 * \brief MD2 process data block (internal use only)
231 *
232 * \deprecated Superseded by mbedtls_internal_md2_process() in 2.7.0
233 *
234 * \param ctx MD2 context
235 *
236 * \warning MD2 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_md2_process( mbedtls_md2_context *ctx );
242
243#undef MBEDTLS_DEPRECATED
244#endif /* !MBEDTLS_DEPRECATED_REMOVED */
245
246/**
247 * \brief Output = MD2( input buffer )
248 *
249 * \param input buffer holding the data
250 * \param ilen length of the input data
251 * \param output MD2 checksum result
252 *
253 * \warning MD2 is considered a weak message digest and its use
254 * constitutes a security risk. We recommend considering
255 * stronger message digests instead.
256 *
257 */
258int mbedtls_md2_ret( const unsigned char *input,
259 size_t ilen,
260 unsigned char output[16] );
261
262#if !defined(MBEDTLS_DEPRECATED_REMOVED)
263#if defined(MBEDTLS_DEPRECATED_WARNING)
264#define MBEDTLS_DEPRECATED __attribute__((deprecated))
265#else
266#define MBEDTLS_DEPRECATED
267#endif
268/**
269 * \brief Output = MD2( input buffer )
270 *
271 * \deprecated Superseded by mbedtls_md2_ret() in 2.7.0
272 *
273 * \param input buffer holding the data
274 * \param ilen length of the input data
275 * \param output MD2 checksum result
276 *
277 * \warning MD2 is considered a weak message digest and its use
278 * constitutes a security risk. We recommend considering
279 * stronger message digests instead.
280 *
281 */
282MBEDTLS_DEPRECATED void mbedtls_md2( const unsigned char *input,
283 size_t ilen,
284 unsigned char output[16] );
285
286#undef MBEDTLS_DEPRECATED
287#endif /* !MBEDTLS_DEPRECATED_REMOVED */
288
289#if defined(MBEDTLS_SELF_TEST)
290
291/**
292 * \brief Checkup routine
293 *
294 * \return 0 if successful, or 1 if the test failed
295 *
296 * \warning MD2 is considered a weak message digest and its use
297 * constitutes a security risk. We recommend considering
298 * stronger message digests instead.
299 *
300 */
301int mbedtls_md2_self_test( int verbose );
302
303#endif /* MBEDTLS_SELF_TEST */
304
305#ifdef __cplusplus
306}
307#endif
308
309/// \}
310
311#endif /* mbedtls_md2.h */
Configuration options (set of defines)
void mbedtls_md2_finish(mbedtls_md2_context *ctx, unsigned char output[16])
MD2 final digest.
void mbedtls_md2_init(mbedtls_md2_context *ctx)
Initialize MD2 context.
void mbedtls_md2_starts(mbedtls_md2_context *ctx)
MD2 context setup.
void mbedtls_md2_process(mbedtls_md2_context *ctx)
MD2 process data block (internal use only)
void mbedtls_md2_update(mbedtls_md2_context *ctx, const unsigned char *input, size_t ilen)
MD2 process buffer.
void mbedtls_md2_clone(mbedtls_md2_context *dst, const mbedtls_md2_context *src)
Clone (the state of) an MD2 context.
int mbedtls_internal_md2_process(mbedtls_md2_context *ctx)
MD2 process data block (internal use only)
int mbedtls_md2_finish_ret(mbedtls_md2_context *ctx, unsigned char output[16])
MD2 final digest.
void mbedtls_md2_free(mbedtls_md2_context *ctx)
Clear MD2 context.
int mbedtls_md2_ret(const unsigned char *input, size_t ilen, unsigned char output[16])
Output = MD2( input buffer )
int mbedtls_md2_starts_ret(mbedtls_md2_context *ctx)
MD2 context setup.
void mbedtls_md2(const unsigned char *input, size_t ilen, unsigned char output[16])
Output = MD2( input buffer )
int mbedtls_md2_update_ret(mbedtls_md2_context *ctx, const unsigned char *input, size_t ilen)
MD2 process buffer.
MD2 context structure.
Definition: md2.h:63
unsigned char buffer[16]
Definition: md2.h:66
size_t left
Definition: md2.h:67
unsigned char state[48]
Definition: md2.h:65
unsigned char cksum[16]
Definition: md2.h:64