1
0

sha512.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*!
  2. \ingroup SHA
  3. \brief This function initializes SHA512. This is automatically called
  4. by wc_Sha512Hash.
  5. \return 0 Returned upon successfully initializing
  6. \param sha512 pointer to the sha512 structure to use for encryption
  7. _Example_
  8. \code
  9. Sha512 sha512[1];
  10. if ((ret = wc_InitSha512(sha512)) != 0) {
  11. WOLFSSL_MSG("wc_InitSha512 failed");
  12. }
  13. else {
  14. wc_Sha512Update(sha512, data, len);
  15. wc_Sha512Final(sha512, hash);
  16. }
  17. \endcode
  18. \sa wc_Sha512Hash
  19. \sa wc_Sha512Update
  20. \sa wc_Sha512Final
  21. */
  22. int wc_InitSha512(wc_Sha512*);
  23. /*!
  24. \ingroup SHA
  25. \brief Can be called to continually hash the provided byte array
  26. of length len.
  27. \return 0 Returned upon successfully adding the data to the digest.
  28. \param sha512 pointer to the sha512 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. Sha512 sha512[1];
  34. byte data[] = { Data to be hashed };
  35. word32 len = sizeof(data);
  36. if ((ret = wc_InitSha512(sha512)) != 0) {
  37. WOLFSSL_MSG("wc_InitSha512 failed");
  38. }
  39. else {
  40. wc_Sha512Update(sha512, data, len);
  41. wc_Sha512Final(sha512, hash);
  42. }
  43. \endcode
  44. \sa wc_Sha512Hash
  45. \sa wc_Sha512Final
  46. \sa wc_InitSha512
  47. */
  48. int wc_Sha512Update(wc_Sha512* sha, const byte* data, word32 len);
  49. /*!
  50. \ingroup SHA
  51. \brief Finalizes hashing of data. Result is placed into hash.
  52. \return 0 Returned upon successfully finalizing the hash.
  53. \param sha512 pointer to the sha512 structure to use for encryption
  54. \param hash Byte array to hold hash value.
  55. _Example_
  56. \code
  57. Sha512 sha512[1];
  58. byte data[] = { Data to be hashed };
  59. word32 len = sizeof(data);
  60. if ((ret = wc_InitSha512(sha512)) != 0) {
  61. WOLFSSL_MSG("wc_InitSha512 failed");
  62. }
  63. else {
  64. wc_Sha512Update(sha512, data, len);
  65. wc_Sha512Final(sha512, hash);
  66. }
  67. \endcode
  68. \sa wc_Sha512Hash
  69. \sa wc_Sha512Final
  70. \sa wc_InitSha512
  71. */
  72. int wc_Sha512Final(wc_Sha512* sha512, byte* hash);
  73. /*!
  74. \ingroup SHA
  75. \brief This function initializes SHA384. This is automatically called
  76. by wc_Sha384Hash.
  77. \return 0 Returned upon successfully initializing
  78. \param sha384 pointer to the sha384 structure to use for encryption
  79. _Example_
  80. \code
  81. Sha384 sha384[1];
  82. if ((ret = wc_InitSha384(sha384)) != 0) {
  83. WOLFSSL_MSG("wc_InitSha384 failed");
  84. }
  85. else {
  86. wc_Sha384Update(sha384, data, len);
  87. wc_Sha384Final(sha384, hash);
  88. }
  89. \endcode
  90. \sa wc_Sha384Hash
  91. \sa wc_Sha384Update
  92. \sa wc_Sha384Final
  93. */
  94. int wc_InitSha384(wc_Sha384*);
  95. /*!
  96. \ingroup SHA
  97. \brief Can be called to continually hash the provided byte array
  98. of length len.
  99. \return 0 Returned upon successfully adding the data to the digest.
  100. \param sha384 pointer to the sha384 structure to use for encryption
  101. \param data the data to be hashed
  102. \param len length of data to be hashed
  103. _Example_
  104. \code
  105. Sha384 sha384[1];
  106. byte data[] = { Data to be hashed };
  107. word32 len = sizeof(data);
  108. if ((ret = wc_InitSha384(sha384)) != 0) {
  109. WOLFSSL_MSG("wc_InitSha384 failed");
  110. }
  111. else {
  112. wc_Sha384Update(sha384, data, len);
  113. wc_Sha384Final(sha384, hash);
  114. }
  115. \endcode
  116. \sa wc_Sha384Hash
  117. \sa wc_Sha384Final
  118. \sa wc_InitSha384
  119. */
  120. int wc_Sha384Update(wc_Sha384* sha, const byte* data, word32 len);
  121. /*!
  122. \ingroup SHA
  123. \brief Finalizes hashing of data. Result is placed into hash.
  124. \return 0 Returned upon successfully finalizing.
  125. \param sha384 pointer to the sha384 structure to use for encryption
  126. \param hash Byte array to hold hash value.
  127. _Example_
  128. \code
  129. Sha384 sha384[1];
  130. byte data[] = { Data to be hashed };
  131. word32 len = sizeof(data);
  132. if ((ret = wc_InitSha384(sha384)) != 0) {
  133. WOLFSSL_MSG("wc_InitSha384 failed");
  134. }
  135. else {
  136. wc_Sha384Update(sha384, data, len);
  137. wc_Sha384Final(sha384, hash);
  138. }
  139. \endcode
  140. \sa wc_Sha384Hash
  141. \sa wc_Sha384Final
  142. \sa wc_InitSha384
  143. */
  144. int wc_Sha384Final(wc_Sha384* sha384, byte* hash);