Kenji Arai / TYBLE16_mbedlized_os5_several_examples_1st

Dependencies:   nRF51_Vdd TextLCD BME280

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 #ifdef __cplusplus
00043 extern "C" {
00044 #endif
00045 
00046 #if !defined(MBEDTLS_MD2_ALT)
00047 // Regular implementation
00048 //
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 mbedtls_md2_context
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 #else  /* MBEDTLS_MD2_ALT */
00068 #include "md2_alt.h"
00069 #endif /* MBEDTLS_MD2_ALT */
00070 
00071 /**
00072  * \brief          Initialize MD2 context
00073  *
00074  * \param ctx      MD2 context to be initialized
00075  *
00076  * \warning        MD2 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_md2_init( mbedtls_md2_context *ctx );
00082 
00083 /**
00084  * \brief          Clear MD2 context
00085  *
00086  * \param ctx      MD2 context to be cleared
00087  *
00088  * \warning        MD2 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_md2_free( mbedtls_md2_context *ctx );
00094 
00095 /**
00096  * \brief          Clone (the state of) an MD2 context
00097  *
00098  * \param dst      The destination context
00099  * \param src      The context to be cloned
00100  *
00101  * \warning        MD2 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_md2_clone( mbedtls_md2_context *dst,
00107                         const mbedtls_md2_context *src );
00108 
00109 /**
00110  * \brief          MD2 context setup
00111  *
00112  * \param ctx      context to be initialized
00113  *
00114  * \return         0 if successful
00115  *
00116  * \warning        MD2 is considered a weak message digest and its use
00117  *                 constitutes a security risk. We recommend considering
00118  *                 stronger message digests instead.
00119  *
00120  */
00121 int mbedtls_md2_starts_ret( mbedtls_md2_context *ctx );
00122 
00123 /**
00124  * \brief          MD2 process buffer
00125  *
00126  * \param ctx      MD2 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        MD2 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_md2_update_ret( mbedtls_md2_context *ctx,
00138                             const unsigned char *input,
00139                             size_t ilen );
00140 
00141 /**
00142  * \brief          MD2 final digest
00143  *
00144  * \param ctx      MD2 context
00145  * \param output   MD2 checksum result
00146  *
00147  * \return         0 if successful
00148  *
00149  * \warning        MD2 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_md2_finish_ret( mbedtls_md2_context *ctx,
00155                             unsigned char output[16] );
00156 
00157 /**
00158  * \brief          MD2 process data block (internal use only)
00159  *
00160  * \param ctx      MD2 context
00161  *
00162  * \return         0 if successful
00163  *
00164  * \warning        MD2 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_md2_process( mbedtls_md2_context *ctx );
00170 
00171 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
00172 #if defined(MBEDTLS_DEPRECATED_WARNING)
00173 #define MBEDTLS_DEPRECATED      __attribute__((deprecated))
00174 #else
00175 #define MBEDTLS_DEPRECATED
00176 #endif
00177 /**
00178  * \brief          MD2 context setup
00179  *
00180  * \deprecated     Superseded by mbedtls_md2_starts_ret() in 2.7.0
00181  *
00182  * \param ctx      context to be initialized
00183  *
00184  * \warning        MD2 is considered a weak message digest and its use
00185  *                 constitutes a security risk. We recommend considering
00186  *                 stronger message digests instead.
00187  *
00188  */
00189 MBEDTLS_DEPRECATED void mbedtls_md2_starts( mbedtls_md2_context *ctx );
00190 
00191 /**
00192  * \brief          MD2 process buffer
00193  *
00194  * \deprecated     Superseded by mbedtls_md2_update_ret() in 2.7.0
00195  *
00196  * \param ctx      MD2 context
00197  * \param input    buffer holding the data
00198  * \param ilen     length of the input data
00199  *
00200  * \warning        MD2 is considered a weak message digest and its use
00201  *                 constitutes a security risk. We recommend considering
00202  *                 stronger message digests instead.
00203  *
00204  */
00205 MBEDTLS_DEPRECATED void mbedtls_md2_update( mbedtls_md2_context *ctx,
00206                                             const unsigned char *input,
00207                                             size_t ilen );
00208 
00209 /**
00210  * \brief          MD2 final digest
00211  *
00212  * \deprecated     Superseded by mbedtls_md2_finish_ret() in 2.7.0
00213  *
00214  * \param ctx      MD2 context
00215  * \param output   MD2 checksum result
00216  *
00217  * \warning        MD2 is considered a weak message digest and its use
00218  *                 constitutes a security risk. We recommend considering
00219  *                 stronger message digests instead.
00220  *
00221  */
00222 MBEDTLS_DEPRECATED void mbedtls_md2_finish( mbedtls_md2_context *ctx,
00223                                             unsigned char output[16] );
00224 
00225 /**
00226  * \brief          MD2 process data block (internal use only)
00227  *
00228  * \deprecated     Superseded by mbedtls_internal_md2_process() in 2.7.0
00229  *
00230  * \param ctx      MD2 context
00231  *
00232  * \warning        MD2 is considered a weak message digest and its use
00233  *                 constitutes a security risk. We recommend considering
00234  *                 stronger message digests instead.
00235  *
00236  */
00237 MBEDTLS_DEPRECATED void mbedtls_md2_process( mbedtls_md2_context *ctx );
00238 
00239 #undef MBEDTLS_DEPRECATED
00240 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
00241 
00242 /**
00243  * \brief          Output = MD2( input buffer )
00244  *
00245  * \param input    buffer holding the data
00246  * \param ilen     length of the input data
00247  * \param output   MD2 checksum result
00248  *
00249  * \warning        MD2 is considered a weak message digest and its use
00250  *                 constitutes a security risk. We recommend considering
00251  *                 stronger message digests instead.
00252  *
00253  */
00254 int mbedtls_md2_ret( const unsigned char *input,
00255                      size_t ilen,
00256                      unsigned char output[16] );
00257 
00258 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
00259 #if defined(MBEDTLS_DEPRECATED_WARNING)
00260 #define MBEDTLS_DEPRECATED      __attribute__((deprecated))
00261 #else
00262 #define MBEDTLS_DEPRECATED
00263 #endif
00264 /**
00265  * \brief          Output = MD2( input buffer )
00266  *
00267  * \deprecated     Superseded by mbedtls_md2_ret() in 2.7.0
00268  *
00269  * \param input    buffer holding the data
00270  * \param ilen     length of the input data
00271  * \param output   MD2 checksum result
00272  *
00273  * \warning        MD2 is considered a weak message digest and its use
00274  *                 constitutes a security risk. We recommend considering
00275  *                 stronger message digests instead.
00276  *
00277  */
00278 MBEDTLS_DEPRECATED void mbedtls_md2( const unsigned char *input,
00279                                      size_t ilen,
00280                                      unsigned char output[16] );
00281 
00282 #undef MBEDTLS_DEPRECATED
00283 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
00284 
00285 /**
00286  * \brief          Checkup routine
00287  *
00288  * \return         0 if successful, or 1 if the test failed
00289  *
00290  * \warning        MD2 is considered a weak message digest and its use
00291  *                 constitutes a security risk. We recommend considering
00292  *                 stronger message digests instead.
00293  *
00294  */
00295 int mbedtls_md2_self_test( int verbose );
00296 
00297 #ifdef __cplusplus
00298 }
00299 #endif
00300 
00301 #endif /* mbedtls_md2.h */