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

247 lines
5.4 KiB
C
Raw Normal View History

/*!
\ingroup SHA
2018-06-27 16:22:12 -06:00
\brief This function initializes SHA256. This is automatically
called by wc_Sha256Hash.
2018-06-27 16:22:12 -06:00
\return 0 Returned upon successfully initializing
2018-06-27 16:22:12 -06:00
\param sha256 pointer to the sha256 structure to use for encryption
2018-06-27 16:22:12 -06:00
_Example_
\code
Sha256 sha256[1];
if ((ret = wc_InitSha256(sha256)) != 0) {
WOLFSSL_MSG("wc_InitSha256 failed");
}
else {
wc_Sha256Update(sha256, data, len);
wc_Sha256Final(sha256, hash);
}
\endcode
2018-06-27 16:22:12 -06:00
\sa wc_Sha256Hash
\sa wc_Sha256Update
\sa wc_Sha256Final
*/
int wc_InitSha256(wc_Sha256*);
/*!
\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 sha256 pointer to the sha256 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
Sha256 sha256[1];
byte data[] = { Data to be hashed };
word32 len = sizeof(data);
if ((ret = wc_InitSha256(sha256)) != 0) {
WOLFSSL_MSG("wc_InitSha256 failed");
}
else {
wc_Sha256Update(sha256, data, len);
wc_Sha256Final(sha256, hash);
}
\endcode
2018-06-27 16:22:12 -06:00
\sa wc_Sha256Hash
\sa wc_Sha256Final
\sa wc_InitSha256
*/
int wc_Sha256Update(wc_Sha256* 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 sha256 struct.
2018-06-27 16:22:12 -06:00
\return 0 Returned upon successfully finalizing.
2018-06-27 16:22:12 -06:00
\param sha256 pointer to the sha256 structure to use for encryption
\param hash Byte array to hold hash value.
2018-06-27 16:22:12 -06:00
_Example_
\code
Sha256 sha256[1];
byte data[] = { Data to be hashed };
word32 len = sizeof(data);
if ((ret = wc_InitSha256(sha256)) != 0) {
WOLFSSL_MSG("wc_InitSha256 failed");
}
else {
wc_Sha256Update(sha256, data, len);
wc_Sha256Final(sha256, hash);
}
\endcode
2018-06-27 16:22:12 -06:00
\sa wc_Sha256Hash
\sa wc_Sha256GetHash
\sa wc_InitSha256
*/
int wc_Sha256Final(wc_Sha256* sha256, byte* hash);
/*!
\ingroup SHA
2018-06-27 16:22:12 -06:00
\brief Resets the Sha256 structure. Note: this is only supported
if you have WOLFSSL_TI_HASH defined.
2018-06-27 16:22:12 -06:00
\return none No returns.
2018-06-27 16:22:12 -06:00
\param sha256 Pointer to the sha256 structure to be freed.
_Example_
\code
Sha256 sha256;
byte data[] = { Data to be hashed };
word32 len = sizeof(data);
if ((ret = wc_InitSha256(&sha256)) != 0) {
WOLFSSL_MSG("wc_InitSha256 failed");
}
else {
wc_Sha256Update(&sha256, data, len);
wc_Sha256Final(&sha256, hash);
wc_Sha256Free(&sha256);
}
\endcode
2018-06-27 16:22:12 -06:00
\sa wc_InitSha256
\sa wc_Sha256Update
\sa wc_Sha256Final
*/
void wc_Sha256Free(wc_Sha256*);
/*!
\ingroup SHA
2018-06-27 16:22:12 -06:00
\brief Gets hash data. Result is placed into hash. Does not
reset state of sha256 struct.
2018-06-27 16:22:12 -06:00
\return 0 Returned upon successfully finalizing.
2018-06-27 16:22:12 -06:00
\param sha256 pointer to the sha256 structure to use for encryption
\param hash Byte array to hold hash value.
2018-06-27 16:22:12 -06:00
_Example_
\code
Sha256 sha256[1];
if ((ret = wc_InitSha256(sha256)) != 0) {
WOLFSSL_MSG("wc_InitSha256 failed");
}
else {
wc_Sha256Update(sha256, data, len);
wc_Sha256GetHash(sha256, hash);
}
\endcode
2018-06-27 16:22:12 -06:00
\sa wc_Sha256Hash
\sa wc_Sha256Final
\sa wc_InitSha256
*/
int wc_Sha256GetHash(wc_Sha256* sha256, byte* hash);
/*!
\ingroup SHA
2018-06-27 16:22:12 -06:00
\brief Used to initialize a Sha224 struct.
2018-06-27 16:22:12 -06:00
\return 0 Success
\return 1 Error returned because sha224 is null.
2018-06-27 16:22:12 -06:00
\param sha224 Pointer to a Sha224 struct to initialize.
2018-06-27 16:22:12 -06:00
_Example_
\code
Sha224 sha224;
if(wc_InitSha224(&sha224) != 0)
{
// Handle error
}
\endcode
2018-06-27 16:22:12 -06:00
\sa wc_Sha224Hash
\sa wc_Sha224Update
\sa wc_Sha224Final
*/
int wc_InitSha224(wc_Sha224*);
/*!
\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 Success
\return 1 Error returned if function fails.
\return BAD_FUNC_ARG Error returned if sha224 or data is null.
\param sha224 Pointer to the Sha224 structure to use for encryption.
\param data Data to be hashed.
\param len Length of data to be hashed.
_Example_
\code
Sha224 sha224;
byte data[] = { /* Data to be hashed };
word32 len = sizeof(data);
if ((ret = wc_InitSha224(&sha224)) != 0) {
WOLFSSL_MSG("wc_InitSha224 failed");
}
else {
wc_Sha224Update(&sha224, data, len);
wc_Sha224Final(&sha224, hash);
}
\endcode
2018-06-27 16:22:12 -06:00
\sa wc_InitSha224
\sa wc_Sha224Final
\sa wc_Sha224Hash
*/
int wc_Sha224Update(wc_Sha224* sha224, 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 sha224 struct.
2018-06-27 16:22:12 -06:00
\return 0 Success
\return <0 Error
2018-06-27 16:22:12 -06:00
\param sha224 pointer to the sha224 structure to use for encryption
\param hash Byte array to hold hash value.
2018-06-27 16:22:12 -06:00
_Example_
\code
Sha224 sha224;
byte data[] = { /* Data to be hashed };
word32 len = sizeof(data);
if ((ret = wc_InitSha224(&sha224)) != 0) {
WOLFSSL_MSG("wc_InitSha224 failed");
}
else {
wc_Sha224Update(&sha224, data, len);
wc_Sha224Final(&sha224, hash);
}
\endcode
2018-06-27 16:22:12 -06:00
\sa wc_InitSha224
\sa wc_Sha224Hash
\sa wc_Sha224Update
*/
int wc_Sha224Final(wc_Sha224* sha224, byte* hash);