Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ripemd160.h Source File

ripemd160.h

Go to the documentation of this file.
00001 /**
00002  * \file ripemd160.h
00003  *
00004  * \brief RIPE MD-160 message digest
00005  */
00006 /*
00007  *  Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
00008  *  SPDX-License-Identifier: Apache-2.0
00009  *
00010  *  Licensed under the Apache License, Version 2.0 (the "License"); you may
00011  *  not use this file except in compliance with the License.
00012  *  You may obtain a copy of the License at
00013  *
00014  *  http://www.apache.org/licenses/LICENSE-2.0
00015  *
00016  *  Unless required by applicable law or agreed to in writing, software
00017  *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00018  *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00019  *  See the License for the specific language governing permissions and
00020  *  limitations under the License.
00021  *
00022  *  This file is part of mbed TLS (https://tls.mbed.org)
00023  */
00024 #ifndef MBEDTLS_RIPEMD160_H
00025 #define MBEDTLS_RIPEMD160_H
00026 
00027 #if !defined(MBEDTLS_CONFIG_FILE)
00028 #include "mbedtls/config.h"
00029 #else
00030 #include MBEDTLS_CONFIG_FILE
00031 #endif
00032 
00033 #include <stddef.h>
00034 #include <stdint.h>
00035 
00036 /* MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED is deprecated and should not be used.
00037  */
00038 #define MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED             -0x0031  /**< RIPEMD160 hardware accelerator failed */
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00044 #if !defined(MBEDTLS_RIPEMD160_ALT)
00045 // Regular implementation
00046 //
00047 
00048 /**
00049  * \brief          RIPEMD-160 context structure
00050  */
00051 typedef struct mbedtls_ripemd160_context
00052 {
00053     uint32_t total [2];          /*!< number of bytes processed  */
00054     uint32_t state [5];          /*!< intermediate digest state  */
00055     unsigned char buffer[64];   /*!< data block being processed */
00056 }
00057 mbedtls_ripemd160_context;
00058 
00059 #else  /* MBEDTLS_RIPEMD160_ALT */
00060 #include "ripemd160_alt.h"
00061 #endif /* MBEDTLS_RIPEMD160_ALT */
00062 
00063 /**
00064  * \brief          Initialize RIPEMD-160 context
00065  *
00066  * \param ctx      RIPEMD-160 context to be initialized
00067  */
00068 void mbedtls_ripemd160_init( mbedtls_ripemd160_context *ctx );
00069 
00070 /**
00071  * \brief          Clear RIPEMD-160 context
00072  *
00073  * \param ctx      RIPEMD-160 context to be cleared
00074  */
00075 void mbedtls_ripemd160_free( mbedtls_ripemd160_context *ctx );
00076 
00077 /**
00078  * \brief          Clone (the state of) an RIPEMD-160 context
00079  *
00080  * \param dst      The destination context
00081  * \param src      The context to be cloned
00082  */
00083 void mbedtls_ripemd160_clone( mbedtls_ripemd160_context *dst,
00084                         const mbedtls_ripemd160_context *src );
00085 
00086 /**
00087  * \brief          RIPEMD-160 context setup
00088  *
00089  * \param ctx      context to be initialized
00090  *
00091  * \return         0 if successful
00092  */
00093 int mbedtls_ripemd160_starts_ret( mbedtls_ripemd160_context *ctx );
00094 
00095 /**
00096  * \brief          RIPEMD-160 process buffer
00097  *
00098  * \param ctx      RIPEMD-160 context
00099  * \param input    buffer holding the data
00100  * \param ilen     length of the input data
00101  *
00102  * \return         0 if successful
00103  */
00104 int mbedtls_ripemd160_update_ret( mbedtls_ripemd160_context *ctx,
00105                                   const unsigned char *input,
00106                                   size_t ilen );
00107 
00108 /**
00109  * \brief          RIPEMD-160 final digest
00110  *
00111  * \param ctx      RIPEMD-160 context
00112  * \param output   RIPEMD-160 checksum result
00113  *
00114  * \return         0 if successful
00115  */
00116 int mbedtls_ripemd160_finish_ret( mbedtls_ripemd160_context *ctx,
00117                                   unsigned char output[20] );
00118 
00119 /**
00120  * \brief          RIPEMD-160 process data block (internal use only)
00121  *
00122  * \param ctx      RIPEMD-160 context
00123  * \param data     buffer holding one block of data
00124  *
00125  * \return         0 if successful
00126  */
00127 int mbedtls_internal_ripemd160_process( mbedtls_ripemd160_context *ctx,
00128                                         const unsigned char data[64] );
00129 
00130 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
00131 #if defined(MBEDTLS_DEPRECATED_WARNING)
00132 #define MBEDTLS_DEPRECATED      __attribute__((deprecated))
00133 #else
00134 #define MBEDTLS_DEPRECATED
00135 #endif
00136 /**
00137  * \brief          RIPEMD-160 context setup
00138  *
00139  * \deprecated     Superseded by mbedtls_ripemd160_starts_ret() in 2.7.0
00140  *
00141  * \param ctx      context to be initialized
00142  */
00143 MBEDTLS_DEPRECATED void mbedtls_ripemd160_starts(
00144                                             mbedtls_ripemd160_context *ctx );
00145 
00146 /**
00147  * \brief          RIPEMD-160 process buffer
00148  *
00149  * \deprecated     Superseded by mbedtls_ripemd160_update_ret() in 2.7.0
00150  *
00151  * \param ctx      RIPEMD-160 context
00152  * \param input    buffer holding the data
00153  * \param ilen     length of the input data
00154  */
00155 MBEDTLS_DEPRECATED void mbedtls_ripemd160_update(
00156                                                 mbedtls_ripemd160_context *ctx,
00157                                                 const unsigned char *input,
00158                                                 size_t ilen );
00159 
00160 /**
00161  * \brief          RIPEMD-160 final digest
00162  *
00163  * \deprecated     Superseded by mbedtls_ripemd160_finish_ret() in 2.7.0
00164  *
00165  * \param ctx      RIPEMD-160 context
00166  * \param output   RIPEMD-160 checksum result
00167  */
00168 MBEDTLS_DEPRECATED void mbedtls_ripemd160_finish(
00169                                                 mbedtls_ripemd160_context *ctx,
00170                                                 unsigned char output[20] );
00171 
00172 /**
00173  * \brief          RIPEMD-160 process data block (internal use only)
00174  *
00175  * \deprecated     Superseded by mbedtls_internal_ripemd160_process() in 2.7.0
00176  *
00177  * \param ctx      RIPEMD-160 context
00178  * \param data     buffer holding one block of data
00179  */
00180 MBEDTLS_DEPRECATED void mbedtls_ripemd160_process(
00181                                             mbedtls_ripemd160_context *ctx,
00182                                             const unsigned char data[64] );
00183 
00184 #undef MBEDTLS_DEPRECATED
00185 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
00186 
00187 /**
00188  * \brief          Output = RIPEMD-160( input buffer )
00189  *
00190  * \param input    buffer holding the data
00191  * \param ilen     length of the input data
00192  * \param output   RIPEMD-160 checksum result
00193  *
00194  * \return         0 if successful
00195  */
00196 int mbedtls_ripemd160_ret( const unsigned char *input,
00197                            size_t ilen,
00198                            unsigned char output[20] );
00199 
00200 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
00201 #if defined(MBEDTLS_DEPRECATED_WARNING)
00202 #define MBEDTLS_DEPRECATED      __attribute__((deprecated))
00203 #else
00204 #define MBEDTLS_DEPRECATED
00205 #endif
00206 /**
00207  * \brief          Output = RIPEMD-160( input buffer )
00208  *
00209  * \deprecated     Superseded by mbedtls_ripemd160_ret() in 2.7.0
00210  *
00211  * \param input    buffer holding the data
00212  * \param ilen     length of the input data
00213  * \param output   RIPEMD-160 checksum result
00214  */
00215 MBEDTLS_DEPRECATED void mbedtls_ripemd160( const unsigned char *input,
00216                                            size_t ilen,
00217                                            unsigned char output[20] );
00218 
00219 #undef MBEDTLS_DEPRECATED
00220 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
00221 
00222 #if defined(MBEDTLS_SELF_TEST)
00223 
00224 /**
00225  * \brief          Checkup routine
00226  *
00227  * \return         0 if successful, or 1 if the test failed
00228  */
00229 int mbedtls_ripemd160_self_test( int verbose );
00230 
00231 #endif /* MBEDTLS_SELF_TEST */
00232 
00233 #ifdef __cplusplus
00234 }
00235 #endif
00236 
00237 #endif /* mbedtls_ripemd160.h */