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