Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /**
  2.  * \file ripemd160.h
  3.  *
  4.  * \brief RIPE MD-160 message digest
  5.  */
  6. /*
  7.  *  Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
  8.  *  SPDX-License-Identifier: GPL-2.0
  9.  *
  10.  *  This program is free software; you can redistribute it and/or modify
  11.  *  it under the terms of the GNU General Public License as published by
  12.  *  the Free Software Foundation; either version 2 of the License, or
  13.  *  (at your option) any later version.
  14.  *
  15.  *  This program is distributed in the hope that it will be useful,
  16.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  *  GNU General Public License for more details.
  19.  *
  20.  *  You should have received a copy of the GNU General Public License along
  21.  *  with this program; if not, write to the Free Software Foundation, Inc.,
  22.  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  23.  *
  24.  *  This file is part of mbed TLS (https://tls.mbed.org)
  25.  */
  26. #ifndef MBEDTLS_RIPEMD160_H
  27. #define MBEDTLS_RIPEMD160_H
  28.  
  29. #if !defined(MBEDTLS_CONFIG_FILE)
  30. #include "config.h"
  31. #else
  32. #include MBEDTLS_CONFIG_FILE
  33. #endif
  34.  
  35. #include <stddef.h>
  36. #include <stdint.h>
  37.  
  38. /* MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED is deprecated and should not be used.
  39.  */
  40. #define MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED             -0x0031  /**< RIPEMD160 hardware accelerator failed */
  41.  
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45.  
  46. #if !defined(MBEDTLS_RIPEMD160_ALT)
  47. // Regular implementation
  48. //
  49.  
  50. /**
  51.  * \brief          RIPEMD-160 context structure
  52.  */
  53. typedef struct mbedtls_ripemd160_context
  54. {
  55.     uint32_t total[2];          /*!< number of bytes processed  */
  56.     uint32_t state[5];          /*!< intermediate digest state  */
  57.     unsigned char buffer[64];   /*!< data block being processed */
  58. }
  59. mbedtls_ripemd160_context;
  60.  
  61. #else  /* MBEDTLS_RIPEMD160_ALT */
  62. #include "ripemd160.h"
  63. #endif /* MBEDTLS_RIPEMD160_ALT */
  64.  
  65. /**
  66.  * \brief          Initialize RIPEMD-160 context
  67.  *
  68.  * \param ctx      RIPEMD-160 context to be initialized
  69.  */
  70. void mbedtls_ripemd160_init( mbedtls_ripemd160_context *ctx );
  71.  
  72. /**
  73.  * \brief          Clear RIPEMD-160 context
  74.  *
  75.  * \param ctx      RIPEMD-160 context to be cleared
  76.  */
  77. void mbedtls_ripemd160_free( mbedtls_ripemd160_context *ctx );
  78.  
  79. /**
  80.  * \brief          Clone (the state of) an RIPEMD-160 context
  81.  *
  82.  * \param dst      The destination context
  83.  * \param src      The context to be cloned
  84.  */
  85. void mbedtls_ripemd160_clone( mbedtls_ripemd160_context *dst,
  86.                         const mbedtls_ripemd160_context *src );
  87.  
  88. /**
  89.  * \brief          RIPEMD-160 context setup
  90.  *
  91.  * \param ctx      context to be initialized
  92.  *
  93.  * \return         0 if successful
  94.  */
  95. int mbedtls_ripemd160_starts_ret( mbedtls_ripemd160_context *ctx );
  96.  
  97. /**
  98.  * \brief          RIPEMD-160 process buffer
  99.  *
  100.  * \param ctx      RIPEMD-160 context
  101.  * \param input    buffer holding the data
  102.  * \param ilen     length of the input data
  103.  *
  104.  * \return         0 if successful
  105.  */
  106. int mbedtls_ripemd160_update_ret( mbedtls_ripemd160_context *ctx,
  107.                                   const unsigned char *input,
  108.                                   size_t ilen );
  109.  
  110. /**
  111.  * \brief          RIPEMD-160 final digest
  112.  *
  113.  * \param ctx      RIPEMD-160 context
  114.  * \param output   RIPEMD-160 checksum result
  115.  *
  116.  * \return         0 if successful
  117.  */
  118. int mbedtls_ripemd160_finish_ret( mbedtls_ripemd160_context *ctx,
  119.                                   unsigned char output[20] );
  120.  
  121. /**
  122.  * \brief          RIPEMD-160 process data block (internal use only)
  123.  *
  124.  * \param ctx      RIPEMD-160 context
  125.  * \param data     buffer holding one block of data
  126.  *
  127.  * \return         0 if successful
  128.  */
  129. int mbedtls_internal_ripemd160_process( mbedtls_ripemd160_context *ctx,
  130.                                         const unsigned char data[64] );
  131.  
  132. #if !defined(MBEDTLS_DEPRECATED_REMOVED)
  133. #if defined(MBEDTLS_DEPRECATED_WARNING)
  134. #define MBEDTLS_DEPRECATED      __attribute__((deprecated))
  135. #else
  136. #define MBEDTLS_DEPRECATED
  137. #endif
  138. /**
  139.  * \brief          RIPEMD-160 context setup
  140.  *
  141.  * \deprecated     Superseded by mbedtls_ripemd160_starts_ret() in 2.7.0
  142.  *
  143.  * \param ctx      context to be initialized
  144.  */
  145. MBEDTLS_DEPRECATED void mbedtls_ripemd160_starts(
  146.                                             mbedtls_ripemd160_context *ctx );
  147.  
  148. /**
  149.  * \brief          RIPEMD-160 process buffer
  150.  *
  151.  * \deprecated     Superseded by mbedtls_ripemd160_update_ret() in 2.7.0
  152.  *
  153.  * \param ctx      RIPEMD-160 context
  154.  * \param input    buffer holding the data
  155.  * \param ilen     length of the input data
  156.  */
  157. MBEDTLS_DEPRECATED void mbedtls_ripemd160_update(
  158.                                                 mbedtls_ripemd160_context *ctx,
  159.                                                 const unsigned char *input,
  160.                                                 size_t ilen );
  161.  
  162. /**
  163.  * \brief          RIPEMD-160 final digest
  164.  *
  165.  * \deprecated     Superseded by mbedtls_ripemd160_finish_ret() in 2.7.0
  166.  *
  167.  * \param ctx      RIPEMD-160 context
  168.  * \param output   RIPEMD-160 checksum result
  169.  */
  170. MBEDTLS_DEPRECATED void mbedtls_ripemd160_finish(
  171.                                                 mbedtls_ripemd160_context *ctx,
  172.                                                 unsigned char output[20] );
  173.  
  174. /**
  175.  * \brief          RIPEMD-160 process data block (internal use only)
  176.  *
  177.  * \deprecated     Superseded by mbedtls_internal_ripemd160_process() in 2.7.0
  178.  *
  179.  * \param ctx      RIPEMD-160 context
  180.  * \param data     buffer holding one block of data
  181.  */
  182. MBEDTLS_DEPRECATED void mbedtls_ripemd160_process(
  183.                                             mbedtls_ripemd160_context *ctx,
  184.                                             const unsigned char data[64] );
  185.  
  186. #undef MBEDTLS_DEPRECATED
  187. #endif /* !MBEDTLS_DEPRECATED_REMOVED */
  188.  
  189. /**
  190.  * \brief          Output = RIPEMD-160( input buffer )
  191.  *
  192.  * \param input    buffer holding the data
  193.  * \param ilen     length of the input data
  194.  * \param output   RIPEMD-160 checksum result
  195.  *
  196.  * \return         0 if successful
  197.  */
  198. int mbedtls_ripemd160_ret( const unsigned char *input,
  199.                            size_t ilen,
  200.                            unsigned char output[20] );
  201.  
  202. #if !defined(MBEDTLS_DEPRECATED_REMOVED)
  203. #if defined(MBEDTLS_DEPRECATED_WARNING)
  204. #define MBEDTLS_DEPRECATED      __attribute__((deprecated))
  205. #else
  206. #define MBEDTLS_DEPRECATED
  207. #endif
  208. /**
  209.  * \brief          Output = RIPEMD-160( input buffer )
  210.  *
  211.  * \deprecated     Superseded by mbedtls_ripemd160_ret() in 2.7.0
  212.  *
  213.  * \param input    buffer holding the data
  214.  * \param ilen     length of the input data
  215.  * \param output   RIPEMD-160 checksum result
  216.  */
  217. MBEDTLS_DEPRECATED void mbedtls_ripemd160( const unsigned char *input,
  218.                                            size_t ilen,
  219.                                            unsigned char output[20] );
  220.  
  221. #undef MBEDTLS_DEPRECATED
  222. #endif /* !MBEDTLS_DEPRECATED_REMOVED */
  223.  
  224. #if defined(MBEDTLS_SELF_TEST)
  225.  
  226. /**
  227.  * \brief          Checkup routine
  228.  *
  229.  * \return         0 if successful, or 1 if the test failed
  230.  */
  231. int mbedtls_ripemd160_self_test( int verbose );
  232.  
  233. #endif /* MBEDTLS_SELF_TEST */
  234.  
  235. #ifdef __cplusplus
  236. }
  237. #endif
  238.  
  239. #endif /* mbedtls_ripemd160.h */
  240.