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.
md5.h
00001 /** 00002 * \file md5.h 00003 * 00004 * \brief MD5 message digest algorithm (hash function) 00005 * 00006 * \warning MD5 is considered a weak message digest and its use constitutes a 00007 * security risk. We recommend considering stronger message 00008 * digests 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 #ifndef MBEDTLS_MD5_H 00029 #define MBEDTLS_MD5_H 00030 00031 #if !defined(MBEDTLS_CONFIG_FILE) 00032 #include "config.h" 00033 #else 00034 #include MBEDTLS_CONFIG_FILE 00035 #endif 00036 00037 #include <stddef.h> 00038 #include <stdint.h> 00039 00040 #define MBEDTLS_ERR_MD5_HW_ACCEL_FAILED -0x002F /**< MD5 hardware accelerator failed */ 00041 00042 #ifdef __cplusplus 00043 extern "C" { 00044 #endif 00045 00046 #if !defined(MBEDTLS_MD5_ALT) 00047 // Regular implementation 00048 // 00049 00050 /** 00051 * \brief MD5 context structure 00052 * 00053 * \warning MD5 is considered a weak message digest and its use 00054 * constitutes a security risk. We recommend considering 00055 * stronger message digests instead. 00056 * 00057 */ 00058 typedef struct mbedtls_md5_context 00059 { 00060 uint32_t total [2]; /*!< number of bytes processed */ 00061 uint32_t state [4]; /*!< intermediate digest state */ 00062 unsigned char buffer[64]; /*!< data block being processed */ 00063 } 00064 mbedtls_md5_context; 00065 00066 #else /* MBEDTLS_MD5_ALT */ 00067 #include "md5_alt.h" 00068 #endif /* MBEDTLS_MD5_ALT */ 00069 00070 /** 00071 * \brief Initialize MD5 context 00072 * 00073 * \param ctx MD5 context to be initialized 00074 * 00075 * \warning MD5 is considered a weak message digest and its use 00076 * constitutes a security risk. We recommend considering 00077 * stronger message digests instead. 00078 * 00079 */ 00080 void mbedtls_md5_init( mbedtls_md5_context *ctx ); 00081 00082 /** 00083 * \brief Clear MD5 context 00084 * 00085 * \param ctx MD5 context to be cleared 00086 * 00087 * \warning MD5 is considered a weak message digest and its use 00088 * constitutes a security risk. We recommend considering 00089 * stronger message digests instead. 00090 * 00091 */ 00092 void mbedtls_md5_free( mbedtls_md5_context *ctx ); 00093 00094 /** 00095 * \brief Clone (the state of) an MD5 context 00096 * 00097 * \param dst The destination context 00098 * \param src The context to be cloned 00099 * 00100 * \warning MD5 is considered a weak message digest and its use 00101 * constitutes a security risk. We recommend considering 00102 * stronger message digests instead. 00103 * 00104 */ 00105 void mbedtls_md5_clone( mbedtls_md5_context *dst, 00106 const mbedtls_md5_context *src ); 00107 00108 /** 00109 * \brief MD5 context setup 00110 * 00111 * \param ctx context to be initialized 00112 * 00113 * \return 0 if successful 00114 * 00115 * \warning MD5 is considered a weak message digest and its use 00116 * constitutes a security risk. We recommend considering 00117 * stronger message digests instead. 00118 * 00119 */ 00120 int mbedtls_md5_starts_ret( mbedtls_md5_context *ctx ); 00121 00122 /** 00123 * \brief MD5 process buffer 00124 * 00125 * \param ctx MD5 context 00126 * \param input buffer holding the data 00127 * \param ilen length of the input data 00128 * 00129 * \return 0 if successful 00130 * 00131 * \warning MD5 is considered a weak message digest and its use 00132 * constitutes a security risk. We recommend considering 00133 * stronger message digests instead. 00134 * 00135 */ 00136 int mbedtls_md5_update_ret( mbedtls_md5_context *ctx, 00137 const unsigned char *input, 00138 size_t ilen ); 00139 00140 /** 00141 * \brief MD5 final digest 00142 * 00143 * \param ctx MD5 context 00144 * \param output MD5 checksum result 00145 * 00146 * \return 0 if successful 00147 * 00148 * \warning MD5 is considered a weak message digest and its use 00149 * constitutes a security risk. We recommend considering 00150 * stronger message digests instead. 00151 * 00152 */ 00153 int mbedtls_md5_finish_ret( mbedtls_md5_context *ctx, 00154 unsigned char output[16] ); 00155 00156 /** 00157 * \brief MD5 process data block (internal use only) 00158 * 00159 * \param ctx MD5 context 00160 * \param data buffer holding one block of data 00161 * 00162 * \return 0 if successful 00163 * 00164 * \warning MD5 is considered a weak message digest and its use 00165 * constitutes a security risk. We recommend considering 00166 * stronger message digests instead. 00167 * 00168 */ 00169 int mbedtls_internal_md5_process( mbedtls_md5_context *ctx, 00170 const unsigned char data[64] ); 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 MD5 context setup 00180 * 00181 * \deprecated Superseded by mbedtls_md5_starts_ret() in 2.7.0 00182 * 00183 * \param ctx context to be initialized 00184 * 00185 * \warning MD5 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_md5_starts( mbedtls_md5_context *ctx ); 00191 00192 /** 00193 * \brief MD5 process buffer 00194 * 00195 * \deprecated Superseded by mbedtls_md5_update_ret() in 2.7.0 00196 * 00197 * \param ctx MD5 context 00198 * \param input buffer holding the data 00199 * \param ilen length of the input data 00200 * 00201 * \warning MD5 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_md5_update( mbedtls_md5_context *ctx, 00207 const unsigned char *input, 00208 size_t ilen ); 00209 00210 /** 00211 * \brief MD5 final digest 00212 * 00213 * \deprecated Superseded by mbedtls_md5_finish_ret() in 2.7.0 00214 * 00215 * \param ctx MD5 context 00216 * \param output MD5 checksum result 00217 * 00218 * \warning MD5 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_md5_finish( mbedtls_md5_context *ctx, 00224 unsigned char output[16] ); 00225 00226 /** 00227 * \brief MD5 process data block (internal use only) 00228 * 00229 * \deprecated Superseded by mbedtls_internal_md5_process() in 2.7.0 00230 * 00231 * \param ctx MD5 context 00232 * \param data buffer holding one block of data 00233 * 00234 * \warning MD5 is considered a weak message digest and its use 00235 * constitutes a security risk. We recommend considering 00236 * stronger message digests instead. 00237 * 00238 */ 00239 MBEDTLS_DEPRECATED void mbedtls_md5_process( mbedtls_md5_context *ctx, 00240 const unsigned char data[64] ); 00241 00242 #undef MBEDTLS_DEPRECATED 00243 #endif /* !MBEDTLS_DEPRECATED_REMOVED */ 00244 00245 /** 00246 * \brief Output = MD5( input buffer ) 00247 * 00248 * \param input buffer holding the data 00249 * \param ilen length of the input data 00250 * \param output MD5 checksum result 00251 * 00252 * \return 0 if successful 00253 * 00254 * \warning MD5 is considered a weak message digest and its use 00255 * constitutes a security risk. We recommend considering 00256 * stronger message digests instead. 00257 * 00258 */ 00259 int mbedtls_md5_ret( const unsigned char *input, 00260 size_t ilen, 00261 unsigned char output[16] ); 00262 00263 #if !defined(MBEDTLS_DEPRECATED_REMOVED) 00264 #if defined(MBEDTLS_DEPRECATED_WARNING) 00265 #define MBEDTLS_DEPRECATED __attribute__((deprecated)) 00266 #else 00267 #define MBEDTLS_DEPRECATED 00268 #endif 00269 /** 00270 * \brief Output = MD5( input buffer ) 00271 * 00272 * \deprecated Superseded by mbedtls_md5_ret() in 2.7.0 00273 * 00274 * \param input buffer holding the data 00275 * \param ilen length of the input data 00276 * \param output MD5 checksum result 00277 * 00278 * \warning MD5 is considered a weak message digest and its use 00279 * constitutes a security risk. We recommend considering 00280 * stronger message digests instead. 00281 * 00282 */ 00283 MBEDTLS_DEPRECATED void mbedtls_md5( const unsigned char *input, 00284 size_t ilen, 00285 unsigned char output[16] ); 00286 00287 #undef MBEDTLS_DEPRECATED 00288 #endif /* !MBEDTLS_DEPRECATED_REMOVED */ 00289 00290 /** 00291 * \brief Checkup routine 00292 * 00293 * \return 0 if successful, or 1 if the test failed 00294 * 00295 * \warning MD5 is considered a weak message digest and its use 00296 * constitutes a security risk. We recommend considering 00297 * stronger message digests instead. 00298 * 00299 */ 00300 int mbedtls_md5_self_test( int verbose ); 00301 00302 #ifdef __cplusplus 00303 } 00304 #endif 00305 00306 #endif /* mbedtls_md5.h */
Generated on Tue Jul 12 2022 13:53:25 by
