Merge pull request #2747 from Eltrick/stylise-dormakaba
[RRG-proxmark3.git] / common / mbedtls / md2.h
blob878e89196300a810d51b75603a8529402a8a8fab
1 /**
2 * \file md2.h
4 * \brief MD2 message digest algorithm (hash function)
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 */
11 * Copyright The Mbed TLS Contributors
12 * SPDX-License-Identifier: Apache-2.0
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
18 * http://www.apache.org/licenses/LICENSE-2.0
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.
27 #ifndef MBEDTLS_MD2_H
28 #define MBEDTLS_MD2_H
30 #if !defined(MBEDTLS_CONFIG_FILE)
31 #include "mbedtls/config.h"
32 #else
33 #include MBEDTLS_CONFIG_FILE
34 #endif
36 #include <stddef.h>
38 /* MBEDTLS_ERR_MD2_HW_ACCEL_FAILED is deprecated and should not be used. */
39 #define MBEDTLS_ERR_MD2_HW_ACCEL_FAILED -0x002B /**< MD2 hardware accelerator failed */
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
45 #if !defined(MBEDTLS_MD2_ALT)
46 // Regular implementation
49 /**
50 * \brief MD2 context structure
52 * \warning MD2 is considered a weak message digest and its use
53 * constitutes a security risk. We recommend considering
54 * stronger message digests instead.
57 typedef struct mbedtls_md2_context {
58 unsigned char cksum[16]; /*!< checksum of the data block */
59 unsigned char state[48]; /*!< intermediate digest state */
60 unsigned char buffer[16]; /*!< data block being processed */
61 size_t left; /*!< amount of data in buffer */
63 mbedtls_md2_context;
65 #else /* MBEDTLS_MD2_ALT */
66 #include "md2_alt.h"
67 #endif /* MBEDTLS_MD2_ALT */
69 /**
70 * \brief Initialize MD2 context
72 * \param ctx MD2 context to be initialized
74 * \warning MD2 is considered a weak message digest and its use
75 * constitutes a security risk. We recommend considering
76 * stronger message digests instead.
79 void mbedtls_md2_init(mbedtls_md2_context *ctx);
81 /**
82 * \brief Clear MD2 context
84 * \param ctx MD2 context to be cleared
86 * \warning MD2 is considered a weak message digest and its use
87 * constitutes a security risk. We recommend considering
88 * stronger message digests instead.
91 void mbedtls_md2_free(mbedtls_md2_context *ctx);
93 /**
94 * \brief Clone (the state of) an MD2 context
96 * \param dst The destination context
97 * \param src The context to be cloned
99 * \warning MD2 is considered a weak message digest and its use
100 * constitutes a security risk. We recommend considering
101 * stronger message digests instead.
104 void mbedtls_md2_clone(mbedtls_md2_context *dst,
105 const mbedtls_md2_context *src);
108 * \brief MD2 context setup
110 * \param ctx context to be initialized
112 * \return 0 if successful
114 * \warning MD2 is considered a weak message digest and its use
115 * constitutes a security risk. We recommend considering
116 * stronger message digests instead.
119 int mbedtls_md2_starts_ret(mbedtls_md2_context *ctx);
122 * \brief MD2 process buffer
124 * \param ctx MD2 context
125 * \param input buffer holding the data
126 * \param ilen length of the input data
128 * \return 0 if successful
130 * \warning MD2 is considered a weak message digest and its use
131 * constitutes a security risk. We recommend considering
132 * stronger message digests instead.
135 int mbedtls_md2_update_ret(mbedtls_md2_context *ctx,
136 const unsigned char *input,
137 size_t ilen);
140 * \brief MD2 final digest
142 * \param ctx MD2 context
143 * \param output MD2 checksum result
145 * \return 0 if successful
147 * \warning MD2 is considered a weak message digest and its use
148 * constitutes a security risk. We recommend considering
149 * stronger message digests instead.
152 int mbedtls_md2_finish_ret(mbedtls_md2_context *ctx,
153 unsigned char output[16]);
156 * \brief MD2 process data block (internal use only)
158 * \param ctx MD2 context
160 * \return 0 if successful
162 * \warning MD2 is considered a weak message digest and its use
163 * constitutes a security risk. We recommend considering
164 * stronger message digests instead.
167 int mbedtls_internal_md2_process(mbedtls_md2_context *ctx);
169 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
170 #if defined(MBEDTLS_DEPRECATED_WARNING)
171 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
172 #else
173 #define MBEDTLS_DEPRECATED
174 #endif
176 * \brief MD2 context setup
178 * \deprecated Superseded by mbedtls_md2_starts_ret() in 2.7.0
180 * \param ctx context to be initialized
182 * \warning MD2 is considered a weak message digest and its use
183 * constitutes a security risk. We recommend considering
184 * stronger message digests instead.
187 MBEDTLS_DEPRECATED void mbedtls_md2_starts(mbedtls_md2_context *ctx);
190 * \brief MD2 process buffer
192 * \deprecated Superseded by mbedtls_md2_update_ret() in 2.7.0
194 * \param ctx MD2 context
195 * \param input buffer holding the data
196 * \param ilen length of the input data
198 * \warning MD2 is considered a weak message digest and its use
199 * constitutes a security risk. We recommend considering
200 * stronger message digests instead.
203 MBEDTLS_DEPRECATED void mbedtls_md2_update(mbedtls_md2_context *ctx,
204 const unsigned char *input,
205 size_t ilen);
208 * \brief MD2 final digest
210 * \deprecated Superseded by mbedtls_md2_finish_ret() in 2.7.0
212 * \param ctx MD2 context
213 * \param output MD2 checksum result
215 * \warning MD2 is considered a weak message digest and its use
216 * constitutes a security risk. We recommend considering
217 * stronger message digests instead.
220 MBEDTLS_DEPRECATED void mbedtls_md2_finish(mbedtls_md2_context *ctx,
221 unsigned char output[16]);
224 * \brief MD2 process data block (internal use only)
226 * \deprecated Superseded by mbedtls_internal_md2_process() in 2.7.0
228 * \param ctx MD2 context
230 * \warning MD2 is considered a weak message digest and its use
231 * constitutes a security risk. We recommend considering
232 * stronger message digests instead.
235 MBEDTLS_DEPRECATED void mbedtls_md2_process(mbedtls_md2_context *ctx);
237 #undef MBEDTLS_DEPRECATED
238 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
241 * \brief Output = MD2( input buffer )
243 * \param input buffer holding the data
244 * \param ilen length of the input data
245 * \param output MD2 checksum result
247 * \warning MD2 is considered a weak message digest and its use
248 * constitutes a security risk. We recommend considering
249 * stronger message digests instead.
252 int mbedtls_md2_ret(const unsigned char *input,
253 size_t ilen,
254 unsigned char output[16]);
256 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
257 #if defined(MBEDTLS_DEPRECATED_WARNING)
258 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
259 #else
260 #define MBEDTLS_DEPRECATED
261 #endif
263 * \brief Output = MD2( input buffer )
265 * \deprecated Superseded by mbedtls_md2_ret() in 2.7.0
267 * \param input buffer holding the data
268 * \param ilen length of the input data
269 * \param output MD2 checksum result
271 * \warning MD2 is considered a weak message digest and its use
272 * constitutes a security risk. We recommend considering
273 * stronger message digests instead.
276 MBEDTLS_DEPRECATED void mbedtls_md2(const unsigned char *input,
277 size_t ilen,
278 unsigned char output[16]);
280 #undef MBEDTLS_DEPRECATED
281 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
283 #if defined(MBEDTLS_SELF_TEST)
286 * \brief Checkup routine
288 * \return 0 if successful, or 1 if the test failed
290 * \warning MD2 is considered a weak message digest and its use
291 * constitutes a security risk. We recommend considering
292 * stronger message digests instead.
295 int mbedtls_md2_self_test(int verbose);
297 #endif /* MBEDTLS_SELF_TEST */
299 #ifdef __cplusplus
301 #endif
303 #endif /* mbedtls_md2.h */