Algorithms - SHA 128/224/256/384/512
Functions
| Name | |
|---|---|
| int | wc_ShaHash(const byte * data, word32 len, byte * hash) Convenience function, handles all the hashing and places the result into hash. |
| int | wc_Sha224Hash(const byte * data, word32 len, byte * hash) Convenience function, handles all the hashing and places the result into hash. |
| int | wc_Sha256Hash(const byte * data, word32 len, byte * hash) Convenience function, handles all the hashing and places the result into hash. |
| int | wc_Sha384Hash(const byte * data, word32 len, byte * hash) Convenience function, handles all the hashing and places the result into hash. |
| int | wc_Sha512Hash(const byte * data, word32 len, byte * hash) Convenience function, handles all the hashing and places the result into hash. |
| int | wc_Sha3_224Hash(const byte * data, word32 len, byte * hash) Convenience function, handles all the hashing and places the result into hash. |
| int | wc_Sha3_256Hash(const byte * data, word32 len, byte * hash) Convenience function, handles all the hashing and places the result into hash. |
| int | wc_Sha3_384Hash(const byte * data, word32 len, byte * hash) Convenience function, handles all the hashing and places the result into hash. |
| int | wc_Sha3_512Hash(const byte * data, word32 len, byte * hash) Convenience function, handles all the hashing and places the result into hash. |
| int | wc_Shake128Hash(const byte * data, word32 len, byte * hash, word32 hashLen) Convenience function, handles all the hashing and places the result into hash. |
| int | wc_Shake256Hash(const byte * data, word32 len, byte * hash, word32 hashLen) Convenience function, handles all the hashing and places the result into hash. |
| int | wc_InitSha(wc_Sha * sha) This function initializes SHA. This is automatically called by wc_ShaHash. |
| int | wc_ShaUpdate(wc_Sha * sha, const byte * data, word32 len) Can be called to continually hash the provided byte array of length len. |
| int | wc_ShaFinal(wc_Sha * sha, byte * hash) Finalizes hashing of data. Result is placed into hash. Resets state of sha struct. |
| void | wc_ShaFree(wc_Sha * sha) Used to clean up memory used by an initialized Sha struct. |
| int | wc_ShaGetHash(wc_Sha * sha, byte * hash) Gets hash data. Result is placed into hash. Does not reset state of sha struct. |
| int | wc_InitSha_ex(wc_Sha * sha, void * heap, int devId) Initializes SHA with heap and device ID. |
| int | wc_ShaFinalRaw(wc_Sha * sha, byte * hash) Gets raw hash without finalizing. |
| int | wc_ShaCopy(wc_Sha * src, wc_Sha * dst) Copies SHA context. |
| int | wc_ShaTransform(wc_Sha * sha, const unsigned char * data) Transforms SHA block. |
| void | wc_ShaSizeSet(wc_Sha * sha, word32 len) Sets SHA size. |
| int | wc_ShaSetFlags(wc_Sha * sha, word32 flags) Sets SHA flags. |
| int | wc_InitSha256(wc_Sha256 * sha) This function initializes SHA256. This is automatically called by wc_Sha256Hash. |
| int | wc_Sha256Update(wc_Sha256 * sha, const byte * data, word32 len) Can be called to continually hash the provided byte array of length len. |
| int | wc_Sha256Final(wc_Sha256 * sha256, byte * hash) Finalizes hashing of data. Result is placed into hash. Resets state of sha256 struct. |
| void | wc_Sha256Free(wc_Sha256 * sha256) Resets the Sha256 structure. Note: this is only supported if you have WOLFSSL_TI_HASH defined. |
| int | wc_Sha256GetHash(wc_Sha256 * sha256, byte * hash) Gets hash data. Result is placed into hash. Does not reset state of sha256 struct. |
| int | wc_InitSha224(wc_Sha224 * sha224) Used to initialize a Sha224 struct. |
| int | wc_Sha224Update(wc_Sha224 * sha224, const byte * data, word32 len) Can be called to continually hash the provided byte array of length len. |
| int | wc_Sha224Final(wc_Sha224 * sha224, byte * hash) Finalizes hashing of data. Result is placed into hash. Resets state of sha224 struct. |
| int | wc_InitSha256_ex(wc_Sha256 * sha, void * heap, int devId) Initializes SHA256 with heap and device ID. |
| int | wc_Sha256FinalRaw(wc_Sha256 * sha256, byte * hash) Gets raw hash without finalizing. |
| int | wc_Sha256Transform(wc_Sha256 * sha, const unsigned char * data) Transforms SHA256 block. |
| int | wc_Sha256HashBlock(wc_Sha256 * sha, const unsigned char * data, unsigned char * hash) Hashes single block and outputs result. |
| int | wc_Sha256_Grow(wc_Sha256 * sha256, const byte * in, int inSz) Grows SHA256 buffer with input data. This function is only available when WOLFSSL_HASH_KEEP is defined. It is used for keeping an internal buffer to hold all data to be hashed rather than iterating over update, which is necessary for some hardware acceleration platforms that have restrictions on streaming hash operations. |
| int | wc_Sha256Copy(wc_Sha256 * src, wc_Sha256 * dst) Copies SHA256 context. |
| void | wc_Sha256SizeSet(wc_Sha256 * sha256, word32 len) Sets SHA256 size. |
| int | wc_Sha256SetFlags(wc_Sha256 * sha256, word32 flags) Sets SHA256 flags. |
| int | wc_Sha256GetFlags(wc_Sha256 * sha256, word32 * flags) Gets SHA256 flags. |
| int | wc_InitSha224_ex(wc_Sha224 * sha224, void * heap, int devId) Initializes SHA224 with heap and device ID. |
| void | wc_Sha224Free(wc_Sha224 * sha224) Frees SHA224 resources. |
| int | wc_Sha224_Grow(wc_Sha224 * sha224, const byte * in, int inSz) Grows SHA224 buffer with input data. This function is only available when WOLFSSL_HASH_KEEP is defined. It is used for keeping an internal buffer to hold all data to be hashed rather than iterating over update, which is necessary for some hardware acceleration platforms that have restrictions on streaming hash operations. |
| int | wc_Sha224GetHash(wc_Sha224 * sha224, byte * hash) Gets SHA224 hash without finalizing. |
| int | wc_Sha224Copy(wc_Sha224 * src, wc_Sha224 * dst) Copies SHA224 context. |
| int | wc_Sha224SetFlags(wc_Sha224 * sha224, word32 flags) Sets SHA224 flags. |
| int | wc_Sha224GetFlags(wc_Sha224 * sha224, word32 * flags) Gets SHA224 flags. |
| int | wc_InitSha3_224(wc_Sha3 * sha3, void * heap, int devId) This function initializes SHA3-224. This is automatically called by wc_Sha3_224Hash. |
| int | wc_Sha3_224_Update(wc_Sha3 * sha, const byte * data, word32 len) Can be called to continually hash the provided byte array of length len. |
| int | wc_Sha3_224_Final(wc_Sha3 * sha3, byte * hash) Finalizes hashing of data. Result is placed into hash. Resets state of sha3 struct. |
| void | wc_Sha3_224_Free(wc_Sha3 * sha3) Resets the wc_Sha3 structure. Note: this is only supported if you have WOLFSSL_TI_HASH defined. |
| int | wc_Sha3_224_GetHash(wc_Sha3 * sha3, byte * hash) Gets hash data. Result is placed into hash. Does not reset state of sha3 struct. |
| int | wc_Sha3_224_Copy(wc_Sha3 * sha3, wc_Sha3 * dst) Copy the state of the hash. |
| int | wc_InitSha3_256(wc_Sha3 * sha3, void * heap, int devId) This function initializes SHA3-256. This is automatically called by wc_Sha3_256Hash. |
| int | wc_Sha3_256_Update(wc_Sha3 * sha, const byte * data, word32 len) Can be called to continually hash the provided byte array of length len. |
| int | wc_Sha3_256_Final(wc_Sha3 * sha3, byte * hash) Finalizes hashing of data. Result is placed into hash. Resets state of sha3 struct. |
| void | wc_Sha3_256_Free(wc_Sha3 * sha3) Resets the wc_Sha3 structure. Note: this is only supported if you have WOLFSSL_TI_HASH defined. |
| int | wc_Sha3_256_GetHash(wc_Sha3 * sha3, byte * hash) Gets hash data. Result is placed into hash. Does not reset state of sha3 struct. |
| int | wc_Sha3_256_Copy(wc_Sha3 * sha3, wc_Sha3 * dst) Copy the state of the hash. |
| int | wc_InitSha3_384(wc_Sha3 * sha3, void * heap, int devId) This function initializes SHA3-384. This is automatically called by wc_Sha3_384Hash. |
| int | wc_Sha3_384_Update(wc_Sha3 * sha, const byte * data, word32 len) Can be called to continually hash the provided byte array of length len. |
| int | wc_Sha3_384_Final(wc_Sha3 * sha3, byte * hash) Finalizes hashing of data. Result is placed into hash. Resets state of sha3 struct. |
| void | wc_Sha3_384_Free(wc_Sha3 * sha3) Resets the wc_Sha3 structure. Note: this is only supported if you have WOLFSSL_TI_HASH defined. |
| int | wc_Sha3_384_GetHash(wc_Sha3 * sha3, byte * hash) Gets hash data. Result is placed into hash. Does not reset state of sha3 struct. |
| int | wc_Sha3_384_Copy(wc_Sha3 * sha3, wc_Sha3 * dst) Copy the state of the hash. |
| int | wc_InitSha3_512(wc_Sha3 * sha3, void * heap, int devId) This function initializes SHA3-512. This is automatically called by wc_Sha3_512Hash. |
| int | wc_Sha3_512_Update(wc_Sha3 * sha, const byte * data, word32 len) Can be called to continually hash the provided byte array of length len. |
| int | wc_Sha3_512_Final(wc_Sha3 * sha3, byte * hash) Finalizes hashing of data. Result is placed into hash. Resets state of sha3 struct. |
| void | wc_Sha3_512_Free(wc_Sha3 * sha3) Resets the wc_Sha3 structure. Note: this is only supported if you have WOLFSSL_TI_HASH defined. |
| int | wc_Sha3_512_GetHash(wc_Sha3 * sha3, byte * hash) Gets hash data. Result is placed into hash. Does not reset state of sha3 struct. |
| int | wc_Sha3_512_Copy(wc_Sha3 * sha3, wc_Sha3 * dst) Copy the state of the hash. |
| int | wc_InitShake128(wc_Shake * shake, void * heap, int devId) This function initializes SHAKE-128. This is automatically called by wc_Shake128Hash. |
| int | wc_Shake128_Update(wc_Shake * sha, const byte * data, word32 len) Can be called to continually hash the provided byte array of length len. |
| int | wc_Shake128_Final(wc_Shake * shake, byte * hash, word32 hashLen) Finalizes hashing of data. Result is placed into hash. Resets state of shake struct. |
| int | wc_Shake128_Absorb(wc_Shake * sha, const byte * data, word32 len) Called to absorb the provided byte array of length len. Cannot be called incrementally. |
| int | wc_Shake128_SqueezeBlocks(wc_Shake * shake, byte * out, word32 blockCnt) Squeeze out more blocks of data. Result is placed into out. Can be called inrementally. |
| void | wc_Shake128_Free(wc_Shake * shake) Resets the wc_Shake structure. Note: this is only supported if you have WOLFSSL_TI_HASH defined. |
| int | wc_Shake128_GetHash(wc_Shake * shake, byte * hash) Gets hash data. Result is placed into hash. Does not reset state of shake struct. |
| int | wc_Shake128_Copy(wc_Shake * src, wc_Sha3 * dst) Copy the state of the hash. |
| int | wc_InitShake256(wc_Shake * shake, void * heap, int devId) This function initializes SHAKE-256. This is automatically called by wc_Shake256Hash. |
| int | wc_Shake256_Update(wc_Shake * sha, const byte * data, word32 len) Can be called to continually hash the provided byte array of length len. |
| int | wc_Shake256_Final(wc_Shake * shake, byte * hash, word32 hashLen) Finalizes hashing of data. Result is placed into hash. Resets state of shake struct. |
| int | wc_Shake256_Absorb(wc_Shake * sha, const byte * data, word32 len) Called to absorb the provided byte array of length len. Cannot be called incrementally. |
| int | wc_Shake256_SqueezeBlocks(wc_Shake * shake, byte * out, word32 blockCnt) Squeeze out more blocks of data. Result is placed into out. Can be called incrementally. |
| void | wc_Shake256_Free(wc_Shake * shake) Resets the wc_Shake structure. Note: this is only supported if you have WOLFSSL_TI_HASH defined. |
| int | wc_Shake256_GetHash(wc_Shake * shake, byte * hash) Gets hash data. Result is placed into hash. Does not reset state of shake struct. |
| int | wc_Shake256_Copy(wc_Shake * src, wc_Sha3 * dst) Copy the state of the hash. |
| int | wc_InitSha512(wc_Sha512 * sha) This function initializes SHA512. This is automatically called by wc_Sha512Hash. |
| int | wc_Sha512Update(wc_Sha512 * sha, const byte * data, word32 len) Can be called to continually hash the provided byte array of length len. |
| int | wc_Sha512Final(wc_Sha512 * sha512, byte * hash) Finalizes hashing of data. Result is placed into hash. |
| int | wc_InitSha384(wc_Sha384 * sha) This function initializes SHA384. This is automatically called by wc_Sha384Hash. |
| int | wc_Sha384Update(wc_Sha384 * sha, const byte * data, word32 len) Can be called to continually hash the provided byte array of length len. |
| int | wc_Sha384Final(wc_Sha384 * sha384, byte * hash) Finalizes hashing of data. Result is placed into hash. |
| int | wc_InitSha512_ex(wc_Sha512 * sha, void * heap, int devId) Initializes SHA512 with heap and device ID. |
| int | wc_Sha512FinalRaw(wc_Sha512 * sha512, byte * hash) Gets raw hash without finalizing. |
| void | wc_Sha512Free(wc_Sha512 * sha) Frees SHA512 resources. |
| int | wc_Sha512GetHash(wc_Sha512 * sha512, byte * hash) Gets SHA512 hash without finalizing. |
| int | wc_Sha512Copy(wc_Sha512 * src, wc_Sha512 * dst) Copies SHA512 context. |
| int | wc_Sha512_Grow(wc_Sha512 * sha512, const byte * in, int inSz) Grows SHA512 buffer with input data. |
| int | wc_Sha512SetFlags(wc_Sha512 * sha512, word32 flags) Sets SHA512 flags. |
| int | wc_Sha512GetFlags(wc_Sha512 * sha512, word32 * flags) Gets SHA512 flags. |
| int | wc_Sha512Transform(wc_Sha512 * sha, const unsigned char * data) Transforms SHA512 block. |
| int | wc_InitSha512_224(wc_Sha512 * sha) Initializes SHA512/224. |
| int | wc_InitSha512_224_ex(wc_Sha512 * sha, void * heap, int devId) Initializes SHA512/224 with heap and device ID. |
| int | wc_Sha512_224Update(wc_Sha512 * sha, const byte * data, word32 len) Updates SHA512/224 hash with data. |
| int | wc_Sha512_224FinalRaw(wc_Sha512 * sha512, byte * hash) Gets raw SHA512/224 hash without finalizing. |
| int | wc_Sha512_224Final(wc_Sha512 * sha512, byte * hash) Finalizes SHA512/224 hash. |
| void | wc_Sha512_224Free(wc_Sha512 * sha) Frees SHA512/224 resources. |
| int | wc_Sha512_224GetHash(wc_Sha512 * sha512, byte * hash) Gets SHA512/224 hash without finalizing. |
| int | wc_Sha512_224Copy(wc_Sha512 * src, wc_Sha512 * dst) Copies SHA512/224 context. |
| int | wc_Sha512_224SetFlags(wc_Sha512 * sha512, word32 flags) Sets SHA512/224 flags. |
| int | wc_Sha512_224GetFlags(wc_Sha512 * sha512, word32 * flags) Gets SHA512/224 flags. |
| int | wc_Sha512_224Transform(wc_Sha512 * sha, const unsigned char * data) Transforms SHA512/224 block. |
| int | wc_InitSha512_256(wc_Sha512 * sha) Initializes SHA512/256. |
| int | wc_InitSha512_256_ex(wc_Sha512 * sha, void * heap, int devId) Initializes SHA512/256 with heap and device ID. |
| int | wc_Sha512_256Update(wc_Sha512 * sha, const byte * data, word32 len) Updates SHA512/256 hash with data. |
| int | wc_Sha512_256FinalRaw(wc_Sha512 * sha512, byte * hash) Gets raw SHA512/256 hash without finalizing. |
| int | wc_Sha512_256Final(wc_Sha512 * sha512, byte * hash) Finalizes SHA512/256 hash. |
| void | wc_Sha512_256Free(wc_Sha512 * sha) Frees SHA512/256 resources. |
| int | wc_Sha512_256GetHash(wc_Sha512 * sha512, byte * hash) Gets SHA512/256 hash without finalizing. |
| int | wc_Sha512_256Copy(wc_Sha512 * src, wc_Sha512 * dst) Copies SHA512/256 context. |
| int | wc_Sha512_256SetFlags(wc_Sha512 * sha512, word32 flags) Sets SHA512/256 flags. |
| int | wc_Sha512_256GetFlags(wc_Sha512 * sha512, word32 * flags) Gets SHA512/256 flags. |
| int | wc_Sha512_256Transform(wc_Sha512 * sha, const unsigned char * data) Transforms SHA512/256 block. |
| int | wc_InitSha384_ex(wc_Sha384 * sha, void * heap, int devId) Initializes SHA384 with heap and device ID. |
| int | wc_Sha384FinalRaw(wc_Sha384 * sha384, byte * hash) Gets raw SHA384 hash without finalizing. |
| void | wc_Sha384Free(wc_Sha384 * sha) Frees SHA384 resources. |
| int | wc_Sha384GetHash(wc_Sha384 * sha384, byte * hash) Gets SHA384 hash without finalizing. |
| int | wc_Sha384Copy(wc_Sha384 * src, wc_Sha384 * dst) Copies SHA384 context. |
| int | wc_Sha384_Grow(wc_Sha384 * sha384, const byte * in, int inSz) Grows SHA384 buffer with input data. |
| int | wc_Sha384SetFlags(wc_Sha384 * sha384, word32 flags) Sets SHA384 flags. |
| int | wc_Sha384GetFlags(wc_Sha384 * sha384, word32 * flags) Gets SHA384 flags. |
| int | wc_Sha384Transform(wc_Sha384 * sha, const unsigned char * data) Transforms SHA384 block. |
Functions Documentation
function wc_ShaHash
int wc_ShaHash(
const byte * data,
word32 len,
byte * hash
)
Convenience function, handles all the hashing and places the result into hash.
Parameters:
- data the data to hash
- len the length of data
- hash Byte array to hold hash value.
See:
Return:
- 0 Returned upon successfully ….
- Memory_E memory error, unable to allocate memory. This is only possible with the small stack option enabled.
Example
none
function wc_Sha224Hash
int wc_Sha224Hash(
const byte * data,
word32 len,
byte * hash
)
Convenience function, handles all the hashing and places the result into hash.
Parameters:
- data the data to hash
- len the length of data
- hash Byte array to hold hash value.
See:
Return:
- 0 Success
- <0 Error
Example
none
function wc_Sha256Hash
int wc_Sha256Hash(
const byte * data,
word32 len,
byte * hash
)
Convenience function, handles all the hashing and places the result into hash.
Parameters:
- data the data to hash
- len the length of data
- hash Byte array to hold hash value.
See:
Return:
- 0 Returned upon successfully …
- Memory_E memory error, unable to allocate memory. This is only possible with the small stack option enabled.
Example
none
function wc_Sha384Hash
int wc_Sha384Hash(
const byte * data,
word32 len,
byte * hash
)
Convenience function, handles all the hashing and places the result into hash.
Parameters:
- data the data to hash
- len the length of data
- hash Byte array to hold hash value.
See:
Return:
- 0 Returned upon successfully hashing the data
- Memory_E memory error, unable to allocate memory. This is only possible with the small stack option enabled.
Example
none
function wc_Sha512Hash
int wc_Sha512Hash(
const byte * data,
word32 len,
byte * hash
)
Convenience function, handles all the hashing and places the result into hash.
Parameters:
- data the data to hash
- len the length of data
- hash Byte array to hold hash value.
See:
Return:
- 0 Returned upon successfully hashing the inputted data
- Memory_E memory error, unable to allocate memory. This is only possible with the small stack option enabled.
Example
none
function wc_Sha3_224Hash
int wc_Sha3_224Hash(
const byte * data,
word32 len,
byte * hash
)
Convenience function, handles all the hashing and places the result into hash.
Parameters:
- data the data to hash
- len the length of data
- hash Byte array to hold hash value.
See:
Return:
- 0 Returned upon successfully hashing the data
- Memory_E memory error, unable to allocate memory. This is only possible with the small stack option enabled.
Example
none
function wc_Sha3_256Hash
int wc_Sha3_256Hash(
const byte * data,
word32 len,
byte * hash
)
Convenience function, handles all the hashing and places the result into hash.
Parameters:
- data the data to hash
- len the length of data
- hash Byte array to hold hash value.
See:
Return:
- 0 Returned upon successfully hashing the data
- Memory_E memory error, unable to allocate memory. This is only possible with the small stack option enabled.
Example
none
function wc_Sha3_384Hash
int wc_Sha3_384Hash(
const byte * data,
word32 len,
byte * hash
)
Convenience function, handles all the hashing and places the result into hash.
Parameters:
- data the data to hash
- len the length of data
- hash Byte array to hold hash value.
See:
Return:
- 0 Returned upon successfully hashing the data
- Memory_E memory error, unable to allocate memory. This is only possible with the small stack option enabled.
Example
none
function wc_Sha3_512Hash
int wc_Sha3_512Hash(
const byte * data,
word32 len,
byte * hash
)
Convenience function, handles all the hashing and places the result into hash.
Parameters:
- data the data to hash
- len the length of data
- hash Byte array to hold hash value.
See:
Return:
- 0 Returned upon successfully hashing the inputted data
- Memory_E memory error, unable to allocate memory. This is only possible with the small stack option enabled.
Example
none
function wc_Shake128Hash
int wc_Shake128Hash(
const byte * data,
word32 len,
byte * hash,
word32 hashLen
)
Convenience function, handles all the hashing and places the result into hash.
Parameters:
- data the data to hash
- len the length of data
- hash Byte array to hold hash value.
See:
Return:
- 0 Returned upon successfully hashing the inputted data
- Memory_E memory error, unable to allocate memory. This is only possible with the small stack option enabled.
Example
none
function wc_Shake256Hash
int wc_Shake256Hash(
const byte * data,
word32 len,
byte * hash,
word32 hashLen
)
Convenience function, handles all the hashing and places the result into hash.
Parameters:
- data the data to hash
- len the length of data
- hash Byte array to hold hash value.
- hashLen Number of bytes to write to hash.
See:
Return:
- 0 Returned upon successfully hashing the inputted data
- Memory_E memory error, unable to allocate memory. This is only possible with the small stack option enabled.
Example
none
function wc_InitSha
int wc_InitSha(
wc_Sha * sha
)
This function initializes SHA. This is automatically called by wc_ShaHash.
Parameters:
- sha pointer to the sha structure to use for encryption
See:
Return: 0 Returned upon successfully initializing
Example
Sha sha[1];
if ((ret = wc_InitSha(sha)) != 0) {
WOLFSSL_MSG("wc_InitSha failed");
}
else {
wc_ShaUpdate(sha, data, len);
wc_ShaFinal(sha, hash);
}
function wc_ShaUpdate
int wc_ShaUpdate(
wc_Sha * sha,
const byte * data,
word32 len
)
Can be called to continually hash the provided byte array of length len.
Parameters:
- sha pointer to the sha structure to use for encryption
- data the data to be hashed
- len length of data to be hashed
See:
Return: 0 Returned upon successfully adding the data to the digest.
Example
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);
}
function wc_ShaFinal
int wc_ShaFinal(
wc_Sha * sha,
byte * hash
)
Finalizes hashing of data. Result is placed into hash. Resets state of sha struct.
Parameters:
- sha pointer to the sha structure to use for encryption
- hash Byte array to hold hash value.
See:
Return: 0 Returned upon successfully finalizing.
Example
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);
}
function wc_ShaFree
void wc_ShaFree(
wc_Sha * sha
)
Used to clean up memory used by an initialized Sha struct.
Parameters:
- sha Pointer to the Sha struct to free.
See:
Return: No returns.
Example
Sha sha;
wc_InitSha(&sha);
// Use sha
wc_ShaFree(&sha);
function wc_ShaGetHash
int wc_ShaGetHash(
wc_Sha * sha,
byte * hash
)
Gets hash data. Result is placed into hash. Does not reset state of sha struct.
Parameters:
- sha pointer to the sha structure to use for encryption
- hash Byte array to hold hash value.
See:
Return: 0 Returned upon successfully finalizing.
Example
Sha sha[1];
if ((ret = wc_InitSha(sha)) != 0) {
WOLFSSL_MSG("wc_InitSha failed");
}
else {
wc_ShaUpdate(sha, data, len);
wc_ShaGetHash(sha, hash);
}
function wc_InitSha_ex
int wc_InitSha_ex(
wc_Sha * sha,
void * heap,
int devId
)
Initializes SHA with heap and device ID.
Parameters:
- sha SHA structure
- heap Heap hint
- devId Device ID
See: wc_InitSha
Return:
- 0 on success
- negative on error
Example
wc_Sha sha;
int ret = wc_InitSha_ex(&sha, NULL, INVALID_DEVID);
function wc_ShaFinalRaw
int wc_ShaFinalRaw(
wc_Sha * sha,
byte * hash
)
Gets raw hash without finalizing.
Parameters:
- sha SHA structure
- hash Output hash buffer
See: wc_ShaFinal
Return:
- 0 on success
- negative on error
Example
wc_Sha sha;
byte hash[WC_SHA_DIGEST_SIZE];
int ret = wc_ShaFinalRaw(&sha, hash);
function wc_ShaCopy
int wc_ShaCopy(
wc_Sha * src,
wc_Sha * dst
)
Copies SHA context.
Parameters:
- src Source SHA structure
- dst Destination SHA structure
See: wc_InitSha
Return:
- 0 on success
- negative on error
Example
wc_Sha src, dst;
int ret = wc_ShaCopy(&src, &dst);
function wc_ShaTransform
int wc_ShaTransform(
wc_Sha * sha,
const unsigned char * data
)
Transforms SHA block.
Parameters:
- sha SHA structure
- data Block data
See: wc_ShaUpdate
Return:
- 0 on success
- negative on error
Example
wc_Sha sha;
unsigned char block[WC_SHA_BLOCK_SIZE];
int ret = wc_ShaTransform(&sha, block);
function wc_ShaSizeSet
void wc_ShaSizeSet(
wc_Sha * sha,
word32 len
)
Sets SHA size.
Parameters:
- sha SHA structure
- len Size to set
See: wc_ShaUpdate
Return: none No returns
Example
wc_Sha sha;
wc_ShaSizeSet(&sha, 1000);
function wc_ShaSetFlags
int wc_ShaSetFlags(
wc_Sha * sha,
word32 flags
)
Sets SHA flags.
Parameters:
- sha SHA structure
- flags Flags to set
See: wc_InitSha
Return:
- 0 on success
- negative on error
Example
wc_Sha sha;
int ret = wc_ShaSetFlags(&sha, WC_HASH_FLAG_WILLCOPY);
function wc_InitSha256
int wc_InitSha256(
wc_Sha256 * sha
)
This function initializes SHA256. This is automatically called by wc_Sha256Hash.
Parameters:
- sha256 pointer to the sha256 structure to use for encryption
See:
Return: 0 Returned upon successfully initializing
Example
Sha256 sha256[1];
if ((ret = wc_InitSha256(sha256)) != 0) {
WOLFSSL_MSG("wc_InitSha256 failed");
}
else {
wc_Sha256Update(sha256, data, len);
wc_Sha256Final(sha256, hash);
}
function wc_Sha256Update
int wc_Sha256Update(
wc_Sha256 * sha,
const byte * data,
word32 len
)
Can be called to continually hash the provided byte array of length len.
Parameters:
- sha256 pointer to the sha256 structure to use for encryption
- data the data to be hashed
- len length of data to be hashed
See:
Return: 0 Returned upon successfully adding the data to the digest.
Example
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);
}
function wc_Sha256Final
int wc_Sha256Final(
wc_Sha256 * sha256,
byte * hash
)
Finalizes hashing of data. Result is placed into hash. Resets state of sha256 struct.
Parameters:
- sha256 pointer to the sha256 structure to use for encryption
- hash Byte array to hold hash value.
See:
Return: 0 Returned upon successfully finalizing.
Example
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);
}
function wc_Sha256Free
void wc_Sha256Free(
wc_Sha256 * sha256
)
Resets the Sha256 structure. Note: this is only supported if you have WOLFSSL_TI_HASH defined.
Parameters:
- sha256 Pointer to the sha256 structure to be freed.
See:
Return: none No returns.
Example
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);
}
function wc_Sha256GetHash
int wc_Sha256GetHash(
wc_Sha256 * sha256,
byte * hash
)
Gets hash data. Result is placed into hash. Does not reset state of sha256 struct.
Parameters:
- sha256 pointer to the sha256 structure to use for encryption
- hash Byte array to hold hash value.
See:
Return: 0 Returned upon successfully finalizing.
Example
Sha256 sha256[1];
if ((ret = wc_InitSha256(sha256)) != 0) {
WOLFSSL_MSG("wc_InitSha256 failed");
}
else {
wc_Sha256Update(sha256, data, len);
wc_Sha256GetHash(sha256, hash);
}
function wc_InitSha224
int wc_InitSha224(
wc_Sha224 * sha224
)
Used to initialize a Sha224 struct.
Parameters:
- sha224 Pointer to a Sha224 struct to initialize.
See:
Return:
- 0 Success
- 1 Error returned because sha224 is null.
Example
Sha224 sha224;
if(wc_InitSha224(&sha224) != 0)
{
// Handle error
}
function wc_Sha224Update
int wc_Sha224Update(
wc_Sha224 * sha224,
const byte * data,
word32 len
)
Can be called to continually hash the provided byte array of length len.
Parameters:
- sha224 Pointer to the Sha224 structure to use for encryption.
- data Data to be hashed.
- len Length of data to be hashed.
See:
Return:
- 0 Success
- 1 Error returned if function fails.
- BAD_FUNC_ARG Error returned if sha224 or data is null.
Example
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);
}
function wc_Sha224Final
int wc_Sha224Final(
wc_Sha224 * sha224,
byte * hash
)
Finalizes hashing of data. Result is placed into hash. Resets state of sha224 struct.
Parameters:
- sha224 pointer to the sha224 structure to use for encryption
- hash Byte array to hold hash value.
See:
Return:
- 0 Success
- <0 Error
Example
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);
}
function wc_InitSha256_ex
int wc_InitSha256_ex(
wc_Sha256 * sha,
void * heap,
int devId
)
Initializes SHA256 with heap and device ID.
Parameters:
- sha SHA256 structure
- heap Heap hint
- devId Device ID
See: wc_InitSha256
Return:
- 0 on success
- negative on error
Example
wc_Sha256 sha;
int ret = wc_InitSha256_ex(&sha, NULL, INVALID_DEVID);
function wc_Sha256FinalRaw
int wc_Sha256FinalRaw(
wc_Sha256 * sha256,
byte * hash
)
Gets raw hash without finalizing.
Parameters:
- sha256 SHA256 structure
- hash Output hash buffer
See: wc_Sha256Final
Return:
- 0 on success
- negative on error
Example
wc_Sha256 sha;
byte hash[WC_SHA256_DIGEST_SIZE];
int ret = wc_Sha256FinalRaw(&sha, hash);
function wc_Sha256Transform
int wc_Sha256Transform(
wc_Sha256 * sha,
const unsigned char * data
)
Transforms SHA256 block.
Parameters:
- sha SHA256 structure
- data Block data
See: wc_Sha256Update
Return:
- 0 on success
- negative on error
Example
wc_Sha256 sha;
unsigned char block[WC_SHA256_BLOCK_SIZE];
int ret = wc_Sha256Transform(&sha, block);
function wc_Sha256HashBlock
int wc_Sha256HashBlock(
wc_Sha256 * sha,
const unsigned char * data,
unsigned char * hash
)
Hashes single block and outputs result.
Parameters:
- sha SHA256 structure
- data Block data
- hash Output hash buffer
See: wc_Sha256Transform
Return:
- 0 on success
- negative on error
Example
wc_Sha256 sha;
unsigned char block[WC_SHA256_BLOCK_SIZE];
unsigned char hash[WC_SHA256_DIGEST_SIZE];
int ret = wc_Sha256HashBlock(&sha, block, hash);
function wc_Sha256_Grow
int wc_Sha256_Grow(
wc_Sha256 * sha256,
const byte * in,
int inSz
)
Grows SHA256 buffer with input data. This function is only available when WOLFSSL_HASH_KEEP is defined. It is used for keeping an internal buffer to hold all data to be hashed rather than iterating over update, which is necessary for some hardware acceleration platforms that have restrictions on streaming hash operations.
Parameters:
- sha256 SHA256 structure
- in Input data
- inSz Input size
See: wc_Sha256Update
Return:
- 0 on success
- negative on error
Example
wc_Sha256 sha;
byte data[100];
int ret = wc_Sha256_Grow(&sha, data, sizeof(data));
function wc_Sha256Copy
int wc_Sha256Copy(
wc_Sha256 * src,
wc_Sha256 * dst
)
Copies SHA256 context.
Parameters:
- src Source SHA256 structure
- dst Destination SHA256 structure
See: wc_InitSha256
Return:
- 0 on success
- negative on error
Example
wc_Sha256 src, dst;
int ret = wc_Sha256Copy(&src, &dst);
function wc_Sha256SizeSet
void wc_Sha256SizeSet(
wc_Sha256 * sha256,
word32 len
)
Sets SHA256 size.
Parameters:
- sha256 SHA256 structure
- len Size to set
See: wc_Sha256Update
Return: none No returns
Example
wc_Sha256 sha;
wc_Sha256SizeSet(&sha, 1000);
function wc_Sha256SetFlags
int wc_Sha256SetFlags(
wc_Sha256 * sha256,
word32 flags
)
Sets SHA256 flags.
Parameters:
- sha256 SHA256 structure
- flags Flags to set
See: wc_InitSha256
Return:
- 0 on success
- negative on error
Example
wc_Sha256 sha;
int ret = wc_Sha256SetFlags(&sha, WC_HASH_FLAG_WILLCOPY);
function wc_Sha256GetFlags
int wc_Sha256GetFlags(
wc_Sha256 * sha256,
word32 * flags
)
Gets SHA256 flags.
Parameters:
- sha256 SHA256 structure
- flags Pointer to store flags
See: wc_Sha256SetFlags
Return:
- 0 on success
- negative on error
Example
wc_Sha256 sha;
word32 flags;
int ret = wc_Sha256GetFlags(&sha, &flags);
function wc_InitSha224_ex
int wc_InitSha224_ex(
wc_Sha224 * sha224,
void * heap,
int devId
)
Initializes SHA224 with heap and device ID.
Parameters:
- sha224 SHA224 structure
- heap Heap hint
- devId Device ID
See: wc_InitSha224
Return:
- 0 on success
- negative on error
Example
wc_Sha224 sha;
int ret = wc_InitSha224_ex(&sha, NULL, INVALID_DEVID);
function wc_Sha224Free
void wc_Sha224Free(
wc_Sha224 * sha224
)
Frees SHA224 resources.
Parameters:
- sha224 SHA224 structure
See: wc_InitSha224
Return: none No returns
Example
wc_Sha224 sha;
wc_InitSha224(&sha);
wc_Sha224Free(&sha);
function wc_Sha224_Grow
int wc_Sha224_Grow(
wc_Sha224 * sha224,
const byte * in,
int inSz
)
Grows SHA224 buffer with input data. This function is only available when WOLFSSL_HASH_KEEP is defined. It is used for keeping an internal buffer to hold all data to be hashed rather than iterating over update, which is necessary for some hardware acceleration platforms that have restrictions on streaming hash operations.
Parameters:
- sha224 SHA224 structure
- in Input data
- inSz Input size
See: wc_Sha224Update
Return:
- 0 on success
- negative on error
Example
wc_Sha224 sha;
byte data[100];
int ret = wc_Sha224_Grow(&sha, data, sizeof(data));
function wc_Sha224GetHash
int wc_Sha224GetHash(
wc_Sha224 * sha224,
byte * hash
)
Gets SHA224 hash without finalizing.
Parameters:
- sha224 SHA224 structure
- hash Output hash buffer
See: wc_Sha224Final
Return:
- 0 on success
- negative on error
Example
wc_Sha224 sha;
byte hash[WC_SHA224_DIGEST_SIZE];
int ret = wc_Sha224GetHash(&sha, hash);
function wc_Sha224Copy
int wc_Sha224Copy(
wc_Sha224 * src,
wc_Sha224 * dst
)
Copies SHA224 context.
Parameters:
- src Source SHA224 structure
- dst Destination SHA224 structure
See: wc_InitSha224
Return:
- 0 on success
- negative on error
Example
wc_Sha224 src, dst;
int ret = wc_Sha224Copy(&src, &dst);
function wc_Sha224SetFlags
int wc_Sha224SetFlags(
wc_Sha224 * sha224,
word32 flags
)
Sets SHA224 flags.
Parameters:
- sha224 SHA224 structure
- flags Flags to set
See: wc_InitSha224
Return:
- 0 on success
- negative on error
Example
wc_Sha224 sha;
int ret = wc_Sha224SetFlags(&sha, WC_HASH_FLAG_WILLCOPY);
function wc_Sha224GetFlags
int wc_Sha224GetFlags(
wc_Sha224 * sha224,
word32 * flags
)
Gets SHA224 flags.
Parameters:
- sha224 SHA224 structure
- flags Pointer to store flags
See: wc_Sha224SetFlags
Return:
- 0 on success
- negative on error
Example
wc_Sha224 sha;
word32 flags;
int ret = wc_Sha224GetFlags(&sha, &flags);
function wc_InitSha3_224
int wc_InitSha3_224(
wc_Sha3 * sha3,
void * heap,
int devId
)
This function initializes SHA3-224. This is automatically called by wc_Sha3_224Hash.
Parameters:
- sha3 pointer to the sha3 structure to use for encryption
See:
Return: 0 Returned upon successfully initializing
Example
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);
}
function wc_Sha3_224_Update
int wc_Sha3_224_Update(
wc_Sha3 * sha,
const byte * data,
word32 len
)
Can be called to continually hash the provided byte array of length len.
Parameters:
- sha3 pointer to the sha3 structure to use for encryption
- data the data to be hashed
- len length of data to be hashed
See:
Return: 0 Returned upon successfully adding the data to the digest.
Example
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);
}
function wc_Sha3_224_Final
int wc_Sha3_224_Final(
wc_Sha3 * sha3,
byte * hash
)
Finalizes hashing of data. Result is placed into hash. Resets state of sha3 struct.
Parameters:
- sha3 pointer to the sha3 structure to use for encryption
- hash Byte array to hold hash value.
See:
Return: 0 Returned upon successfully finalizing.
Example
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);
}
function wc_Sha3_224_Free
void wc_Sha3_224_Free(
wc_Sha3 * sha3
)
Resets the wc_Sha3 structure. Note: this is only supported if you have WOLFSSL_TI_HASH defined.
Parameters:
- sha3 Pointer to the sha3 structure to be freed.
See:
Return: none No returns.
Example
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);
}
function wc_Sha3_224_GetHash
int wc_Sha3_224_GetHash(
wc_Sha3 * sha3,
byte * hash
)
Gets hash data. Result is placed into hash. Does not reset state of sha3 struct.
Parameters:
- sha3 pointer to the sha3 structure to use for encryption
- hash Byte array to hold hash value.
See:
Return: 0 Returned upon successful copying of the hash.
Example
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);
}
function wc_Sha3_224_Copy
int wc_Sha3_224_Copy(
wc_Sha3 * sha3,
wc_Sha3 * dst
)
Copy the state of the hash.
Parameters:
- sha3 pointer to the sha3 structure to copy
- dst pointer to the sha3 structure to copy into
See:
Return: 0 Returned upon successful copying.
Example
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);
}
function wc_InitSha3_256
int wc_InitSha3_256(
wc_Sha3 * sha3,
void * heap,
int devId
)
This function initializes SHA3-256. This is automatically called by wc_Sha3_256Hash.
Parameters:
- sha3 pointer to the sha3 structure to use for encryption
See:
Return: 0 Returned upon successfully initializing
Example
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);
}
function wc_Sha3_256_Update
int wc_Sha3_256_Update(
wc_Sha3 * sha,
const byte * data,
word32 len
)
Can be called to continually hash the provided byte array of length len.
Parameters:
- sha3 pointer to the sha3 structure to use for encryption
- data the data to be hashed
- len length of data to be hashed
See:
Return: 0 Returned upon successfully adding the data to the digest.
Example
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);
}
function wc_Sha3_256_Final
int wc_Sha3_256_Final(
wc_Sha3 * sha3,
byte * hash
)
Finalizes hashing of data. Result is placed into hash. Resets state of sha3 struct.
Parameters:
- sha3 pointer to the sha3 structure to use for encryption
- hash Byte array to hold hash value.
See:
Return: 0 Returned upon successfully finalizing.
Example
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);
}
function wc_Sha3_256_Free
void wc_Sha3_256_Free(
wc_Sha3 * sha3
)
Resets the wc_Sha3 structure. Note: this is only supported if you have WOLFSSL_TI_HASH defined.
Parameters:
- sha3 Pointer to the sha3 structure to be freed.
See:
Return: none No returns.
Example
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);
}
function wc_Sha3_256_GetHash
int wc_Sha3_256_GetHash(
wc_Sha3 * sha3,
byte * hash
)
Gets hash data. Result is placed into hash. Does not reset state of sha3 struct.
Parameters:
- sha3 pointer to the sha3 structure to use for encryption
- hash Byte array to hold hash value.
See:
Return: 0 Returned upon successful copying of the hash.
Example
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);
}
function wc_Sha3_256_Copy
int wc_Sha3_256_Copy(
wc_Sha3 * sha3,
wc_Sha3 * dst
)
Copy the state of the hash.
Parameters:
- sha3 pointer to the sha3 structure to copy
- dst pointer to the sha3 structure to copy into
See:
Return: 0 Returned upon successful copying.
Example
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);
}
function wc_InitSha3_384
int wc_InitSha3_384(
wc_Sha3 * sha3,
void * heap,
int devId
)
This function initializes SHA3-384. This is automatically called by wc_Sha3_384Hash.
Parameters:
- sha3 pointer to the sha3 structure to use for encryption
See:
Return: 0 Returned upon successfully initializing
Example
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);
}
function wc_Sha3_384_Update
int wc_Sha3_384_Update(
wc_Sha3 * sha,
const byte * data,
word32 len
)
Can be called to continually hash the provided byte array of length len.
Parameters:
- sha3 pointer to the sha3 structure to use for encryption
- data the data to be hashed
- len length of data to be hashed
See:
Return: 0 Returned upon successfully adding the data to the digest.
Example
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);
}
function wc_Sha3_384_Final
int wc_Sha3_384_Final(
wc_Sha3 * sha3,
byte * hash
)
Finalizes hashing of data. Result is placed into hash. Resets state of sha3 struct.
Parameters:
- sha3 pointer to the sha3 structure to use for encryption
- hash Byte array to hold hash value.
See:
Return: 0 Returned upon successfully finalizing.
Example
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);
}
function wc_Sha3_384_Free
void wc_Sha3_384_Free(
wc_Sha3 * sha3
)
Resets the wc_Sha3 structure. Note: this is only supported if you have WOLFSSL_TI_HASH defined.
Parameters:
- sha3 Pointer to the sha3 structure to be freed.
See:
Return: none No returns.
Example
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);
}
function wc_Sha3_384_GetHash
int wc_Sha3_384_GetHash(
wc_Sha3 * sha3,
byte * hash
)
Gets hash data. Result is placed into hash. Does not reset state of sha3 struct.
Parameters:
- sha3 pointer to the sha3 structure to use for encryption
- hash Byte array to hold hash value.
See:
Return: 0 Returned upon successful copying of the hash.
Example
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);
}
function wc_Sha3_384_Copy
int wc_Sha3_384_Copy(
wc_Sha3 * sha3,
wc_Sha3 * dst
)
Copy the state of the hash.
Parameters:
- sha3 pointer to the sha3 structure to copy
- dst pointer to the sha3 structure to copy into
See:
Return: 0 Returned upon successful copying.
Example
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);
}
function wc_InitSha3_512
int wc_InitSha3_512(
wc_Sha3 * sha3,
void * heap,
int devId
)
This function initializes SHA3-512. This is automatically called by wc_Sha3_512Hash.
Parameters:
- sha3 pointer to the sha3 structure to use for encryption
See:
Return: 0 Returned upon successfully initializing
Example
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);
}
function wc_Sha3_512_Update
int wc_Sha3_512_Update(
wc_Sha3 * sha,
const byte * data,
word32 len
)
Can be called to continually hash the provided byte array of length len.
Parameters:
- sha3 pointer to the sha3 structure to use for encryption
- data the data to be hashed
- len length of data to be hashed
See:
Return: 0 Returned upon successfully adding the data to the digest.
Example
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);
}
function wc_Sha3_512_Final
int wc_Sha3_512_Final(
wc_Sha3 * sha3,
byte * hash
)
Finalizes hashing of data. Result is placed into hash. Resets state of sha3 struct.
Parameters:
- sha3 pointer to the sha3 structure to use for encryption
- hash Byte array to hold hash value.
See:
Return: 0 Returned upon successfully finalizing.
Example
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);
}
function wc_Sha3_512_Free
void wc_Sha3_512_Free(
wc_Sha3 * sha3
)
Resets the wc_Sha3 structure. Note: this is only supported if you have WOLFSSL_TI_HASH defined.
Parameters:
- sha3 Pointer to the sha3 structure to be freed.
See:
Return: none No returns.
Example
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);
}
function wc_Sha3_512_GetHash
int wc_Sha3_512_GetHash(
wc_Sha3 * sha3,
byte * hash
)
Gets hash data. Result is placed into hash. Does not reset state of sha3 struct.
Parameters:
- sha3 pointer to the sha3 structure to use for encryption
- hash Byte array to hold hash value.
See:
Return: 0 Returned upon successful copying of the hash.
Example
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);
}
function wc_Sha3_512_Copy
int wc_Sha3_512_Copy(
wc_Sha3 * sha3,
wc_Sha3 * dst
)
Copy the state of the hash.
Parameters:
- sha3 pointer to the sha3 structure to copy
- dst pointer to the sha3 structure to copy into
See:
Return: 0 Returned upon successful copying.
Example
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);
}
function wc_InitShake128
int wc_InitShake128(
wc_Shake * shake,
void * heap,
int devId
)
This function initializes SHAKE-128. This is automatically called by wc_Shake128Hash.
Parameters:
- shake pointer to the shake structure to use for encryption
See:
Return: 0 Returned upon successfully initializing
Example
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);
}
function wc_Shake128_Update
int wc_Shake128_Update(
wc_Shake * sha,
const byte * data,
word32 len
)
Can be called to continually hash the provided byte array of length len.
Parameters:
- shake pointer to the shake structure to use for encryption
- data the data to be hashed
- len length of data to be hashed
See:
Return: 0 Returned upon successfully adding the data to the digest.
Example
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);
}
function wc_Shake128_Final
int wc_Shake128_Final(
wc_Shake * shake,
byte * hash,
word32 hashLen
)
Finalizes hashing of data. Result is placed into hash. Resets state of shake struct.
Parameters:
- shake pointer to the shake structure to use for encryption
- hash Byte array to hold hash value.
- hashLen Number of bytes to write to hash.
See:
Return: 0 Returned upon successfully finalizing.
Example
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);
}
function wc_Shake128_Absorb
int wc_Shake128_Absorb(
wc_Shake * sha,
const byte * data,
word32 len
)
Called to absorb the provided byte array of length len. Cannot be called incrementally.
Parameters:
- shake pointer to the shake structure to use for encryption
- data the data to be absorbed
- len length of data to be absorbed
See:
Return: 0 Returned upon successfully absorbed the data.
Example
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);
}
function wc_Shake128_SqueezeBlocks
int wc_Shake128_SqueezeBlocks(
wc_Shake * shake,
byte * out,
word32 blockCnt
)
Squeeze out more blocks of data. Result is placed into out. Can be called inrementally.
Parameters:
- shake pointer to the shake structure to use for encryption
- hash Byte array to hold output.
- blocks Number of blocks to squeeze out. Each block is WC_SHA3_128_BLOCK_SIZE bytes in length.
See:
Return: 0 Returned upon successfully squeezing.
Example
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);
}
function wc_Shake128_Free
void wc_Shake128_Free(
wc_Shake * shake
)
Resets the wc_Shake structure. Note: this is only supported if you have WOLFSSL_TI_HASH defined.
Parameters:
- shake Pointer to the shake structure to be freed.
See:
Return: none No returns.
Example
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);
}
function wc_Shake128_GetHash
int wc_Shake128_GetHash(
wc_Shake * shake,
byte * hash
)
Gets hash data. Result is placed into hash. Does not reset state of shake struct.
Parameters:
- shake pointer to the shake structure to use for encryption
- hash Byte array to hold hash value.
See:
Return: 0 Returned upon successful copying of the hash.
Example
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);
}
function wc_Shake128_Copy
int wc_Shake128_Copy(
wc_Shake * src,
wc_Sha3 * dst
)
Copy the state of the hash.
Parameters:
- shake pointer to the shake structure to copy
- dst pointer to the shake structure to copy into
See:
Return: 0 Returned upon successful copying.
Example
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);
}
function wc_InitShake256
int wc_InitShake256(
wc_Shake * shake,
void * heap,
int devId
)
This function initializes SHAKE-256. This is automatically called by wc_Shake256Hash.
Parameters:
- shake pointer to the shake structure to use for encryption
See:
Return: 0 Returned upon successfully initializing
Example
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));
}
function wc_Shake256_Update
int wc_Shake256_Update(
wc_Shake * sha,
const byte * data,
word32 len
)
Can be called to continually hash the provided byte array of length len.
Parameters:
- shake pointer to the shake structure to use for encryption
- data the data to be hashed
- len length of data to be hashed
See:
Return: 0 Returned upon successfully adding the data to the digest.
Example
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));
}
function wc_Shake256_Final
int wc_Shake256_Final(
wc_Shake * shake,
byte * hash,
word32 hashLen
)
Finalizes hashing of data. Result is placed into hash. Resets state of shake struct.
Parameters:
- shake pointer to the shake structure to use for encryption
- hash Byte array to hold hash value.
- hashLen Size of hash in bytes.
See:
Return: 0 Returned upon successfully finalizing.
Example
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));
}
function wc_Shake256_Absorb
int wc_Shake256_Absorb(
wc_Shake * sha,
const byte * data,
word32 len
)
Called to absorb the provided byte array of length len. Cannot be called incrementally.
Parameters:
- shake pointer to the shake structure to use for encryption
- data the data to be absorbed
- len length of data to be absorbed
See:
Return: 0 Returned upon successfully absorbed the data.
Example
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);
}
function wc_Shake256_SqueezeBlocks
int wc_Shake256_SqueezeBlocks(
wc_Shake * shake,
byte * out,
word32 blockCnt
)
Squeeze out more blocks of data. Result is placed into out. Can be called incrementally.
Parameters:
- shake pointer to the shake structure to use for encryption
- hash Byte array to hold output.
- blocks Number of blocks to squeeze out. Each block is WC_SHA3_256_BLOCK_SIZE bytes in length.
See:
Return: 0 Returned upon successfully squeezing.
Example
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);
}
function wc_Shake256_Free
void wc_Shake256_Free(
wc_Shake * shake
)
Resets the wc_Shake structure. Note: this is only supported if you have WOLFSSL_TI_HASH defined.
Parameters:
- shake Pointer to the shake structure to be freed.
See:
Return: none No returns.
Example
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);
}
function wc_Shake256_GetHash
int wc_Shake256_GetHash(
wc_Shake * shake,
byte * hash
)
Gets hash data. Result is placed into hash. Does not reset state of shake struct.
Parameters:
- shake pointer to the shake structure to use for encryption
- hash Byte array to hold hash value.
See:
Return: 0 Returned upon successful copying of the hash.
Example
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);
}
function wc_Shake256_Copy
int wc_Shake256_Copy(
wc_Shake * src,
wc_Sha3 * dst
)
Copy the state of the hash.
Parameters:
- shake pointer to the shake structure to copy
- dst pointer to the shake structure to copy into
See:
Return: 0 Returned upon successful copying.
Example
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);
}
function wc_InitSha512
int wc_InitSha512(
wc_Sha512 * sha
)
This function initializes SHA512. This is automatically called by wc_Sha512Hash.
Parameters:
- sha512 pointer to the sha512 structure to use for encryption
See:
Return: 0 Returned upon successfully initializing
Example
Sha512 sha512[1];
if ((ret = wc_InitSha512(sha512)) != 0) {
WOLFSSL_MSG("wc_InitSha512 failed");
}
else {
wc_Sha512Update(sha512, data, len);
wc_Sha512Final(sha512, hash);
}
function wc_Sha512Update
int wc_Sha512Update(
wc_Sha512 * sha,
const byte * data,
word32 len
)
Can be called to continually hash the provided byte array of length len.
Parameters:
- sha512 pointer to the sha512 structure to use for encryption
- data the data to be hashed
- len length of data to be hashed
See:
Return: 0 Returned upon successfully adding the data to the digest.
Example
Sha512 sha512[1];
byte data[] = { Data to be hashed };
word32 len = sizeof(data);
if ((ret = wc_InitSha512(sha512)) != 0) {
WOLFSSL_MSG("wc_InitSha512 failed");
}
else {
wc_Sha512Update(sha512, data, len);
wc_Sha512Final(sha512, hash);
}
function wc_Sha512Final
int wc_Sha512Final(
wc_Sha512 * sha512,
byte * hash
)
Finalizes hashing of data. Result is placed into hash.
Parameters:
- sha512 pointer to the sha512 structure to use for encryption
- hash Byte array to hold hash value.
See:
Return: 0 Returned upon successfully finalizing the hash.
Example
Sha512 sha512[1];
byte data[] = { Data to be hashed };
word32 len = sizeof(data);
if ((ret = wc_InitSha512(sha512)) != 0) {
WOLFSSL_MSG("wc_InitSha512 failed");
}
else {
wc_Sha512Update(sha512, data, len);
wc_Sha512Final(sha512, hash);
}
function wc_InitSha384
int wc_InitSha384(
wc_Sha384 * sha
)
This function initializes SHA384. This is automatically called by wc_Sha384Hash.
Parameters:
- sha384 pointer to the sha384 structure to use for encryption
See:
Return: 0 Returned upon successfully initializing
Example
Sha384 sha384[1];
if ((ret = wc_InitSha384(sha384)) != 0) {
WOLFSSL_MSG("wc_InitSha384 failed");
}
else {
wc_Sha384Update(sha384, data, len);
wc_Sha384Final(sha384, hash);
}
function wc_Sha384Update
int wc_Sha384Update(
wc_Sha384 * sha,
const byte * data,
word32 len
)
Can be called to continually hash the provided byte array of length len.
Parameters:
- sha384 pointer to the sha384 structure to use for encryption
- data the data to be hashed
- len length of data to be hashed
See:
Return: 0 Returned upon successfully adding the data to the digest.
Example
Sha384 sha384[1];
byte data[] = { Data to be hashed };
word32 len = sizeof(data);
if ((ret = wc_InitSha384(sha384)) != 0) {
WOLFSSL_MSG("wc_InitSha384 failed");
}
else {
wc_Sha384Update(sha384, data, len);
wc_Sha384Final(sha384, hash);
}
function wc_Sha384Final
int wc_Sha384Final(
wc_Sha384 * sha384,
byte * hash
)
Finalizes hashing of data. Result is placed into hash.
Parameters:
- sha384 pointer to the sha384 structure to use for encryption
- hash Byte array to hold hash value.
See:
Return: 0 Returned upon successfully finalizing.
Example
Sha384 sha384[1];
byte data[] = { Data to be hashed };
word32 len = sizeof(data);
if ((ret = wc_InitSha384(sha384)) != 0) {
WOLFSSL_MSG("wc_InitSha384 failed");
}
else {
wc_Sha384Update(sha384, data, len);
wc_Sha384Final(sha384, hash);
}
function wc_InitSha512_ex
int wc_InitSha512_ex(
wc_Sha512 * sha,
void * heap,
int devId
)
Initializes SHA512 with heap and device ID.
Parameters:
- sha SHA512 structure
- heap Heap hint
- devId Device ID
See: wc_InitSha512
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
int ret = wc_InitSha512_ex(&sha, NULL, INVALID_DEVID);
function wc_Sha512FinalRaw
int wc_Sha512FinalRaw(
wc_Sha512 * sha512,
byte * hash
)
Gets raw hash without finalizing.
Parameters:
- sha512 SHA512 structure
- hash Output hash buffer
See: wc_Sha512Final
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
byte hash[WC_SHA512_DIGEST_SIZE];
int ret = wc_Sha512FinalRaw(&sha, hash);
function wc_Sha512Free
void wc_Sha512Free(
wc_Sha512 * sha
)
Frees SHA512 resources.
Parameters:
- sha SHA512 structure
See: wc_InitSha512
Return: none No returns
Example
wc_Sha512 sha;
wc_InitSha512(&sha);
wc_Sha512Free(&sha);
function wc_Sha512GetHash
int wc_Sha512GetHash(
wc_Sha512 * sha512,
byte * hash
)
Gets SHA512 hash without finalizing.
Parameters:
- sha512 SHA512 structure
- hash Output hash buffer
See: wc_Sha512Final
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
byte hash[WC_SHA512_DIGEST_SIZE];
int ret = wc_Sha512GetHash(&sha, hash);
function wc_Sha512Copy
int wc_Sha512Copy(
wc_Sha512 * src,
wc_Sha512 * dst
)
Copies SHA512 context.
Parameters:
- src Source SHA512 structure
- dst Destination SHA512 structure
See: wc_InitSha512
Return:
- 0 on success
- negative on error
Example
wc_Sha512 src, dst;
int ret = wc_Sha512Copy(&src, &dst);
function wc_Sha512_Grow
int wc_Sha512_Grow(
wc_Sha512 * sha512,
const byte * in,
int inSz
)
Grows SHA512 buffer with input data.
Parameters:
- sha512 SHA512 structure
- in Input data
- inSz Input size
See: wc_Sha512Update
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
byte data[100];
int ret = wc_Sha512_Grow(&sha, data, sizeof(data));
function wc_Sha512SetFlags
int wc_Sha512SetFlags(
wc_Sha512 * sha512,
word32 flags
)
Sets SHA512 flags.
Parameters:
- sha512 SHA512 structure
- flags Flags to set
See: wc_InitSha512
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
int ret = wc_Sha512SetFlags(&sha, WC_HASH_FLAG_WILLCOPY);
function wc_Sha512GetFlags
int wc_Sha512GetFlags(
wc_Sha512 * sha512,
word32 * flags
)
Gets SHA512 flags.
Parameters:
- sha512 SHA512 structure
- flags Pointer to store flags
See: wc_Sha512SetFlags
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
word32 flags;
int ret = wc_Sha512GetFlags(&sha, &flags);
function wc_Sha512Transform
int wc_Sha512Transform(
wc_Sha512 * sha,
const unsigned char * data
)
Transforms SHA512 block.
Parameters:
- sha SHA512 structure
- data Block data
See: wc_Sha512Update
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
unsigned char block[WC_SHA512_BLOCK_SIZE];
int ret = wc_Sha512Transform(&sha, block);
function wc_InitSha512_224
int wc_InitSha512_224(
wc_Sha512 * sha
)
Initializes SHA512/224.
Parameters:
- sha SHA512 structure
See: wc_Sha512_224Update
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
int ret = wc_InitSha512_224(&sha);
function wc_InitSha512_224_ex
int wc_InitSha512_224_ex(
wc_Sha512 * sha,
void * heap,
int devId
)
Initializes SHA512/224 with heap and device ID.
Parameters:
- sha SHA512 structure
- heap Heap hint
- devId Device ID
See: wc_InitSha512_224
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
int ret = wc_InitSha512_224_ex(&sha, NULL, INVALID_DEVID);
function wc_Sha512_224Update
int wc_Sha512_224Update(
wc_Sha512 * sha,
const byte * data,
word32 len
)
Updates SHA512/224 hash with data.
Parameters:
- sha SHA512 structure
- data Input data
- len Input size
See: wc_InitSha512_224
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
byte data[100];
int ret = wc_Sha512_224Update(&sha, data, sizeof(data));
function wc_Sha512_224FinalRaw
int wc_Sha512_224FinalRaw(
wc_Sha512 * sha512,
byte * hash
)
Gets raw SHA512/224 hash without finalizing.
Parameters:
- sha512 SHA512 structure
- hash Output hash buffer
See: wc_Sha512_224Final
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
byte hash[WC_SHA512_224_DIGEST_SIZE];
int ret = wc_Sha512_224FinalRaw(&sha, hash);
function wc_Sha512_224Final
int wc_Sha512_224Final(
wc_Sha512 * sha512,
byte * hash
)
Finalizes SHA512/224 hash.
Parameters:
- sha512 SHA512 structure
- hash Output hash buffer
See: wc_Sha512_224Update
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
byte hash[WC_SHA512_224_DIGEST_SIZE];
int ret = wc_Sha512_224Final(&sha, hash);
function wc_Sha512_224Free
void wc_Sha512_224Free(
wc_Sha512 * sha
)
Frees SHA512/224 resources.
Parameters:
- sha SHA512 structure
See: wc_InitSha512_224
Return: none No returns
Example
wc_Sha512 sha;
wc_InitSha512_224(&sha);
wc_Sha512_224Free(&sha);
function wc_Sha512_224GetHash
int wc_Sha512_224GetHash(
wc_Sha512 * sha512,
byte * hash
)
Gets SHA512/224 hash without finalizing.
Parameters:
- sha512 SHA512 structure
- hash Output hash buffer
See: wc_Sha512_224Final
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
byte hash[WC_SHA512_224_DIGEST_SIZE];
int ret = wc_Sha512_224GetHash(&sha, hash);
function wc_Sha512_224Copy
int wc_Sha512_224Copy(
wc_Sha512 * src,
wc_Sha512 * dst
)
Copies SHA512/224 context.
Parameters:
- src Source SHA512 structure
- dst Destination SHA512 structure
See: wc_InitSha512_224
Return:
- 0 on success
- negative on error
Example
wc_Sha512 src, dst;
int ret = wc_Sha512_224Copy(&src, &dst);
function wc_Sha512_224SetFlags
int wc_Sha512_224SetFlags(
wc_Sha512 * sha512,
word32 flags
)
Sets SHA512/224 flags.
Parameters:
- sha512 SHA512 structure
- flags Flags to set
See: wc_InitSha512_224
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
int ret = wc_Sha512_224SetFlags(&sha, WC_HASH_FLAG_WILLCOPY);
function wc_Sha512_224GetFlags
int wc_Sha512_224GetFlags(
wc_Sha512 * sha512,
word32 * flags
)
Gets SHA512/224 flags.
Parameters:
- sha512 SHA512 structure
- flags Pointer to store flags
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
word32 flags;
int ret = wc_Sha512_224GetFlags(&sha, &flags);
function wc_Sha512_224Transform
int wc_Sha512_224Transform(
wc_Sha512 * sha,
const unsigned char * data
)
Transforms SHA512/224 block.
Parameters:
- sha SHA512 structure
- data Block data
See: wc_Sha512_224Update
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
unsigned char block[WC_SHA512_BLOCK_SIZE];
int ret = wc_Sha512_224Transform(&sha, block);
function wc_InitSha512_256
int wc_InitSha512_256(
wc_Sha512 * sha
)
Initializes SHA512/256.
Parameters:
- sha SHA512 structure
See: wc_Sha512_256Update
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
int ret = wc_InitSha512_256(&sha);
function wc_InitSha512_256_ex
int wc_InitSha512_256_ex(
wc_Sha512 * sha,
void * heap,
int devId
)
Initializes SHA512/256 with heap and device ID.
Parameters:
- sha SHA512 structure
- heap Heap hint
- devId Device ID
See: wc_InitSha512_256
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
int ret = wc_InitSha512_256_ex(&sha, NULL, INVALID_DEVID);
function wc_Sha512_256Update
int wc_Sha512_256Update(
wc_Sha512 * sha,
const byte * data,
word32 len
)
Updates SHA512/256 hash with data.
Parameters:
- sha SHA512 structure
- data Input data
- len Input size
See: wc_InitSha512_256
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
byte data[100];
int ret = wc_Sha512_256Update(&sha, data, sizeof(data));
function wc_Sha512_256FinalRaw
int wc_Sha512_256FinalRaw(
wc_Sha512 * sha512,
byte * hash
)
Gets raw SHA512/256 hash without finalizing.
Parameters:
- sha512 SHA512 structure
- hash Output hash buffer
See: wc_Sha512_256Final
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
byte hash[WC_SHA512_256_DIGEST_SIZE];
int ret = wc_Sha512_256FinalRaw(&sha, hash);
function wc_Sha512_256Final
int wc_Sha512_256Final(
wc_Sha512 * sha512,
byte * hash
)
Finalizes SHA512/256 hash.
Parameters:
- sha512 SHA512 structure
- hash Output hash buffer
See: wc_Sha512_256Update
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
byte hash[WC_SHA512_256_DIGEST_SIZE];
int ret = wc_Sha512_256Final(&sha, hash);
function wc_Sha512_256Free
void wc_Sha512_256Free(
wc_Sha512 * sha
)
Frees SHA512/256 resources.
Parameters:
- sha SHA512 structure
See: wc_InitSha512_256
Return: none No returns
Example
wc_Sha512 sha;
wc_InitSha512_256(&sha);
wc_Sha512_256Free(&sha);
function wc_Sha512_256GetHash
int wc_Sha512_256GetHash(
wc_Sha512 * sha512,
byte * hash
)
Gets SHA512/256 hash without finalizing.
Parameters:
- sha512 SHA512 structure
- hash Output hash buffer
See: wc_Sha512_256Final
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
byte hash[WC_SHA512_256_DIGEST_SIZE];
int ret = wc_Sha512_256GetHash(&sha, hash);
function wc_Sha512_256Copy
int wc_Sha512_256Copy(
wc_Sha512 * src,
wc_Sha512 * dst
)
Copies SHA512/256 context.
Parameters:
- src Source SHA512 structure
- dst Destination SHA512 structure
See: wc_InitSha512_256
Return:
- 0 on success
- negative on error
Example
wc_Sha512 src, dst;
int ret = wc_Sha512_256Copy(&src, &dst);
function wc_Sha512_256SetFlags
int wc_Sha512_256SetFlags(
wc_Sha512 * sha512,
word32 flags
)
Sets SHA512/256 flags.
Parameters:
- sha512 SHA512 structure
- flags Flags to set
See: wc_InitSha512_256
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
int ret = wc_Sha512_256SetFlags(&sha, WC_HASH_FLAG_WILLCOPY);
function wc_Sha512_256GetFlags
int wc_Sha512_256GetFlags(
wc_Sha512 * sha512,
word32 * flags
)
Gets SHA512/256 flags.
Parameters:
- sha512 SHA512 structure
- flags Pointer to store flags
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
word32 flags;
int ret = wc_Sha512_256GetFlags(&sha, &flags);
function wc_Sha512_256Transform
int wc_Sha512_256Transform(
wc_Sha512 * sha,
const unsigned char * data
)
Transforms SHA512/256 block.
Parameters:
- sha SHA512 structure
- data Block data
See: wc_Sha512_256Update
Return:
- 0 on success
- negative on error
Example
wc_Sha512 sha;
unsigned char block[WC_SHA512_BLOCK_SIZE];
int ret = wc_Sha512_256Transform(&sha, block);
function wc_InitSha384_ex
int wc_InitSha384_ex(
wc_Sha384 * sha,
void * heap,
int devId
)
Initializes SHA384 with heap and device ID.
Parameters:
- sha SHA384 structure
- heap Heap hint
- devId Device ID
See: wc_InitSha384
Return:
- 0 on success
- negative on error
Example
wc_Sha384 sha;
int ret = wc_InitSha384_ex(&sha, NULL, INVALID_DEVID);
function wc_Sha384FinalRaw
int wc_Sha384FinalRaw(
wc_Sha384 * sha384,
byte * hash
)
Gets raw SHA384 hash without finalizing.
Parameters:
- sha384 SHA384 structure
- hash Output hash buffer
See: wc_Sha384Final
Return:
- 0 on success
- negative on error
Example
wc_Sha384 sha;
byte hash[WC_SHA384_DIGEST_SIZE];
int ret = wc_Sha384FinalRaw(&sha, hash);
function wc_Sha384Free
void wc_Sha384Free(
wc_Sha384 * sha
)
Frees SHA384 resources.
Parameters:
- sha SHA384 structure
See: wc_InitSha384
Return: none No returns
Example
wc_Sha384 sha;
wc_InitSha384(&sha);
wc_Sha384Free(&sha);
function wc_Sha384GetHash
int wc_Sha384GetHash(
wc_Sha384 * sha384,
byte * hash
)
Gets SHA384 hash without finalizing.
Parameters:
- sha384 SHA384 structure
- hash Output hash buffer
See: wc_Sha384Final
Return:
- 0 on success
- negative on error
Example
wc_Sha384 sha;
byte hash[WC_SHA384_DIGEST_SIZE];
int ret = wc_Sha384GetHash(&sha, hash);
function wc_Sha384Copy
int wc_Sha384Copy(
wc_Sha384 * src,
wc_Sha384 * dst
)
Copies SHA384 context.
Parameters:
- src Source SHA384 structure
- dst Destination SHA384 structure
See: wc_InitSha384
Return:
- 0 on success
- negative on error
Example
wc_Sha384 src, dst;
int ret = wc_Sha384Copy(&src, &dst);
function wc_Sha384_Grow
int wc_Sha384_Grow(
wc_Sha384 * sha384,
const byte * in,
int inSz
)
Grows SHA384 buffer with input data.
Parameters:
- sha384 SHA384 structure
- in Input data
- inSz Input size
See: wc_Sha384Update
Return:
- 0 on success
- negative on error
Example
wc_Sha384 sha;
byte data[100];
int ret = wc_Sha384_Grow(&sha, data, sizeof(data));
function wc_Sha384SetFlags
int wc_Sha384SetFlags(
wc_Sha384 * sha384,
word32 flags
)
Sets SHA384 flags.
Parameters:
- sha384 SHA384 structure
- flags Flags to set
See: wc_InitSha384
Return:
- 0 on success
- negative on error
Example
wc_Sha384 sha;
int ret = wc_Sha384SetFlags(&sha, WC_HASH_FLAG_WILLCOPY);
function wc_Sha384GetFlags
int wc_Sha384GetFlags(
wc_Sha384 * sha384,
word32 * flags
)
Gets SHA384 flags.
Parameters:
- sha384 SHA384 structure
- flags Pointer to store flags
See: wc_Sha384SetFlags
Return:
- 0 on success
- negative on error
Example
wc_Sha384 sha;
word32 flags;
int ret = wc_Sha384GetFlags(&sha, &flags);
function wc_Sha384Transform
int wc_Sha384Transform(
wc_Sha384 * sha,
const unsigned char * data
)
Transforms SHA384 block.
Parameters:
- sha SHA384 structure
- data Block data
See: wc_Sha384Update
Return:
- 0 on success
- negative on error
Example
wc_Sha384 sha;
unsigned char block[WC_SHA384_BLOCK_SIZE];
int ret = wc_Sha384Transform(&sha, block);
Updated on 2026-01-08 at 01:20:24 +0000