1
0

md2.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*!
  2. \ingroup MD2
  3. \brief This function initializes md2. This is automatically
  4. called by wc_Md2Hash.
  5. \return 0 Returned upon successfully initializing
  6. \param md2 pointer to the md2 structure to use for encryption
  7. _Example_
  8. \code
  9. md2 md2[1];
  10. if ((ret = wc_InitMd2(md2)) != 0) {
  11. WOLFSSL_MSG("wc_Initmd2 failed");
  12. }
  13. else {
  14. wc_Md2Update(md2, data, len);
  15. wc_Md2Final(md2, hash);
  16. }
  17. \endcode
  18. \sa wc_Md2Hash
  19. \sa wc_Md2Update
  20. \sa wc_Md2Final
  21. */
  22. void wc_InitMd2(Md2*);
  23. /*!
  24. \ingroup MD2
  25. \brief Can be called to continually hash the provided byte
  26. array of length len.
  27. \return 0 Returned upon successfully adding the data to the digest.
  28. \param md2 pointer to the md2 structure to use for encryption
  29. \param data the data to be hashed
  30. \param len length of data to be hashed
  31. _Example_
  32. \code
  33. md2 md2[1];
  34. byte data[] = { }; // Data to be hashed
  35. word32 len = sizeof(data);
  36. if ((ret = wc_InitMd2(md2)) != 0) {
  37. WOLFSSL_MSG("wc_Initmd2 failed");
  38. }
  39. else {
  40. wc_Md2Update(md2, data, len);
  41. wc_Md2Final(md2, hash);
  42. }
  43. \endcode
  44. \sa wc_Md2Hash
  45. \sa wc_Md2Final
  46. \sa wc_InitMd2
  47. */
  48. void wc_Md2Update(Md2* md2, const byte* data, word32 len);
  49. /*!
  50. \ingroup MD2
  51. \brief Finalizes hashing of data. Result is placed into hash.
  52. \return 0 Returned upon successfully finalizing.
  53. \param md2 pointer to the md2 structure to use for encryption
  54. \param hash Byte array to hold hash value.
  55. _Example_
  56. \code
  57. md2 md2[1];
  58. byte data[] = { }; // Data to be hashed
  59. word32 len = sizeof(data);
  60. if ((ret = wc_InitMd2(md2)) != 0) {
  61. WOLFSSL_MSG("wc_Initmd2 failed");
  62. }
  63. else {
  64. wc_Md2Update(md2, data, len);
  65. wc_Md2Final(md2, hash);
  66. }
  67. \endcode
  68. \sa wc_Md2Hash
  69. \sa wc_Md2Final
  70. \sa wc_InitMd2
  71. */
  72. void wc_Md2Final(Md2* md2, byte* hash);
  73. /*!
  74. \ingroup MD2
  75. \brief Convenience function, handles all the hashing and places
  76. the result into hash.
  77. \return 0 Returned upon successfully hashing the data.
  78. \return Memory_E memory error, unable to allocate memory. This is only
  79. possible with the small stack option enabled.
  80. \param data the data to hash
  81. \param len the length of data
  82. \param hash Byte array to hold hash value.
  83. _Example_
  84. \code
  85. none
  86. \endcode
  87. \sa wc_Md2Hash
  88. \sa wc_Md2Final
  89. \sa wc_InitMd2
  90. */
  91. int wc_Md2Hash(const byte* data, word32 len, byte* hash);