Gleb Klochkov / Mbed OS Climatcontroll_Main

Dependencies:   esp8266-driver

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers md2.h Source File

md2.h

Go to the documentation of this file.
00001 /**
00002  * \file md2.h
00003  *
00004  * \brief MD2 message digest algorithm (hash function)
00005  *
00006  * \warning MD2 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_MD2_H
00030 #define MBEDTLS_MD2_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 
00040 #define MBEDTLS_ERR_MD2_HW_ACCEL_FAILED                   -0x002B  /**< MD2 hardware accelerator failed */
00041 
00042 #if !defined(MBEDTLS_MD2_ALT)
00043 // Regular implementation
00044 //
00045 
00046 #ifdef __cplusplus
00047 extern "C" {
00048 #endif
00049 
00050 /**
00051  * \brief          MD2 context structure
00052  *
00053  * \warning        MD2 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
00059 {
00060     unsigned char cksum[16];    /*!< checksum of the data block */
00061     unsigned char state[48];    /*!< intermediate digest state  */
00062     unsigned char buffer[16];   /*!< data block being processed */
00063     size_t left ;                /*!< amount of data in buffer   */
00064 }
00065 mbedtls_md2_context;
00066 
00067 /**
00068  * \brief          Initialize MD2 context
00069  *
00070  * \param ctx      MD2 context to be initialized
00071  *
00072  * \warning        MD2 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_md2_init( mbedtls_md2_context *ctx );
00078 
00079 /**
00080  * \brief          Clear MD2 context
00081  *
00082  * \param ctx      MD2 context to be cleared
00083  *
00084  * \warning        MD2 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_md2_free( mbedtls_md2_context *ctx );
00090 
00091 /**
00092  * \brief          Clone (the state of) an MD2 context
00093  *
00094  * \param dst      The destination context
00095  * \param src      The context to be cloned
00096  *
00097  * \warning        MD2 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_md2_clone( mbedtls_md2_context *dst,
00103                         const mbedtls_md2_context *src );
00104 
00105 /**
00106  * \brief          MD2 context setup
00107  *
00108  * \param ctx      context to be initialized
00109  *
00110  * \return         0 if successful
00111  *
00112  * \warning        MD2 is considered a weak message digest and its use
00113  *                 constitutes a security risk. We recommend considering
00114  *                 stronger message digests instead.
00115  *
00116  */
00117 int mbedtls_md2_starts_ret( mbedtls_md2_context *ctx );
00118 
00119 /**
00120  * \brief          MD2 process buffer
00121  *
00122  * \param ctx      MD2 context
00123  * \param input    buffer holding the data
00124  * \param ilen     length of the input data
00125  *
00126  * \return         0 if successful
00127  *
00128  * \warning        MD2 is considered a weak message digest and its use
00129  *                 constitutes a security risk. We recommend considering
00130  *                 stronger message digests instead.
00131  *
00132  */
00133 int mbedtls_md2_update_ret( mbedtls_md2_context *ctx,
00134                             const unsigned char *input,
00135                             size_t ilen );
00136 
00137 /**
00138  * \brief          MD2 final digest
00139  *
00140  * \param ctx      MD2 context
00141  * \param output   MD2 checksum result
00142  *
00143  * \return         0 if successful
00144  *
00145  * \warning        MD2 is considered a weak message digest and its use
00146  *                 constitutes a security risk. We recommend considering
00147  *                 stronger message digests instead.
00148  *
00149  */
00150 int mbedtls_md2_finish_ret( mbedtls_md2_context *ctx,
00151                             unsigned char output[16] );
00152 
00153 /**
00154  * \brief          MD2 process data block (internal use only)
00155  *
00156  * \param ctx      MD2 context
00157  *
00158  * \return         0 if successful
00159  *
00160  * \warning        MD2 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_md2_process( mbedtls_md2_context *ctx );
00166 
00167 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
00168 #if defined(MBEDTLS_DEPRECATED_WARNING)
00169 #define MBEDTLS_DEPRECATED      __attribute__((deprecated))
00170 #else
00171 #define MBEDTLS_DEPRECATED
00172 #endif
00173 /**
00174  * \brief          MD2 context setup
00175  *
00176  * \deprecated     Superseded by mbedtls_md2_starts_ret() in 2.7.0
00177  *
00178  * \param ctx      context to be initialized
00179  *
00180  * \warning        MD2 is considered a weak message digest and its use
00181  *                 constitutes a security risk. We recommend considering
00182  *                 stronger message digests instead.
00183  *
00184  */
00185 MBEDTLS_DEPRECATED void mbedtls_md2_starts( mbedtls_md2_context *ctx );
00186 
00187 /**
00188  * \brief          MD2 process buffer
00189  *
00190  * \deprecated     Superseded by mbedtls_md2_update_ret() in 2.7.0
00191  *
00192  * \param ctx      MD2 context
00193  * \param input    buffer holding the data
00194  * \param ilen     length of the input data
00195  *
00196  * \warning        MD2 is considered a weak message digest and its use
00197  *                 constitutes a security risk. We recommend considering
00198  *                 stronger message digests instead.
00199  *
00200  */
00201 MBEDTLS_DEPRECATED void mbedtls_md2_update( mbedtls_md2_context *ctx,
00202                                             const unsigned char *input,
00203                                             size_t ilen );
00204 
00205 /**
00206  * \brief          MD2 final digest
00207  *
00208  * \deprecated     Superseded by mbedtls_md2_finish_ret() in 2.7.0
00209  *
00210  * \param ctx      MD2 context
00211  * \param output   MD2 checksum result
00212  *
00213  * \warning        MD2 is considered a weak message digest and its use
00214  *                 constitutes a security risk. We recommend considering
00215  *                 stronger message digests instead.
00216  *
00217  */
00218 MBEDTLS_DEPRECATED void mbedtls_md2_finish( mbedtls_md2_context *ctx,
00219                                             unsigned char output[16] );
00220 
00221 /**
00222  * \brief          MD2 process data block (internal use only)
00223  *
00224  * \deprecated     Superseded by mbedtls_internal_md2_process() in 2.7.0
00225  *
00226  * \param ctx      MD2 context
00227  *
00228  * \warning        MD2 is considered a weak message digest and its use
00229  *                 constitutes a security risk. We recommend considering
00230  *                 stronger message digests instead.
00231  *
00232  */
00233 MBEDTLS_DEPRECATED void mbedtls_md2_process( mbedtls_md2_context *ctx );
00234 
00235 #undef MBEDTLS_DEPRECATED
00236 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
00237 
00238 #ifdef __cplusplus
00239 }
00240 #endif
00241 
00242 #else  /* MBEDTLS_MD2_ALT */
00243 #include "md2_alt.h"
00244 #endif /* MBEDTLS_MD2_ALT */
00245 
00246 #ifdef __cplusplus
00247 extern "C" {
00248 #endif
00249 
00250 /**
00251  * \brief          Output = MD2( input buffer )
00252  *
00253  * \param input    buffer holding the data
00254  * \param ilen     length of the input data
00255  * \param output   MD2 checksum result
00256  *
00257  * \warning        MD2 is considered a weak message digest and its use
00258  *                 constitutes a security risk. We recommend considering
00259  *                 stronger message digests instead.
00260  *
00261  */
00262 int mbedtls_md2_ret( const unsigned char *input,
00263                      size_t ilen,
00264                      unsigned char output[16] );
00265 
00266 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
00267 #if defined(MBEDTLS_DEPRECATED_WARNING)
00268 #define MBEDTLS_DEPRECATED      __attribute__((deprecated))
00269 #else
00270 #define MBEDTLS_DEPRECATED
00271 #endif
00272 /**
00273  * \brief          Output = MD2( input buffer )
00274  *
00275  * \deprecated     Superseded by mbedtls_md2_ret() in 2.7.0
00276  *
00277  * \param input    buffer holding the data
00278  * \param ilen     length of the input data
00279  * \param output   MD2 checksum result
00280  *
00281  * \warning        MD2 is considered a weak message digest and its use
00282  *                 constitutes a security risk. We recommend considering
00283  *                 stronger message digests instead.
00284  *
00285  */
00286 MBEDTLS_DEPRECATED void mbedtls_md2( const unsigned char *input,
00287                                      size_t ilen,
00288                                      unsigned char output[16] );
00289 
00290 #undef MBEDTLS_DEPRECATED
00291 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
00292 
00293 /**
00294  * \brief          Checkup routine
00295  *
00296  * \return         0 if successful, or 1 if the test failed
00297  *
00298  * \warning        MD2 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_md2_self_test( int verbose );
00304 
00305 #ifdef __cplusplus
00306 }
00307 #endif
00308 
00309 #endif /* mbedtls_md2.h */