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