ripemd160.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /**
  2. * \file ripemd160.h
  3. *
  4. * \brief RIPE MD-160 message digest
  5. */
  6. /*
  7. * Copyright The Mbed TLS Contributors
  8. * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
  9. */
  10. #ifndef MBEDTLS_RIPEMD160_H
  11. #define MBEDTLS_RIPEMD160_H
  12. #include "mbedtls/private_access.h"
  13. #include "mbedtls/build_info.h"
  14. #include <stddef.h>
  15. #include <stdint.h>
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. #if !defined(MBEDTLS_RIPEMD160_ALT)
  20. // Regular implementation
  21. //
  22. /**
  23. * \brief RIPEMD-160 context structure
  24. */
  25. typedef struct mbedtls_ripemd160_context {
  26. uint32_t MBEDTLS_PRIVATE(total)[2]; /*!< number of bytes processed */
  27. uint32_t MBEDTLS_PRIVATE(state)[5]; /*!< intermediate digest state */
  28. unsigned char MBEDTLS_PRIVATE(buffer)[64]; /*!< data block being processed */
  29. }
  30. mbedtls_ripemd160_context;
  31. #else /* MBEDTLS_RIPEMD160_ALT */
  32. #include "ripemd160_alt.h"
  33. #endif /* MBEDTLS_RIPEMD160_ALT */
  34. /**
  35. * \brief Initialize RIPEMD-160 context
  36. *
  37. * \param ctx RIPEMD-160 context to be initialized
  38. */
  39. void mbedtls_ripemd160_init(mbedtls_ripemd160_context *ctx);
  40. /**
  41. * \brief Clear RIPEMD-160 context
  42. *
  43. * \param ctx RIPEMD-160 context to be cleared
  44. */
  45. void mbedtls_ripemd160_free(mbedtls_ripemd160_context *ctx);
  46. /**
  47. * \brief Clone (the state of) a RIPEMD-160 context
  48. *
  49. * \param dst The destination context
  50. * \param src The context to be cloned
  51. */
  52. void mbedtls_ripemd160_clone(mbedtls_ripemd160_context *dst,
  53. const mbedtls_ripemd160_context *src);
  54. /**
  55. * \brief RIPEMD-160 context setup
  56. *
  57. * \param ctx context to be initialized
  58. *
  59. * \return 0 if successful
  60. */
  61. int mbedtls_ripemd160_starts(mbedtls_ripemd160_context *ctx);
  62. /**
  63. * \brief RIPEMD-160 process buffer
  64. *
  65. * \param ctx RIPEMD-160 context
  66. * \param input buffer holding the data
  67. * \param ilen length of the input data
  68. *
  69. * \return 0 if successful
  70. */
  71. int mbedtls_ripemd160_update(mbedtls_ripemd160_context *ctx,
  72. const unsigned char *input,
  73. size_t ilen);
  74. /**
  75. * \brief RIPEMD-160 final digest
  76. *
  77. * \param ctx RIPEMD-160 context
  78. * \param output RIPEMD-160 checksum result
  79. *
  80. * \return 0 if successful
  81. */
  82. int mbedtls_ripemd160_finish(mbedtls_ripemd160_context *ctx,
  83. unsigned char output[20]);
  84. /**
  85. * \brief RIPEMD-160 process data block (internal use only)
  86. *
  87. * \param ctx RIPEMD-160 context
  88. * \param data buffer holding one block of data
  89. *
  90. * \return 0 if successful
  91. */
  92. int mbedtls_internal_ripemd160_process(mbedtls_ripemd160_context *ctx,
  93. const unsigned char data[64]);
  94. /**
  95. * \brief Output = RIPEMD-160( input buffer )
  96. *
  97. * \param input buffer holding the data
  98. * \param ilen length of the input data
  99. * \param output RIPEMD-160 checksum result
  100. *
  101. * \return 0 if successful
  102. */
  103. int mbedtls_ripemd160(const unsigned char *input,
  104. size_t ilen,
  105. unsigned char output[20]);
  106. #if defined(MBEDTLS_SELF_TEST)
  107. /**
  108. * \brief Checkup routine
  109. *
  110. * \return 0 if successful, or 1 if the test failed
  111. */
  112. int mbedtls_ripemd160_self_test(int verbose);
  113. #endif /* MBEDTLS_SELF_TEST */
  114. #ifdef __cplusplus
  115. }
  116. #endif
  117. #endif /* mbedtls_ripemd160.h */