Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers md4.h Source File

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