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 #ifdef __cplusplus 00044 extern "C" { 00045 #endif 00046 00047 #if !defined(MBEDTLS_MD4_ALT) 00048 // Regular implementation 00049 // 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 #else /* MBEDTLS_MD4_ALT */ 00068 #include "md4_alt.h" 00069 #endif /* MBEDTLS_MD4_ALT */ 00070 00071 /** 00072 * \brief Initialize MD4 context 00073 * 00074 * \param ctx MD4 context to be initialized 00075 * 00076 * \warning MD4 is considered a weak message digest and its use 00077 * constitutes a security risk. We recommend considering 00078 * stronger message digests instead. 00079 * 00080 */ 00081 void mbedtls_md4_init( mbedtls_md4_context *ctx ); 00082 00083 /** 00084 * \brief Clear MD4 context 00085 * 00086 * \param ctx MD4 context to be cleared 00087 * 00088 * \warning MD4 is considered a weak message digest and its use 00089 * constitutes a security risk. We recommend considering 00090 * stronger message digests instead. 00091 * 00092 */ 00093 void mbedtls_md4_free( mbedtls_md4_context *ctx ); 00094 00095 /** 00096 * \brief Clone (the state of) an MD4 context 00097 * 00098 * \param dst The destination context 00099 * \param src The context to be cloned 00100 * 00101 * \warning MD4 is considered a weak message digest and its use 00102 * constitutes a security risk. We recommend considering 00103 * stronger message digests instead. 00104 * 00105 */ 00106 void mbedtls_md4_clone( mbedtls_md4_context *dst, 00107 const mbedtls_md4_context *src ); 00108 00109 /** 00110 * \brief MD4 context setup 00111 * 00112 * \param ctx context to be initialized 00113 * 00114 * \return 0 if successful 00115 * 00116 * \warning MD4 is considered a weak message digest and its use 00117 * constitutes a security risk. We recommend considering 00118 * stronger message digests instead. 00119 */ 00120 int mbedtls_md4_starts_ret( mbedtls_md4_context *ctx ); 00121 00122 /** 00123 * \brief MD4 process buffer 00124 * 00125 * \param ctx MD4 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 MD4 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_md4_update_ret( mbedtls_md4_context *ctx, 00137 const unsigned char *input, 00138 size_t ilen ); 00139 00140 /** 00141 * \brief MD4 final digest 00142 * 00143 * \param ctx MD4 context 00144 * \param output MD4 checksum result 00145 * 00146 * \return 0 if successful 00147 * 00148 * \warning MD4 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_md4_finish_ret( mbedtls_md4_context *ctx, 00154 unsigned char output[16] ); 00155 00156 /** 00157 * \brief MD4 process data block (internal use only) 00158 * 00159 * \param ctx MD4 context 00160 * \param data buffer holding one block of data 00161 * 00162 * \return 0 if successful 00163 * 00164 * \warning MD4 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_md4_process( mbedtls_md4_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 MD4 context setup 00180 * 00181 * \deprecated Superseded by mbedtls_md4_starts_ret() in 2.7.0 00182 * 00183 * \param ctx context to be initialized 00184 * 00185 * \warning MD4 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_md4_starts( mbedtls_md4_context *ctx ); 00191 00192 /** 00193 * \brief MD4 process buffer 00194 * 00195 * \deprecated Superseded by mbedtls_md4_update_ret() in 2.7.0 00196 * 00197 * \param ctx MD4 context 00198 * \param input buffer holding the data 00199 * \param ilen length of the input data 00200 * 00201 * \warning MD4 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_md4_update( mbedtls_md4_context *ctx, 00207 const unsigned char *input, 00208 size_t ilen ); 00209 00210 /** 00211 * \brief MD4 final digest 00212 * 00213 * \deprecated Superseded by mbedtls_md4_finish_ret() in 2.7.0 00214 * 00215 * \param ctx MD4 context 00216 * \param output MD4 checksum result 00217 * 00218 * \warning MD4 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_md4_finish( mbedtls_md4_context *ctx, 00224 unsigned char output[16] ); 00225 00226 /** 00227 * \brief MD4 process data block (internal use only) 00228 * 00229 * \deprecated Superseded by mbedtls_internal_md4_process() in 2.7.0 00230 * 00231 * \param ctx MD4 context 00232 * \param data buffer holding one block of data 00233 * 00234 * \warning MD4 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_md4_process( mbedtls_md4_context *ctx, 00240 const unsigned char data[64] ); 00241 00242 #undef MBEDTLS_DEPRECATED 00243 #endif /* !MBEDTLS_DEPRECATED_REMOVED */ 00244 00245 /** 00246 * \brief Output = MD4( input buffer ) 00247 * 00248 * \param input buffer holding the data 00249 * \param ilen length of the input data 00250 * \param output MD4 checksum result 00251 * 00252 * \return 0 if successful 00253 * 00254 * \warning MD4 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_md4_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 = MD4( input buffer ) 00271 * 00272 * \deprecated Superseded by mbedtls_md4_ret() in 2.7.0 00273 * 00274 * \param input buffer holding the data 00275 * \param ilen length of the input data 00276 * \param output MD4 checksum result 00277 * 00278 * \warning MD4 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_md4( 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 MD4 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_md4_self_test( int verbose ); 00301 00302 #ifdef __cplusplus 00303 } 00304 #endif 00305 00306 #endif /* mbedtls_md4.h */
Generated on Tue Jul 12 2022 12:45:31 by
1.7.2