Files
wolfssl/doc/dox_comments/header_files/sha.h

146 lines
3.0 KiB
C
Raw Normal View History

/*!
\ingroup SHA
2018-06-27 16:22:12 -06:00
\brief This function initializes SHA. This is automatically called
by wc_ShaHash.
2018-06-27 16:22:12 -06:00
\return 0 Returned upon successfully initializing
2018-06-27 16:22:12 -06:00
\param sha pointer to the sha structure to use for encryption
2018-06-27 16:22:12 -06:00
_Example_
\code
Sha sha[1];
if ((ret = wc_InitSha(sha)) != 0) {
WOLFSSL_MSG("wc_InitSha failed");
}
else {
wc_ShaUpdate(sha, data, len);
wc_ShaFinal(sha, hash);
}
\endcode
2018-06-27 16:22:12 -06:00
\sa wc_ShaHash
\sa wc_ShaUpdate
\sa wc_ShaFinal
*/
int wc_InitSha(wc_Sha*);
/*!
\ingroup SHA
2018-06-27 16:22:12 -06:00
\brief Can be called to continually hash the provided byte array of
length len.
2018-06-27 16:22:12 -06:00
\return 0 Returned upon successfully adding the data to the digest.
2018-06-27 16:22:12 -06:00
\param sha pointer to the sha structure to use for encryption
\param data the data to be hashed
\param len length of data to be hashed
2018-06-27 16:22:12 -06:00
_Example_
\code
Sha sha[1];
byte data[] = { // Data to be hashed };
word32 len = sizeof(data);
if ((ret = wc_InitSha(sha)) != 0) {
WOLFSSL_MSG("wc_InitSha failed");
}
else {
wc_ShaUpdate(sha, data, len);
wc_ShaFinal(sha, hash);
}
\endcode
2018-06-27 16:22:12 -06:00
\sa wc_ShaHash
\sa wc_ShaFinal
\sa wc_InitSha
*/
int wc_ShaUpdate(wc_Sha* sha, const byte* data, word32 len);
/*!
\ingroup SHA
2018-06-27 16:22:12 -06:00
\brief Finalizes hashing of data. Result is placed into hash.
Resets state of sha struct.
2018-06-27 16:22:12 -06:00
\return 0 Returned upon successfully finalizing.
2018-06-27 16:22:12 -06:00
\param sha pointer to the sha structure to use for encryption
\param hash Byte array to hold hash value.
2018-06-27 16:22:12 -06:00
_Example_
\code
Sha sha[1];
byte data[] = { Data to be hashed };
word32 len = sizeof(data);
if ((ret = wc_InitSha(sha)) != 0) {
WOLFSSL_MSG("wc_InitSha failed");
}
else {
wc_ShaUpdate(sha, data, len);
wc_ShaFinal(sha, hash);
}
\endcode
2018-06-27 16:22:12 -06:00
\sa wc_ShaHash
\sa wc_InitSha
\sa wc_ShaGetHash
*/
int wc_ShaFinal(wc_Sha* sha, byte* hash);
/*!
\ingroup SHA
2018-06-27 16:22:12 -06:00
\brief Used to clean up memory used by an initialized Sha struct.
Note: this is only supported if you have WOLFSSL_TI_HASH defined.
2018-06-27 16:22:12 -06:00
\return No returns.
2018-06-27 16:22:12 -06:00
\param sha Pointer to the Sha struct to free.
2018-06-27 16:22:12 -06:00
_Example_
\code
Sha sha;
wc_InitSha(&sha);
// Use sha
wc_ShaFree(&sha);
\endcode
2018-06-27 16:22:12 -06:00
\sa wc_InitSha
\sa wc_ShaUpdate
\sa wc_ShaFinal
*/
void wc_ShaFree(wc_Sha*);
/*!
\ingroup SHA
2018-06-27 16:22:12 -06:00
\brief Gets hash data. Result is placed into hash. Does not reset state
of sha struct.
2018-06-27 16:22:12 -06:00
\return 0 Returned upon successfully finalizing.
2018-06-27 16:22:12 -06:00
\param sha pointer to the sha structure to use for encryption
\param hash Byte array to hold hash value.
2018-06-27 16:22:12 -06:00
_Example_
\code
Sha sha[1];
if ((ret = wc_InitSha(sha)) != 0) {
WOLFSSL_MSG("wc_InitSha failed");
}
else {
wc_ShaUpdate(sha, data, len);
wc_ShaGetHash(sha, hash);
}
\endcode
2018-06-27 16:22:12 -06:00
\sa wc_ShaHash
\sa wc_ShaFinal
\sa wc_InitSha
*/
int wc_ShaGetHash(wc_Sha* sha, byte* hash);