mbed TLS library
Dependents: HTTPClient-SSL WS_SERVER
md4.h
00001 /** 00002 * \file md4.h 00003 * 00004 * \brief MD4 message digest algorithm (hash function) 00005 * 00006 * Copyright (C) 2006-2014, ARM Limited, All Rights Reserved 00007 * 00008 * This file is part of mbed TLS (https://tls.mbed.org) 00009 * 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License along 00021 * with this program; if not, write to the Free Software Foundation, Inc., 00022 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00023 */ 00024 #ifndef POLARSSL_MD4_H 00025 #define POLARSSL_MD4_H 00026 00027 #if !defined(POLARSSL_CONFIG_FILE) 00028 #include "config.h" 00029 #else 00030 #include POLARSSL_CONFIG_FILE 00031 #endif 00032 00033 #include <stddef.h> 00034 00035 #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32) 00036 #include <basetsd.h> 00037 typedef UINT32 uint32_t; 00038 #else 00039 #include <inttypes.h> 00040 #endif 00041 00042 #define POLARSSL_ERR_MD4_FILE_IO_ERROR -0x0072 /**< Read/write error in file. */ 00043 00044 #if !defined(POLARSSL_MD4_ALT) 00045 // Regular implementation 00046 // 00047 00048 #ifdef __cplusplus 00049 extern "C" { 00050 #endif 00051 00052 /** 00053 * \brief MD4 context structure 00054 */ 00055 typedef struct 00056 { 00057 uint32_t total[2]; /*!< number of bytes processed */ 00058 uint32_t state[4]; /*!< intermediate digest state */ 00059 unsigned char buffer[64]; /*!< data block being processed */ 00060 00061 unsigned char ipad[64]; /*!< HMAC: inner padding */ 00062 unsigned char opad[64]; /*!< HMAC: outer padding */ 00063 } 00064 md4_context; 00065 00066 /** 00067 * \brief Initialize MD4 context 00068 * 00069 * \param ctx MD4 context to be initialized 00070 */ 00071 void md4_init( md4_context *ctx ); 00072 00073 /** 00074 * \brief Clear MD4 context 00075 * 00076 * \param ctx MD4 context to be cleared 00077 */ 00078 void md4_free( md4_context *ctx ); 00079 00080 /** 00081 * \brief MD4 context setup 00082 * 00083 * \param ctx context to be initialized 00084 */ 00085 void md4_starts( md4_context *ctx ); 00086 00087 /** 00088 * \brief MD4 process buffer 00089 * 00090 * \param ctx MD4 context 00091 * \param input buffer holding the data 00092 * \param ilen length of the input data 00093 */ 00094 void md4_update( md4_context *ctx, const unsigned char *input, size_t ilen ); 00095 00096 /** 00097 * \brief MD4 final digest 00098 * 00099 * \param ctx MD4 context 00100 * \param output MD4 checksum result 00101 */ 00102 void md4_finish( md4_context *ctx, unsigned char output[16] ); 00103 00104 #ifdef __cplusplus 00105 } 00106 #endif 00107 00108 #else /* POLARSSL_MD4_ALT */ 00109 #include "md4_alt.h" 00110 #endif /* POLARSSL_MD4_ALT */ 00111 00112 #ifdef __cplusplus 00113 extern "C" { 00114 #endif 00115 00116 /** 00117 * \brief Output = MD4( input buffer ) 00118 * 00119 * \param input buffer holding the data 00120 * \param ilen length of the input data 00121 * \param output MD4 checksum result 00122 */ 00123 void md4( const unsigned char *input, size_t ilen, unsigned char output[16] ); 00124 00125 /** 00126 * \brief Output = MD4( file contents ) 00127 * 00128 * \param path input file name 00129 * \param output MD4 checksum result 00130 * 00131 * \return 0 if successful, or POLARSSL_ERR_MD4_FILE_IO_ERROR 00132 */ 00133 int md4_file( const char *path, unsigned char output[16] ); 00134 00135 /** 00136 * \brief MD4 HMAC context setup 00137 * 00138 * \param ctx HMAC context to be initialized 00139 * \param key HMAC secret key 00140 * \param keylen length of the HMAC key 00141 */ 00142 void md4_hmac_starts( md4_context *ctx, const unsigned char *key, 00143 size_t keylen ); 00144 00145 /** 00146 * \brief MD4 HMAC process buffer 00147 * 00148 * \param ctx HMAC context 00149 * \param input buffer holding the data 00150 * \param ilen length of the input data 00151 */ 00152 void md4_hmac_update( md4_context *ctx, const unsigned char *input, 00153 size_t ilen ); 00154 00155 /** 00156 * \brief MD4 HMAC final digest 00157 * 00158 * \param ctx HMAC context 00159 * \param output MD4 HMAC checksum result 00160 */ 00161 void md4_hmac_finish( md4_context *ctx, unsigned char output[16] ); 00162 00163 /** 00164 * \brief MD4 HMAC context reset 00165 * 00166 * \param ctx HMAC context to be reset 00167 */ 00168 void md4_hmac_reset( md4_context *ctx ); 00169 00170 /** 00171 * \brief Output = HMAC-MD4( hmac key, input buffer ) 00172 * 00173 * \param key HMAC secret key 00174 * \param keylen length of the HMAC key 00175 * \param input buffer holding the data 00176 * \param ilen length of the input data 00177 * \param output HMAC-MD4 result 00178 */ 00179 void md4_hmac( const unsigned char *key, size_t keylen, 00180 const unsigned char *input, size_t ilen, 00181 unsigned char output[16] ); 00182 00183 /** 00184 * \brief Checkup routine 00185 * 00186 * \return 0 if successful, or 1 if the test failed 00187 */ 00188 int md4_self_test( int verbose ); 00189 00190 /* Internal use */ 00191 void md4_process( md4_context *ctx, const unsigned char data[64] ); 00192 00193 #ifdef __cplusplus 00194 } 00195 #endif 00196 00197 #endif /* md4.h */ 00198
Generated on Tue Jul 12 2022 13:50:37 by 1.7.2