12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250 |
- /*!
- \ingroup SHA
- \brief This function initializes SHA3-224. This is automatically
- called by wc_Sha3_224Hash.
- \return 0 Returned upon successfully initializing
- \param sha3 pointer to the sha3 structure to use for encryption
- _Example_
- \code
- wc_Sha3 sha3[1];
- if ((ret = wc_InitSha3_224(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_224 failed");
- }
- else {
- wc_Sha3_224_Update(sha3, data, len);
- wc_Sha3_224_Final(sha3, hash);
- }
- \endcode
- \sa wc_Sha3_224Hash
- \sa wc_Sha3_224_Update
- \sa wc_Sha3_224_Final
- */
- int wc_InitSha3_224(wc_Sha3* sha3, void* heap, int devId);
- /*!
- \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 sha3 pointer to the sha3 structure to use for encryption
- \param data the data to be hashed
- \param len length of data to be hashed
- _Example_
- \code
- wc_Sha3 sha3[1];
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- if ((ret = wc_InitSha3_224(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_224 failed");
- }
- else {
- wc_Sha3_224_Update(sha3, data, len);
- wc_Sha3_224_Final(sha3, hash);
- }
- \endcode
- \sa wc_Sha3_224Hash
- \sa wc_Sha3_224_Final
- \sa wc_InitSha3_224
- */
- int wc_Sha3_224_Update(wc_Sha3* sha, const byte* data, word32 len);
- /*!
- \ingroup SHA
- \brief Finalizes hashing of data. Result is placed into hash.
- Resets state of sha3 struct.
- \return 0 Returned upon successfully finalizing.
- \param sha3 pointer to the sha3 structure to use for encryption
- \param hash Byte array to hold hash value.
- _Example_
- \code
- wc_Sha3 sha3[1];
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- if ((ret = wc_InitSha3_224(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_224 failed");
- }
- else {
- wc_Sha3_224_Update(sha3, data, len);
- wc_Sha3_224_Final(sha3, hash);
- }
- \endcode
- \sa wc_Sha3_224Hash
- \sa wc_Sha3_224_GetHash
- \sa wc_InitSha3_224
- */
- int wc_Sha3_224_Final(wc_Sha3* sha3, byte* hash);
- /*!
- \ingroup SHA
- \brief Resets the wc_Sha3 structure. Note: this is only supported
- if you have WOLFSSL_TI_HASH defined.
- \return none No returns.
- \param sha3 Pointer to the sha3 structure to be freed.
- _Example_
- \code
- wc_Sha3 sha3;
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- if ((ret = wc_InitSha3_224(&sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_224 failed");
- }
- else {
- wc_Sha3_224_Update(&sha3, data, len);
- wc_Sha3_224_Final(&sha3, hash);
- wc_Sha3_224_Free(&sha3);
- }
- \endcode
- \sa wc_InitSha3_224
- \sa wc_Sha3_224_Update
- \sa wc_Sha3_224_Final
- */
- void wc_Sha3_224_Free(wc_Sha3*);
- /*!
- \ingroup SHA
- \brief Gets hash data. Result is placed into hash. Does not
- reset state of sha3 struct.
- \return 0 Returned upon successful copying of the hash.
- \param sha3 pointer to the sha3 structure to use for encryption
- \param hash Byte array to hold hash value.
- _Example_
- \code
- wc_Sha3 sha3[1];
- if ((ret = wc_InitSha3_224(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_224 failed");
- }
- else {
- wc_Sha3_224_Update(sha3, data, len);
- wc_Sha3_224_GetHash(sha3, hash);
- }
- \endcode
- \sa wc_Sha3_224Hash
- \sa wc_Sha3_224_Final
- \sa wc_InitSha3_224
- \sa wc_Sha3_224_Copy
- */
- int wc_Sha3_224_GetHash(wc_Sha3* sha3, byte* hash);
- /*!
- \ingroup SHA
- \brief Copy the state of the hash.
- \return 0 Returned upon successful copying.
- \param sha3 pointer to the sha3 structure to copy
- \param dst pointer to the sha3 structure to copy into
- _Example_
- \code
- wc_Sha3 sha3[1];
- wc_Sha3 sha3_dup[1];
- if ((ret = wc_InitSha3_224(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_224 failed");
- }
- else {
- wc_Sha3_224_Update(sha3, data, len);
- wc_Sha3_224_Copy(sha3, sha3_dup);
- }
- \endcode
- \sa wc_Sha3_224Hash
- \sa wc_Sha3_224_Final
- \sa wc_InitSha3_224
- \sa wc_Sha3_224_GetHash
- */
- int wc_Sha3_224_Copy(wc_Sha3* sha3, wc_Sha3* dst);
- /*!
- \ingroup SHA
- \brief This function initializes SHA3-256. This is automatically
- called by wc_Sha3_256Hash.
- \return 0 Returned upon successfully initializing
- \param sha3 pointer to the sha3 structure to use for encryption
- _Example_
- \code
- wc_Sha3 sha3[1];
- if ((ret = wc_InitSha3_256(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_256 failed");
- }
- else {
- wc_Sha3_256_Update(sha3, data, len);
- wc_Sha3_256_Final(sha3, hash);
- }
- \endcode
- \sa wc_Sha3_256Hash
- \sa wc_Sha3_256_Update
- \sa wc_Sha3_256_Final
- */
- int wc_InitSha3_256(wc_Sha3* sha3, void* heap, int devId);
- /*!
- \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 sha3 pointer to the sha3 structure to use for encryption
- \param data the data to be hashed
- \param len length of data to be hashed
- _Example_
- \code
- wc_Sha3 sha3[1];
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- if ((ret = wc_InitSha3_256(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_256 failed");
- }
- else {
- wc_Sha3_256_Update(sha3, data, len);
- wc_Sha3_256_Final(sha3, hash);
- }
- \endcode
- \sa wc_Sha3_256Hash
- \sa wc_Sha3_256_Final
- \sa wc_InitSha3_256
- */
- int wc_Sha3_256_Update(wc_Sha3* sha, const byte* data, word32 len);
- /*!
- \ingroup SHA
- \brief Finalizes hashing of data. Result is placed into hash.
- Resets state of sha3 struct.
- \return 0 Returned upon successfully finalizing.
- \param sha3 pointer to the sha3 structure to use for encryption
- \param hash Byte array to hold hash value.
- _Example_
- \code
- wc_Sha3 sha3[1];
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- if ((ret = wc_InitSha3_256(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_256 failed");
- }
- else {
- wc_Sha3_256_Update(sha3, data, len);
- wc_Sha3_256_Final(sha3, hash);
- }
- \endcode
- \sa wc_Sha3_256Hash
- \sa wc_Sha3_256_GetHash
- \sa wc_InitSha3_256
- */
- int wc_Sha3_256_Final(wc_Sha3* sha3, byte* hash);
- /*!
- \ingroup SHA
- \brief Resets the wc_Sha3 structure. Note: this is only supported
- if you have WOLFSSL_TI_HASH defined.
- \return none No returns.
- \param sha3 Pointer to the sha3 structure to be freed.
- _Example_
- \code
- wc_Sha3 sha3;
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- if ((ret = wc_InitSha3_256(&sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_256 failed");
- }
- else {
- wc_Sha3_256_Update(&sha3, data, len);
- wc_Sha3_256_Final(&sha3, hash);
- wc_Sha3_256_Free(&sha3);
- }
- \endcode
- \sa wc_InitSha3_256
- \sa wc_Sha3_256_Update
- \sa wc_Sha3_256_Final
- */
- void wc_Sha3_256_Free(wc_Sha3*);
- /*!
- \ingroup SHA
- \brief Gets hash data. Result is placed into hash. Does not
- reset state of sha3 struct.
- \return 0 Returned upon successful copying of the hash.
- \param sha3 pointer to the sha3 structure to use for encryption
- \param hash Byte array to hold hash value.
- _Example_
- \code
- wc_Sha3 sha3[1];
- if ((ret = wc_InitSha3_256(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_256 failed");
- }
- else {
- wc_Sha3_256_Update(sha3, data, len);
- wc_Sha3_256_GetHash(sha3, hash);
- }
- \endcode
- \sa wc_Sha3_256Hash
- \sa wc_Sha3_256_Final
- \sa wc_InitSha3_256
- \sa wc_Sha3_256_Copy
- */
- int wc_Sha3_256_GetHash(wc_Sha3* sha3, byte* hash);
- /*!
- \ingroup SHA
- \brief Copy the state of the hash.
- \return 0 Returned upon successful copying.
- \param sha3 pointer to the sha3 structure to copy
- \param dst pointer to the sha3 structure to copy into
- _Example_
- \code
- wc_Sha3 sha3[1];
- wc_Sha3 sha3_dup[1];
- if ((ret = wc_InitSha3_256(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_256 failed");
- }
- else {
- wc_Sha3_256_Update(sha3, data, len);
- wc_Sha3_256_Copy(sha3, sha3_dup);
- }
- \endcode
- \sa wc_Sha3_256Hash
- \sa wc_Sha3_256_Final
- \sa wc_InitSha3_256
- \sa wc_Sha3_256_GetHash
- */
- int wc_Sha3_256_Copy(wc_Sha3* sha3, wc_Sha3* dst);
- /*!
- \ingroup SHA
- \brief This function initializes SHA3-384. This is automatically
- called by wc_Sha3_384Hash.
- \return 0 Returned upon successfully initializing
- \param sha3 pointer to the sha3 structure to use for encryption
- _Example_
- \code
- wc_Sha3 sha3[1];
- if ((ret = wc_InitSha3_384(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_384 failed");
- }
- else {
- wc_Sha3_384_Update(sha3, data, len);
- wc_Sha3_384_Final(sha3, hash);
- }
- \endcode
- \sa wc_Sha3_384Hash
- \sa wc_Sha3_384_Update
- \sa wc_Sha3_384_Final
- */
- int wc_InitSha3_384(wc_Sha3* sha3, void* heap, int devId);
- /*!
- \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 sha3 pointer to the sha3 structure to use for encryption
- \param data the data to be hashed
- \param len length of data to be hashed
- _Example_
- \code
- wc_Sha3 sha3[1];
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- if ((ret = wc_InitSha3_384(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_384 failed");
- }
- else {
- wc_Sha3_384_Update(sha3, data, len);
- wc_Sha3_384_Final(sha3, hash);
- }
- \endcode
- \sa wc_Sha3_384Hash
- \sa wc_Sha3_384_Final
- \sa wc_InitSha3_384
- */
- int wc_Sha3_384_Update(wc_Sha3* sha, const byte* data, word32 len);
- /*!
- \ingroup SHA
- \brief Finalizes hashing of data. Result is placed into hash.
- Resets state of sha3 struct.
- \return 0 Returned upon successfully finalizing.
- \param sha3 pointer to the sha3 structure to use for encryption
- \param hash Byte array to hold hash value.
- _Example_
- \code
- wc_Sha3 sha3[1];
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- if ((ret = wc_InitSha3_384(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_384 failed");
- }
- else {
- wc_Sha3_384_Update(sha3, data, len);
- wc_Sha3_384_Final(sha3, hash);
- }
- \endcode
- \sa wc_Sha3_384Hash
- \sa wc_Sha3_384_GetHash
- \sa wc_InitSha3_384
- */
- int wc_Sha3_384_Final(wc_Sha3* sha3, byte* hash);
- /*!
- \ingroup SHA
- \brief Resets the wc_Sha3 structure. Note: this is only supported
- if you have WOLFSSL_TI_HASH defined.
- \return none No returns.
- \param sha3 Pointer to the sha3 structure to be freed.
- _Example_
- \code
- wc_Sha3 sha3;
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- if ((ret = wc_InitSha3_384(&sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_384 failed");
- }
- else {
- wc_Sha3_384_Update(&sha3, data, len);
- wc_Sha3_384_Final(&sha3, hash);
- wc_Sha3_384_Free(&sha3);
- }
- \endcode
- \sa wc_InitSha3_384
- \sa wc_Sha3_384_Update
- \sa wc_Sha3_384_Final
- */
- void wc_Sha3_384_Free(wc_Sha3*);
- /*!
- \ingroup SHA
- \brief Gets hash data. Result is placed into hash. Does not
- reset state of sha3 struct.
- \return 0 Returned upon successful copying of the hash.
- \param sha3 pointer to the sha3 structure to use for encryption
- \param hash Byte array to hold hash value.
- _Example_
- \code
- wc_Sha3 sha3[1];
- if ((ret = wc_InitSha3_384(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_38384ailed");
- }
- else {
- wc_Sha3_384_Update(sha3, data, len);
- wc_Sha3_384_GetHash(sha3, hash);
- }
- \endcode
- \sa wc_Sha3_384Hash
- \sa wc_Sha3_384_Final
- \sa wc_InitSha3_384
- \sa wc_Sha3_384_Copy
- */
- int wc_Sha3_384_GetHash(wc_Sha3* sha3, byte* hash);
- /*!
- \ingroup SHA
- \brief Copy the state of the hash.
- \return 0 Returned upon successful copying.
- \param sha3 pointer to the sha3 structure to copy
- \param dst pointer to the sha3 structure to copy into
- _Example_
- \code
- wc_Sha3 sha3[1];
- wc_Sha3 sha3_dup[1];
- if ((ret = wc_InitSha3_384(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_384 failed");
- }
- else {
- wc_Sha3_384_Update(sha3, data, len);
- wc_Sha3_384_Copy(sha3, sha3_dup);
- }
- \endcode
- \sa wc_Sha3_384Hash
- \sa wc_Sha3_384_Final
- \sa wc_InitSha3_384
- \sa wc_Sha3_384_GetHash
- */
- int wc_Sha3_384_Copy(wc_Sha3* sha3, wc_Sha3* dst);
- /*!
- \ingroup SHA
- \brief This function initializes SHA3-512. This is automatically
- called by wc_Sha3_512Hash.
- \return 0 Returned upon successfully initializing
- \param sha3 pointer to the sha3 structure to use for encryption
- _Example_
- \code
- wc_Sha3 sha3[1];
- if ((ret = wc_InitSha3_512(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_512 failed");
- }
- else {
- wc_Sha3_512_Update(sha3, data, len);
- wc_Sha3_512_Final(sha3, hash);
- }
- \endcode
- \sa wc_Sha3_512Hash
- \sa wc_Sha3_512_Update
- \sa wc_Sha3_512_Final
- */
- int wc_InitSha3_512(wc_Sha3* sha3, void* heap, int devId);
- /*!
- \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 sha3 pointer to the sha3 structure to use for encryption
- \param data the data to be hashed
- \param len length of data to be hashed
- _Example_
- \code
- wc_Sha3 sha3[1];
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- if ((ret = wc_InitSha3_512(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_512 failed");
- }
- else {
- wc_Sha3_512_Update(sha3, data, len);
- wc_Sha3_512_Final(sha3, hash);
- }
- \endcode
- \sa wc_Sha3_512Hash
- \sa wc_Sha3_512_Final
- \sa wc_InitSha3_512
- */
- int wc_Sha3_512_Update(wc_Sha3* sha, const byte* data, word32 len);
- /*!
- \ingroup SHA
- \brief Finalizes hashing of data. Result is placed into hash.
- Resets state of sha3 struct.
- \return 0 Returned upon successfully finalizing.
- \param sha3 pointer to the sha3 structure to use for encryption
- \param hash Byte array to hold hash value.
- _Example_
- \code
- wc_Sha3 sha3[1];
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- if ((ret = wc_InitSha3_512(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_512 failed");
- }
- else {
- wc_Sha3_512_Update(sha3, data, len);
- wc_Sha3_512_Final(sha3, hash);
- }
- \endcode
- \sa wc_Sha3_512Hash
- \sa wc_Sha3_512_GetHash
- \sa wc_InitSha3_512
- */
- int wc_Sha3_512_Final(wc_Sha3* sha3, byte* hash);
- /*!
- \ingroup SHA
- \brief Resets the wc_Sha3 structure. Note: this is only supported
- if you have WOLFSSL_TI_HASH defined.
- \return none No returns.
- \param sha3 Pointer to the sha3 structure to be freed.
- _Example_
- \code
- wc_Sha3 sha3;
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- if ((ret = wc_InitSha3_512(&sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_512 failed");
- }
- else {
- wc_Sha3_512_Update(&sha3, data, len);
- wc_Sha3_512_Final(&sha3, hash);
- wc_Sha3_512_Free(&sha3);
- }
- \endcode
- \sa wc_InitSha3_512
- \sa wc_Sha3_512_Update
- \sa wc_Sha3_512_Final
- */
- void wc_Sha3_512_Free(wc_Sha3*);
- /*!
- \ingroup SHA
- \brief Gets hash data. Result is placed into hash. Does not
- reset state of sha3 struct.
- \return 0 Returned upon successful copying of the hash.
- \param sha3 pointer to the sha3 structure to use for encryption
- \param hash Byte array to hold hash value.
- _Example_
- \code
- wc_Sha3 sha3[1];
- if ((ret = wc_InitSha3_512(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_512 failed");
- }
- else {
- wc_Sha3_512_Update(sha3, data, len);
- wc_Sha3_512_GetHash(sha3, hash);
- }
- \endcode
- \sa wc_Sha3_512Hash
- \sa wc_Sha3_512_Final
- \sa wc_InitSha3_512
- \sa wc_Sha3_512_Copy
- */
- int wc_Sha3_512_GetHash(wc_Sha3* sha3, byte* hash);
- /*!
- \ingroup SHA
- \brief Copy the state of the hash.
- \return 0 Returned upon successful copying.
- \param sha3 pointer to the sha3 structure to copy
- \param dst pointer to the sha3 structure to copy into
- _Example_
- \code
- wc_Sha3 sha3[1];
- wc_Sha3 sha3_dup[1];
- if ((ret = wc_InitSha3_512(sha3, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitSha3_512 failed");
- }
- else {
- wc_Sha3_512_Update(sha3, data, len);
- wc_Sha3_512_Copy(sha3, sha3_dup);
- }
- \endcode
- \sa wc_Sha3_512Hash
- \sa wc_Sha3_512_Final
- \sa wc_InitSha3_512
- \sa wc_Sha3_512_GetHash
- */
- int wc_Sha3_512_Copy(wc_Sha3* sha3, wc_Sha3* dst);
- /*!
- \ingroup SHA
- \brief This function initializes SHAKE-128. This is automatically
- called by wc_Shake128Hash.
- \return 0 Returned upon successfully initializing
- \param shake pointer to the shake structure to use for encryption
- _Example_
- \code
- wc_Shake shake[1];
- if ((ret = wc_InitShake128(shake, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitShake128 failed");
- }
- else {
- wc_Shake128_Update(shake, data, len);
- wc_Shake128_Final(shake, hash);
- }
- \endcode
- \sa wc_Shake128Hash
- \sa wc_Shake128_Update
- \sa wc_Shake128_Final
- */
- int wc_InitShake128(wc_Shake* shake, void* heap, int devId);
- /*!
- \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 shake pointer to the shake structure to use for encryption
- \param data the data to be hashed
- \param len length of data to be hashed
- _Example_
- \code
- wc_Shake shake[1];
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- if ((ret = wc_InitShake128(shake, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitShake128 failed");
- }
- else {
- wc_Shake128_Update(shake, data, len);
- wc_Shake128_Final(shake, hash);
- }
- \endcode
- \sa wc_Shake128Hash
- \sa wc_Shake128_Final
- \sa wc_InitShake128
- */
- int wc_Shake128_Update(wc_Shake* sha, const byte* data, word32 len);
- /*!
- \ingroup SHA
- \brief Finalizes hashing of data. Result is placed into hash.
- Resets state of shake struct.
- \return 0 Returned upon successfully finalizing.
- \param shake pointer to the shake structure to use for encryption
- \param hash Byte array to hold hash value.
- _Example_
- \code
- wc_Shake shake[1];
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- if ((ret = wc_InitShake128(shake, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitShake128 failed");
- }
- else {
- wc_Shake128_Update(shake, data, len);
- wc_Shake128_Final(shake, hash);
- }
- \endcode
- \sa wc_Shake128Hash
- \sa wc_Shake128_GetHash
- \sa wc_InitShake128
- */
- int wc_Shake128_Final(wc_Shake* shake, byte* hash);
- /*!
- \ingroup SHA
- \brief Called to absorb the provided byte array of length len. Cannot
- be called incrementally.
- \return 0 Returned upon successfully absorbed the data.
- \param shake pointer to the shake structure to use for encryption
- \param data the data to be absorbed
- \param len length of data to be absorbed
- _Example_
- \code
- wc_Shake shake[1];
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- byte out[2 * WC_SHA3_128_BLOCK_SIZE];
- int blocks = 2;
- if ((ret = wc_InitShake128(shake, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitShake128 failed");
- }
- else {
- wc_Shake128_Absorb(shake, data, len);
- wc_Shake128_SqueezeBlocks(shake, out, blocks);
- }
- \endcode
- \sa wc_Shake128_SqueezeBlocks
- \sa wc_InitShake128
- */
- int wc_Shake128_Absorb(wc_Shake* sha, const byte* data, word32 len);
- /*!
- \ingroup SHA
- \brief Squeeze out more blocks of data. Result is placed into out. Can be
- called inrementally.
- \return 0 Returned upon successfully squeezing.
- \param shake pointer to the shake structure to use for encryption
- \param hash Byte array to hold output.
- \param blocks Number of blocks to squeeze out. Each block is
- WC_SHA3_128_BLOCK_SIZE bytes in length.
- _Example_
- \code
- wc_Shake shake[1];
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- byte out[2 * WC_SHA3_128_BLOCK_SIZE];
- int blocks = 2;
- if ((ret = wc_InitShake128(shake, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitShake128 failed");
- }
- else {
- wc_Shake128_Absorb(shake, data, len);
- wc_Shake128_SqueezeBlocks(shake, out, blocks);
- }
- \endcode
- \sa wc_Shake128_Absorb
- \sa wc_InitShake128
- */
- int wc_Shake128_SqueezeBlocks(wc_Shake* shake, byte* out, word32 blockCnt);
- /*!
- \ingroup SHA
- \brief Resets the wc_Shake structure. Note: this is only supported
- if you have WOLFSSL_TI_HASH defined.
- \return none No returns.
- \param shake Pointer to the shake structure to be freed.
- _Example_
- \code
- wc_Shake shake;
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- if ((ret = wc_InitShake128(&shake, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitShake128 failed");
- }
- else {
- wc_Shake128_Update(&shake, data, len);
- wc_Shake128_Final(&shake, hash);
- wc_Shake128_Free(&shake);
- }
- \endcode
- \sa wc_InitShake128
- \sa wc_Shake128_Update
- \sa wc_Shake128_Final
- */
- void wc_Shake128_Free(wc_Shake*);
- /*!
- \ingroup SHA
- \brief Gets hash data. Result is placed into hash. Does not
- reset state of shake struct.
- \return 0 Returned upon successful copying of the hash.
- \param shake pointer to the shake structure to use for encryption
- \param hash Byte array to hold hash value.
- _Example_
- \code
- wc_Shake shake[1];
- if ((ret = wc_InitShake128(shake, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitShake128 failed");
- }
- else {
- wc_Shake128_Update(shake, data, len);
- wc_Shake128_GetHash(shake, hash);
- }
- \endcode
- \sa wc_Shake128Hash
- \sa wc_Shake128_Final
- \sa wc_InitShake128
- \sa wc_Shake128_Copy
- */
- int wc_Shake128_GetHash(wc_Shake* shake, byte* hash);
- /*!
- \ingroup SHA
- \brief Copy the state of the hash.
- \return 0 Returned upon successful copying.
- \param shake pointer to the shake structure to copy
- \param dst pointer to the shake structure to copy into
- _Example_
- \code
- wc_Shake shake[1];
- wc_Shake shake_dup[1];
- if ((ret = wc_InitShake128(shake, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitShake128 failed");
- }
- else {
- wc_Shake128_Update(shake, data, len);
- wc_Shake128_Copy(shake, shake_dup);
- }
- \endcode
- \sa wc_Shake128Hash
- \sa wc_Shake128_Final
- \sa wc_InitShake128
- \sa wc_Shake128_GetHash
- */
- int wc_Shake128_Copy(wc_Shake* shake, wc_Shake* dst);
- /*!
- \ingroup SHA
- \brief This function initializes SHAKE-256. This is automatically
- called by wc_Shake256Hash.
- \return 0 Returned upon successfully initializing
- \param shake pointer to the shake structure to use for encryption
- _Example_
- \code
- wc_Shake shake[1];
- if ((ret = wc_InitShake256(shake, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitShake256 failed");
- }
- else {
- wc_Shake256_Update(shake, data, len);
- wc_Shake256_Final(shake, hash, sizeof(hash));
- }
- \endcode
- \sa wc_Shake256Hash
- \sa wc_Shake256_Update
- \sa wc_Shake256_Final
- */
- int wc_InitShake256(wc_Shake* shake, void* heap, int devId);
- /*!
- \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 shake pointer to the shake structure to use for encryption
- \param data the data to be hashed
- \param len length of data to be hashed
- _Example_
- \code
- wc_Shake shake[1];
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- if ((ret = wc_InitShake256(shake, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitShake256 failed");
- }
- else {
- wc_Shake256_Update(shake, data, len);
- wc_Shake256_Final(shake, hash, sizeof(hash));
- }
- \endcode
- \sa wc_Shake256Hash
- \sa wc_Shake256_Final
- \sa wc_InitShake256
- */
- int wc_Shake256_Update(wc_Shake* sha, const byte* data, word32 len);
- /*!
- \ingroup SHA
- \brief Finalizes hashing of data. Result is placed into hash.
- Resets state of shake struct.
- \return 0 Returned upon successfully finalizing.
- \param shake pointer to the shake structure to use for encryption
- \param hash Byte array to hold hash value.
- \param hashLen Size of hash in bytes.
- _Example_
- \code
- wc_Shake shake[1];
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- if ((ret = wc_InitShake256(shake, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitShake256 failed");
- }
- else {
- wc_Shake256_Update(shake, data, len);
- wc_Shake256_Final(shake, hash, sizeof(hash));
- }
- \endcode
- \sa wc_Shake256Hash
- \sa wc_Shake256_GetHash
- \sa wc_InitShake256
- */
- int wc_Shake256_Final(wc_Shake* shake, byte* hash, word32 hashLen);
- /*!
- \ingroup SHA
- \brief Called to absorb the provided byte array of length len. Cannot
- be called incrementally.
- \return 0 Returned upon successfully absorbed the data.
- \param shake pointer to the shake structure to use for encryption
- \param data the data to be absorbed
- \param len length of data to be absorbed
- _Example_
- \code
- wc_Shake shake[1];
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- byte out[2 * WC_SHA3_256_BLOCK_SIZE];
- int blocks = 2;
- if ((ret = wc_InitShake256(shake, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitShake256 failed");
- }
- else {
- wc_Shake256_Absorb(shake, data, len);
- wc_Shake256_SqueezeBlocks(shake, out, blocks);
- }
- \endcode
- \sa wc_Shake256_SqueezeBlocks
- \sa wc_InitShake256
- */
- int wc_Shake256_Absorb(wc_Shake* sha, const byte* data, word32 len);
- /*!
- \ingroup SHA
- \brief Squeeze out more blocks of data. Result is placed into out. Can be
- called incrementally.
- \return 0 Returned upon successfully squeezing.
- \param shake pointer to the shake structure to use for encryption
- \param hash Byte array to hold output.
- \param blocks Number of blocks to squeeze out. Each block is
- WC_SHA3_256_BLOCK_SIZE bytes in length.
- _Example_
- \code
- wc_Shake shake[1];
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- byte out[2 * WC_SHA3_256_BLOCK_SIZE];
- int blocks = 2;
- if ((ret = wc_InitShake256(shake, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitShake256 failed");
- }
- else {
- wc_Shake256_Absorb(shake, data, len);
- wc_Shake256_SqueezeBlocks(shake, out, blocks);
- }
- \endcode
- \sa wc_Shake256_Absorb
- \sa wc_InitShake256
- */
- int wc_Shake256_SqueezeBlocks(wc_Shake* shake, byte* out, word32 blockCnt);
- /*!
- \ingroup SHA
- \brief Resets the wc_Shake structure. Note: this is only supported
- if you have WOLFSSL_TI_HASH defined.
- \return none No returns.
- \param shake Pointer to the shake structure to be freed.
- _Example_
- \code
- wc_Shake shake;
- byte data[] = { Data to be hashed };
- word32 len = sizeof(data);
- if ((ret = wc_InitShake256(&shake, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitShake256 failed");
- }
- else {
- wc_Shake256_Update(&shake, data, len);
- wc_Shake256_Final(&shake, hash, sizeof(hash));
- wc_Shake256_Free(&shake);
- }
- \endcode
- \sa wc_InitShake256
- \sa wc_Shake256_Update
- \sa wc_Shake256_Final
- */
- void wc_Shake256_Free(wc_Shake*);
- /*!
- \ingroup SHA
- \brief Gets hash data. Result is placed into hash. Does not
- reset state of shake struct.
- \return 0 Returned upon successful copying of the hash.
- \param shake pointer to the shake structure to use for encryption
- \param hash Byte array to hold hash value.
- _Example_
- \code
- wc_Shake shake[1];
- if ((ret = wc_InitShake256(shake, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitShake256 failed");
- }
- else {
- wc_Shake256_Update(shake, data, len);
- wc_Shake256_GetHash(shake, hash);
- }
- \endcode
- \sa wc_Shake256Hash
- \sa wc_Shake256_Final
- \sa wc_InitShake256
- \sa wc_Shake256_Copy
- */
- int wc_Shake256_GetHash(wc_Shake* shake, byte* hash);
- /*!
- \ingroup SHA
- \brief Copy the state of the hash.
- \return 0 Returned upon successful copying.
- \param shake pointer to the shake structure to copy
- \param dst pointer to the shake structure to copy into
- _Example_
- \code
- wc_Shake shake[1];
- wc_Shake shake_dup[1];
- if ((ret = wc_InitShake256(shake, NULL, INVALID_DEVID)) != 0) {
- WOLFSSL_MSG("wc_InitShake256 failed");
- }
- else {
- wc_Shake256_Update(shake, data, len);
- wc_Shake256_Copy(shake, shake_dup);
- }
- \endcode
- \sa wc_Shake256Hash
- \sa wc_Shake256_Final
- \sa wc_InitShake256
- \sa wc_Shake256_GetHash
- */
- int wc_Shake256_Copy(wc_Shake* shake, wc_Shake* dst);
|