ripemd160.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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: Apache-2.0
  9. *
  10. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  11. * not use this file except in compliance with the License.
  12. * You may obtain a copy of the License at
  13. *
  14. * http://www.apache.org/licenses/LICENSE-2.0
  15. *
  16. * Unless required by applicable law or agreed to in writing, software
  17. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  18. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. * See the License for the specific language governing permissions and
  20. * limitations under the License.
  21. *
  22. * This file is part of mbed TLS (https://tls.mbed.org)
  23. */
  24. #ifndef MBEDTLS_RIPEMD160_H
  25. #define MBEDTLS_RIPEMD160_H
  26. #if !defined(MBEDTLS_CONFIG_FILE)
  27. #include "config.h"
  28. #else
  29. #include MBEDTLS_CONFIG_FILE
  30. #endif
  31. #include <stddef.h>
  32. #include <stdint.h>
  33. #define MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED -0x0031 /**< RIPEMD160 hardware accelerator failed */
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. #if !defined(MBEDTLS_RIPEMD160_ALT)
  38. // Regular implementation
  39. //
  40. /**
  41. * \brief RIPEMD-160 context structure
  42. */
  43. typedef struct
  44. {
  45. uint32_t total[2]; /*!< number of bytes processed */
  46. uint32_t state[5]; /*!< intermediate digest state */
  47. unsigned char buffer[64]; /*!< data block being processed */
  48. }
  49. mbedtls_ripemd160_context;
  50. #else /* MBEDTLS_RIPEMD160_ALT */
  51. #include "ripemd160.h"
  52. #endif /* MBEDTLS_RIPEMD160_ALT */
  53. /**
  54. * \brief Initialize RIPEMD-160 context
  55. *
  56. * \param ctx RIPEMD-160 context to be initialized
  57. */
  58. void mbedtls_ripemd160_init( mbedtls_ripemd160_context *ctx );
  59. /**
  60. * \brief Clear RIPEMD-160 context
  61. *
  62. * \param ctx RIPEMD-160 context to be cleared
  63. */
  64. void mbedtls_ripemd160_free( mbedtls_ripemd160_context *ctx );
  65. /**
  66. * \brief Clone (the state of) an RIPEMD-160 context
  67. *
  68. * \param dst The destination context
  69. * \param src The context to be cloned
  70. */
  71. void mbedtls_ripemd160_clone( mbedtls_ripemd160_context *dst,
  72. const mbedtls_ripemd160_context *src );
  73. /**
  74. * \brief RIPEMD-160 context setup
  75. *
  76. * \param ctx context to be initialized
  77. *
  78. * \return 0 if successful
  79. */
  80. int mbedtls_ripemd160_starts_ret( mbedtls_ripemd160_context *ctx );
  81. /**
  82. * \brief RIPEMD-160 process buffer
  83. *
  84. * \param ctx RIPEMD-160 context
  85. * \param input buffer holding the data
  86. * \param ilen length of the input data
  87. *
  88. * \return 0 if successful
  89. */
  90. int mbedtls_ripemd160_update_ret( mbedtls_ripemd160_context *ctx,
  91. const unsigned char *input,
  92. size_t ilen );
  93. /**
  94. * \brief RIPEMD-160 final digest
  95. *
  96. * \param ctx RIPEMD-160 context
  97. * \param output RIPEMD-160 checksum result
  98. *
  99. * \return 0 if successful
  100. */
  101. int mbedtls_ripemd160_finish_ret( mbedtls_ripemd160_context *ctx,
  102. unsigned char output[20] );
  103. /**
  104. * \brief RIPEMD-160 process data block (internal use only)
  105. *
  106. * \param ctx RIPEMD-160 context
  107. * \param data buffer holding one block of data
  108. *
  109. * \return 0 if successful
  110. */
  111. int mbedtls_internal_ripemd160_process( mbedtls_ripemd160_context *ctx,
  112. const unsigned char data[64] );
  113. #if !defined(MBEDTLS_DEPRECATED_REMOVED)
  114. #if defined(MBEDTLS_DEPRECATED_WARNING)
  115. #define MBEDTLS_DEPRECATED __attribute__((deprecated))
  116. #else
  117. #define MBEDTLS_DEPRECATED
  118. #endif
  119. /**
  120. * \brief RIPEMD-160 context setup
  121. *
  122. * \deprecated Superseded by mbedtls_ripemd160_starts_ret() in 2.7.0
  123. *
  124. * \param ctx context to be initialized
  125. */
  126. MBEDTLS_DEPRECATED void mbedtls_ripemd160_starts(
  127. mbedtls_ripemd160_context *ctx );
  128. /**
  129. * \brief RIPEMD-160 process buffer
  130. *
  131. * \deprecated Superseded by mbedtls_ripemd160_update_ret() in 2.7.0
  132. *
  133. * \param ctx RIPEMD-160 context
  134. * \param input buffer holding the data
  135. * \param ilen length of the input data
  136. */
  137. MBEDTLS_DEPRECATED void mbedtls_ripemd160_update(
  138. mbedtls_ripemd160_context *ctx,
  139. const unsigned char *input,
  140. size_t ilen );
  141. /**
  142. * \brief RIPEMD-160 final digest
  143. *
  144. * \deprecated Superseded by mbedtls_ripemd160_finish_ret() in 2.7.0
  145. *
  146. * \param ctx RIPEMD-160 context
  147. * \param output RIPEMD-160 checksum result
  148. */
  149. MBEDTLS_DEPRECATED void mbedtls_ripemd160_finish(
  150. mbedtls_ripemd160_context *ctx,
  151. unsigned char output[20] );
  152. /**
  153. * \brief RIPEMD-160 process data block (internal use only)
  154. *
  155. * \deprecated Superseded by mbedtls_internal_ripemd160_process() in 2.7.0
  156. *
  157. * \param ctx RIPEMD-160 context
  158. * \param data buffer holding one block of data
  159. */
  160. MBEDTLS_DEPRECATED void mbedtls_ripemd160_process(
  161. mbedtls_ripemd160_context *ctx,
  162. const unsigned char data[64] );
  163. #undef MBEDTLS_DEPRECATED
  164. #endif /* !MBEDTLS_DEPRECATED_REMOVED */
  165. /**
  166. * \brief Output = RIPEMD-160( input buffer )
  167. *
  168. * \param input buffer holding the data
  169. * \param ilen length of the input data
  170. * \param output RIPEMD-160 checksum result
  171. *
  172. * \return 0 if successful
  173. */
  174. int mbedtls_ripemd160_ret( const unsigned char *input,
  175. size_t ilen,
  176. unsigned char output[20] );
  177. #if !defined(MBEDTLS_DEPRECATED_REMOVED)
  178. #if defined(MBEDTLS_DEPRECATED_WARNING)
  179. #define MBEDTLS_DEPRECATED __attribute__((deprecated))
  180. #else
  181. #define MBEDTLS_DEPRECATED
  182. #endif
  183. /**
  184. * \brief Output = RIPEMD-160( input buffer )
  185. *
  186. * \deprecated Superseded by mbedtls_ripemd160_ret() in 2.7.0
  187. *
  188. * \param input buffer holding the data
  189. * \param ilen length of the input data
  190. * \param output RIPEMD-160 checksum result
  191. */
  192. MBEDTLS_DEPRECATED void mbedtls_ripemd160( const unsigned char *input,
  193. size_t ilen,
  194. unsigned char output[20] );
  195. #undef MBEDTLS_DEPRECATED
  196. #endif /* !MBEDTLS_DEPRECATED_REMOVED */
  197. /**
  198. * \brief Checkup routine
  199. *
  200. * \return 0 if successful, or 1 if the test failed
  201. */
  202. int mbedtls_ripemd160_self_test( int verbose );
  203. #ifdef __cplusplus
  204. }
  205. #endif
  206. #endif /* mbedtls_ripemd160.h */