Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
md2.h
00001 /** 00002 * \file md2.h 00003 * 00004 * \brief MD2 message digest algorithm (hash function) 00005 * 00006 * \warning MD2 is considered a weak message digest and its use constitutes a 00007 * security risk. We recommend considering stronger message digests 00008 * instead. 00009 */ 00010 /* 00011 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 00012 * SPDX-License-Identifier: Apache-2.0 00013 * 00014 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00015 * not use this file except in compliance with the License. 00016 * You may obtain a copy of the License at 00017 * 00018 * http://www.apache.org/licenses/LICENSE-2.0 00019 * 00020 * Unless required by applicable law or agreed to in writing, software 00021 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00022 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00023 * See the License for the specific language governing permissions and 00024 * limitations under the License. 00025 * 00026 * This file is part of mbed TLS (https://tls.mbed.org) 00027 * 00028 */ 00029 #ifndef MBEDTLS_MD2_H 00030 #define MBEDTLS_MD2_H 00031 00032 #if !defined(MBEDTLS_CONFIG_FILE) 00033 #include "mbedtls/config.h" 00034 #else 00035 #include MBEDTLS_CONFIG_FILE 00036 #endif 00037 00038 #include <stddef.h> 00039 00040 /* MBEDTLS_ERR_MD2_HW_ACCEL_FAILED is deprecated and should not be used. */ 00041 #define MBEDTLS_ERR_MD2_HW_ACCEL_FAILED -0x002B /**< MD2 hardware accelerator failed */ 00042 00043 #ifdef __cplusplus 00044 extern "C" { 00045 #endif 00046 00047 #if !defined(MBEDTLS_MD2_ALT) 00048 // Regular implementation 00049 // 00050 00051 /** 00052 * \brief MD2 context structure 00053 * 00054 * \warning MD2 is considered a weak message digest and its use 00055 * constitutes a security risk. We recommend considering 00056 * stronger message digests instead. 00057 * 00058 */ 00059 typedef struct mbedtls_md2_context 00060 { 00061 unsigned char cksum [16]; /*!< checksum of the data block */ 00062 unsigned char state [48]; /*!< intermediate digest state */ 00063 unsigned char buffer[16]; /*!< data block being processed */ 00064 size_t left ; /*!< amount of data in buffer */ 00065 } 00066 mbedtls_md2_context; 00067 00068 #else /* MBEDTLS_MD2_ALT */ 00069 #include "md2_alt.h" 00070 #endif /* MBEDTLS_MD2_ALT */ 00071 00072 /** 00073 * \brief Initialize MD2 context 00074 * 00075 * \param ctx MD2 context to be initialized 00076 * 00077 * \warning MD2 is considered a weak message digest and its use 00078 * constitutes a security risk. We recommend considering 00079 * stronger message digests instead. 00080 * 00081 */ 00082 void mbedtls_md2_init( mbedtls_md2_context *ctx ); 00083 00084 /** 00085 * \brief Clear MD2 context 00086 * 00087 * \param ctx MD2 context to be cleared 00088 * 00089 * \warning MD2 is considered a weak message digest and its use 00090 * constitutes a security risk. We recommend considering 00091 * stronger message digests instead. 00092 * 00093 */ 00094 void mbedtls_md2_free( mbedtls_md2_context *ctx ); 00095 00096 /** 00097 * \brief Clone (the state of) an MD2 context 00098 * 00099 * \param dst The destination context 00100 * \param src The context to be cloned 00101 * 00102 * \warning MD2 is considered a weak message digest and its use 00103 * constitutes a security risk. We recommend considering 00104 * stronger message digests instead. 00105 * 00106 */ 00107 void mbedtls_md2_clone( mbedtls_md2_context *dst, 00108 const mbedtls_md2_context *src ); 00109 00110 /** 00111 * \brief MD2 context setup 00112 * 00113 * \param ctx context to be initialized 00114 * 00115 * \return 0 if successful 00116 * 00117 * \warning MD2 is considered a weak message digest and its use 00118 * constitutes a security risk. We recommend considering 00119 * stronger message digests instead. 00120 * 00121 */ 00122 int mbedtls_md2_starts_ret( mbedtls_md2_context *ctx ); 00123 00124 /** 00125 * \brief MD2 process buffer 00126 * 00127 * \param ctx MD2 context 00128 * \param input buffer holding the data 00129 * \param ilen length of the input data 00130 * 00131 * \return 0 if successful 00132 * 00133 * \warning MD2 is considered a weak message digest and its use 00134 * constitutes a security risk. We recommend considering 00135 * stronger message digests instead. 00136 * 00137 */ 00138 int mbedtls_md2_update_ret( mbedtls_md2_context *ctx, 00139 const unsigned char *input, 00140 size_t ilen ); 00141 00142 /** 00143 * \brief MD2 final digest 00144 * 00145 * \param ctx MD2 context 00146 * \param output MD2 checksum result 00147 * 00148 * \return 0 if successful 00149 * 00150 * \warning MD2 is considered a weak message digest and its use 00151 * constitutes a security risk. We recommend considering 00152 * stronger message digests instead. 00153 * 00154 */ 00155 int mbedtls_md2_finish_ret( mbedtls_md2_context *ctx, 00156 unsigned char output[16] ); 00157 00158 /** 00159 * \brief MD2 process data block (internal use only) 00160 * 00161 * \param ctx MD2 context 00162 * 00163 * \return 0 if successful 00164 * 00165 * \warning MD2 is considered a weak message digest and its use 00166 * constitutes a security risk. We recommend considering 00167 * stronger message digests instead. 00168 * 00169 */ 00170 int mbedtls_internal_md2_process( mbedtls_md2_context *ctx ); 00171 00172 #if !defined(MBEDTLS_DEPRECATED_REMOVED) 00173 #if defined(MBEDTLS_DEPRECATED_WARNING) 00174 #define MBEDTLS_DEPRECATED __attribute__((deprecated)) 00175 #else 00176 #define MBEDTLS_DEPRECATED 00177 #endif 00178 /** 00179 * \brief MD2 context setup 00180 * 00181 * \deprecated Superseded by mbedtls_md2_starts_ret() in 2.7.0 00182 * 00183 * \param ctx context to be initialized 00184 * 00185 * \warning MD2 is considered a weak message digest and its use 00186 * constitutes a security risk. We recommend considering 00187 * stronger message digests instead. 00188 * 00189 */ 00190 MBEDTLS_DEPRECATED void mbedtls_md2_starts( mbedtls_md2_context *ctx ); 00191 00192 /** 00193 * \brief MD2 process buffer 00194 * 00195 * \deprecated Superseded by mbedtls_md2_update_ret() in 2.7.0 00196 * 00197 * \param ctx MD2 context 00198 * \param input buffer holding the data 00199 * \param ilen length of the input data 00200 * 00201 * \warning MD2 is considered a weak message digest and its use 00202 * constitutes a security risk. We recommend considering 00203 * stronger message digests instead. 00204 * 00205 */ 00206 MBEDTLS_DEPRECATED void mbedtls_md2_update( mbedtls_md2_context *ctx, 00207 const unsigned char *input, 00208 size_t ilen ); 00209 00210 /** 00211 * \brief MD2 final digest 00212 * 00213 * \deprecated Superseded by mbedtls_md2_finish_ret() in 2.7.0 00214 * 00215 * \param ctx MD2 context 00216 * \param output MD2 checksum result 00217 * 00218 * \warning MD2 is considered a weak message digest and its use 00219 * constitutes a security risk. We recommend considering 00220 * stronger message digests instead. 00221 * 00222 */ 00223 MBEDTLS_DEPRECATED void mbedtls_md2_finish( mbedtls_md2_context *ctx, 00224 unsigned char output[16] ); 00225 00226 /** 00227 * \brief MD2 process data block (internal use only) 00228 * 00229 * \deprecated Superseded by mbedtls_internal_md2_process() in 2.7.0 00230 * 00231 * \param ctx MD2 context 00232 * 00233 * \warning MD2 is considered a weak message digest and its use 00234 * constitutes a security risk. We recommend considering 00235 * stronger message digests instead. 00236 * 00237 */ 00238 MBEDTLS_DEPRECATED void mbedtls_md2_process( mbedtls_md2_context *ctx ); 00239 00240 #undef MBEDTLS_DEPRECATED 00241 #endif /* !MBEDTLS_DEPRECATED_REMOVED */ 00242 00243 /** 00244 * \brief Output = MD2( input buffer ) 00245 * 00246 * \param input buffer holding the data 00247 * \param ilen length of the input data 00248 * \param output MD2 checksum result 00249 * 00250 * \warning MD2 is considered a weak message digest and its use 00251 * constitutes a security risk. We recommend considering 00252 * stronger message digests instead. 00253 * 00254 */ 00255 int mbedtls_md2_ret( const unsigned char *input, 00256 size_t ilen, 00257 unsigned char output[16] ); 00258 00259 #if !defined(MBEDTLS_DEPRECATED_REMOVED) 00260 #if defined(MBEDTLS_DEPRECATED_WARNING) 00261 #define MBEDTLS_DEPRECATED __attribute__((deprecated)) 00262 #else 00263 #define MBEDTLS_DEPRECATED 00264 #endif 00265 /** 00266 * \brief Output = MD2( input buffer ) 00267 * 00268 * \deprecated Superseded by mbedtls_md2_ret() in 2.7.0 00269 * 00270 * \param input buffer holding the data 00271 * \param ilen length of the input data 00272 * \param output MD2 checksum result 00273 * 00274 * \warning MD2 is considered a weak message digest and its use 00275 * constitutes a security risk. We recommend considering 00276 * stronger message digests instead. 00277 * 00278 */ 00279 MBEDTLS_DEPRECATED void mbedtls_md2( const unsigned char *input, 00280 size_t ilen, 00281 unsigned char output[16] ); 00282 00283 #undef MBEDTLS_DEPRECATED 00284 #endif /* !MBEDTLS_DEPRECATED_REMOVED */ 00285 00286 #if defined(MBEDTLS_SELF_TEST) 00287 00288 /** 00289 * \brief Checkup routine 00290 * 00291 * \return 0 if successful, or 1 if the test failed 00292 * 00293 * \warning MD2 is considered a weak message digest and its use 00294 * constitutes a security risk. We recommend considering 00295 * stronger message digests instead. 00296 * 00297 */ 00298 int mbedtls_md2_self_test( int verbose ); 00299 00300 #endif /* MBEDTLS_SELF_TEST */ 00301 00302 #ifdef __cplusplus 00303 } 00304 #endif 00305 00306 #endif /* mbedtls_md2.h */
Generated on Tue Jul 12 2022 13:54:34 by
