ripemd.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*!
  2. \ingroup RIPEMD
  3. \brief This function initializes a ripemd structure by initializing
  4. ripemd’s digest, buffer, loLen and hiLen.
  5. \return 0 returned on successful execution of the function. The RipeMd
  6. structure is initialized.
  7. \return BAD_FUNC_ARG returned if the RipeMd structure is NULL.
  8. \param ripemd pointer to the ripemd structure to initialize
  9. _Example_
  10. \code
  11. RipeMd md;
  12. int ret;
  13. ret = wc_InitRipeMd(&md);
  14. if (ret != 0) {
  15. // Failure case.
  16. }
  17. \endcode
  18. \sa wc_RipeMdUpdate
  19. \sa wc_RipeMdFinal
  20. */
  21. int wc_InitRipeMd(RipeMd*);
  22. /*!
  23. \ingroup RIPEMD
  24. \brief This function generates the RipeMd digest of the data input and
  25. stores the result in the ripemd->digest buffer. After running
  26. wc_RipeMdUpdate, one should compare the generated ripemd->digest to a
  27. known authentication tag to verify the authenticity of a message.
  28. \return 0 Returned on successful execution of the function.
  29. \return BAD_FUNC_ARG Returned if the RipeMd structure is NULL or if data
  30. is NULL and len is not zero. This function should execute if data is NULL
  31. and len is 0.
  32. \param ripemd: pointer to the ripemd structure to be initialized with
  33. wc_InitRipeMd
  34. \param data data to be hashed
  35. \param len sizeof data in bytes
  36. _Example_
  37. \code
  38. const byte* data; // The data to be hashed
  39. ....
  40. RipeMd md;
  41. int ret;
  42. ret = wc_InitRipeMd(&md);
  43. if (ret == 0) {
  44. ret = wc_RipeMdUpdate(&md, plain, sizeof(plain));
  45. if (ret != 0) {
  46. // Failure case …
  47. \endcode
  48. \sa wc_InitRipeMd
  49. \sa wc_RipeMdFinal
  50. */
  51. int wc_RipeMdUpdate(RipeMd* ripemd, const byte* data, word32 len);
  52. /*!
  53. \ingroup RIPEMD
  54. \brief This function copies the computed digest into hash. If there is a
  55. partial unhashed block, this method will pad the block with 0s, and
  56. include that block’s round in the digest before copying to hash. State
  57. of ripemd is reset.
  58. \return 0 Returned on successful execution of the function. The state of
  59. the RipeMd structure has been reset.
  60. \return BAD_FUNC_ARG Returned if the RipeMd structure or hash parameters
  61. are NULL.
  62. \param ripemd pointer to the ripemd structure to be initialized with
  63. wc_InitRipeMd, and containing hashes from wc_RipeMdUpdate. State will
  64. be reset
  65. \param hash buffer to copy digest to. Should be RIPEMD_DIGEST_SIZE bytes
  66. _Example_
  67. \code
  68. RipeMd md;
  69. int ret;
  70. byte digest[RIPEMD_DIGEST_SIZE];
  71. const byte* data; // The data to be hashed
  72. ...
  73. ret = wc_InitRipeMd(&md);
  74. if (ret == 0) {
  75. ret = wc_RipeMdUpdate(&md, plain, sizeof(plain));
  76. if (ret != 0) {
  77. // RipeMd Update Failure Case.
  78. }
  79. ret = wc_RipeMdFinal(&md, digest);
  80. if (ret != 0) {
  81. // RipeMd Final Failure Case.
  82. }...
  83. \endcode
  84. \sa none
  85. */
  86. int wc_RipeMdFinal(RipeMd* ripemd, byte* hash);