ripemd160.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. /* MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED is deprecated and should not be used.
  34. */
  35. #define MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED -0x0031 /**< RIPEMD160 hardware accelerator failed */
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. #if !defined(MBEDTLS_RIPEMD160_ALT)
  40. // Regular implementation
  41. //
  42. /**
  43. * \brief RIPEMD-160 context structure
  44. */
  45. typedef struct mbedtls_ripemd160_context
  46. {
  47. uint32_t total[2]; /*!< number of bytes processed */
  48. uint32_t state[5]; /*!< intermediate digest state */
  49. unsigned char buffer[64]; /*!< data block being processed */
  50. }
  51. mbedtls_ripemd160_context;
  52. #else /* MBEDTLS_RIPEMD160_ALT */
  53. #include "ripemd160.h"
  54. #endif /* MBEDTLS_RIPEMD160_ALT */
  55. /**
  56. * \brief Initialize RIPEMD-160 context
  57. *
  58. * \param ctx RIPEMD-160 context to be initialized
  59. */
  60. void mbedtls_ripemd160_init( mbedtls_ripemd160_context *ctx );
  61. /**
  62. * \brief Clear RIPEMD-160 context
  63. *
  64. * \param ctx RIPEMD-160 context to be cleared
  65. */
  66. void mbedtls_ripemd160_free( mbedtls_ripemd160_context *ctx );
  67. /**
  68. * \brief Clone (the state of) an RIPEMD-160 context
  69. *
  70. * \param dst The destination context
  71. * \param src The context to be cloned
  72. */
  73. void mbedtls_ripemd160_clone( mbedtls_ripemd160_context *dst,
  74. const mbedtls_ripemd160_context *src );
  75. /**
  76. * \brief RIPEMD-160 context setup
  77. *
  78. * \param ctx context to be initialized
  79. *
  80. * \return 0 if successful
  81. */
  82. int mbedtls_ripemd160_starts_ret( mbedtls_ripemd160_context *ctx );
  83. /**
  84. * \brief RIPEMD-160 process buffer
  85. *
  86. * \param ctx RIPEMD-160 context
  87. * \param input buffer holding the data
  88. * \param ilen length of the input data
  89. *
  90. * \return 0 if successful
  91. */
  92. int mbedtls_ripemd160_update_ret( mbedtls_ripemd160_context *ctx,
  93. const unsigned char *input,
  94. size_t ilen );
  95. /**
  96. * \brief RIPEMD-160 final digest
  97. *
  98. * \param ctx RIPEMD-160 context
  99. * \param output RIPEMD-160 checksum result
  100. *
  101. * \return 0 if successful
  102. */
  103. int mbedtls_ripemd160_finish_ret( mbedtls_ripemd160_context *ctx,
  104. unsigned char output[20] );
  105. /**
  106. * \brief RIPEMD-160 process data block (internal use only)
  107. *
  108. * \param ctx RIPEMD-160 context
  109. * \param data buffer holding one block of data
  110. *
  111. * \return 0 if successful
  112. */
  113. int mbedtls_internal_ripemd160_process( mbedtls_ripemd160_context *ctx,
  114. const unsigned char data[64] );
  115. #if !defined(MBEDTLS_DEPRECATED_REMOVED)
  116. #if defined(MBEDTLS_DEPRECATED_WARNING)
  117. #define MBEDTLS_DEPRECATED __attribute__((deprecated))
  118. #else
  119. #define MBEDTLS_DEPRECATED
  120. #endif
  121. /**
  122. * \brief RIPEMD-160 context setup
  123. *
  124. * \deprecated Superseded by mbedtls_ripemd160_starts_ret() in 2.7.0
  125. *
  126. * \param ctx context to be initialized
  127. */
  128. MBEDTLS_DEPRECATED void mbedtls_ripemd160_starts(
  129. mbedtls_ripemd160_context *ctx );
  130. /**
  131. * \brief RIPEMD-160 process buffer
  132. *
  133. * \deprecated Superseded by mbedtls_ripemd160_update_ret() in 2.7.0
  134. *
  135. * \param ctx RIPEMD-160 context
  136. * \param input buffer holding the data
  137. * \param ilen length of the input data
  138. */
  139. MBEDTLS_DEPRECATED void mbedtls_ripemd160_update(
  140. mbedtls_ripemd160_context *ctx,
  141. const unsigned char *input,
  142. size_t ilen );
  143. /**
  144. * \brief RIPEMD-160 final digest
  145. *
  146. * \deprecated Superseded by mbedtls_ripemd160_finish_ret() in 2.7.0
  147. *
  148. * \param ctx RIPEMD-160 context
  149. * \param output RIPEMD-160 checksum result
  150. */
  151. MBEDTLS_DEPRECATED void mbedtls_ripemd160_finish(
  152. mbedtls_ripemd160_context *ctx,
  153. unsigned char output[20] );
  154. /**
  155. * \brief RIPEMD-160 process data block (internal use only)
  156. *
  157. * \deprecated Superseded by mbedtls_internal_ripemd160_process() in 2.7.0
  158. *
  159. * \param ctx RIPEMD-160 context
  160. * \param data buffer holding one block of data
  161. */
  162. MBEDTLS_DEPRECATED void mbedtls_ripemd160_process(
  163. mbedtls_ripemd160_context *ctx,
  164. const unsigned char data[64] );
  165. #undef MBEDTLS_DEPRECATED
  166. #endif /* !MBEDTLS_DEPRECATED_REMOVED */
  167. /**
  168. * \brief Output = RIPEMD-160( input buffer )
  169. *
  170. * \param input buffer holding the data
  171. * \param ilen length of the input data
  172. * \param output RIPEMD-160 checksum result
  173. *
  174. * \return 0 if successful
  175. */
  176. int mbedtls_ripemd160_ret( const unsigned char *input,
  177. size_t ilen,
  178. unsigned char output[20] );
  179. #if !defined(MBEDTLS_DEPRECATED_REMOVED)
  180. #if defined(MBEDTLS_DEPRECATED_WARNING)
  181. #define MBEDTLS_DEPRECATED __attribute__((deprecated))
  182. #else
  183. #define MBEDTLS_DEPRECATED
  184. #endif
  185. /**
  186. * \brief Output = RIPEMD-160( input buffer )
  187. *
  188. * \deprecated Superseded by mbedtls_ripemd160_ret() in 2.7.0
  189. *
  190. * \param input buffer holding the data
  191. * \param ilen length of the input data
  192. * \param output RIPEMD-160 checksum result
  193. */
  194. MBEDTLS_DEPRECATED void mbedtls_ripemd160( const unsigned char *input,
  195. size_t ilen,
  196. unsigned char output[20] );
  197. #undef MBEDTLS_DEPRECATED
  198. #endif /* !MBEDTLS_DEPRECATED_REMOVED */
  199. #if defined(MBEDTLS_SELF_TEST)
  200. /**
  201. * \brief Checkup routine
  202. *
  203. * \return 0 if successful, or 1 if the test failed
  204. */
  205. int mbedtls_ripemd160_self_test( int verbose );
  206. #endif /* MBEDTLS_SELF_TEST */
  207. #ifdef __cplusplus
  208. }
  209. #endif
  210. #endif /* mbedtls_ripemd160.h */