sha3.h
Functions
| Name | |
|---|---|
| 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_InitKmac128(wc_Kmac * kmac, const byte * key, word32 keyLen, const byte * custom, word32 customLen, void * heap, int devId) This function initializes a KMAC128 operation with a key and an optional customization string, per NIST SP 800_185. KMAC128 requires SHAKE128 (WOLFSSL_SHAKE128) and is enabled with WOLFSSL_KMAC. |
| int | wc_Kmac128_Update(wc_Kmac * kmac, const byte * in, word32 inLen) This function absorbs message data into a KMAC128 operation. It may be called any number of times before finalizing. |
| int | wc_Kmac128_Final(wc_Kmac * kmac, byte * out, word32 outLen) This function finalizes a KMAC128 operation, producing outLen bytes of output. The output length is bound into the result, so a KMAC with a different length is a different value. |
| int | wc_Kmac128_FinalXof(wc_Kmac * kmac, byte * out, word32 outLen) This function finalizes a KMAC128 operation as an XOF (KMACXOF128). Unlike wc_Kmac128_Final, the output length is not bound into the result, so any amount of output may be requested. |
| void | wc_Kmac128_Free(wc_Kmac * kmac) This function releases any resources associated with a KMAC128 operation. Passing NULL is safe and does nothing. |
| int | wc_Kmac128Hash(const byte * key, word32 keyLen, const byte * custom, word32 customLen, const byte * in, word32 inLen, byte * out, word32 outLen) This function computes a KMAC128 over a single message in one call, initializing, updating and finalizing internally. |
| int | wc_Kmac128HashXof(const byte * key, word32 keyLen, const byte * custom, word32 customLen, const byte * in, word32 inLen, byte * out, word32 outLen) This function computes a KMACXOF128 over a single message in one call. Like wc_Kmac128Hash but the output length is not bound into the result, so any amount of output may be requested. |
| int | wc_InitKmac256(wc_Kmac * kmac, const byte * key, word32 keyLen, const byte * custom, word32 customLen, void * heap, int devId) This function initializes a KMAC256 operation with a key and an optional customization string, per NIST SP 800_185. KMAC256 requires SHAKE256 (WOLFSSL_SHAKE256) and is enabled with WOLFSSL_KMAC. |
| int | wc_Kmac256_Update(wc_Kmac * kmac, const byte * in, word32 inLen) This function absorbs message data into a KMAC256 operation. It may be called any number of times before finalizing. |
| int | wc_Kmac256_Final(wc_Kmac * kmac, byte * out, word32 outLen) This function finalizes a KMAC256 operation, producing outLen bytes of output. The output length is bound into the result, so a KMAC with a different length is a different value. |
| int | wc_Kmac256_FinalXof(wc_Kmac * kmac, byte * out, word32 outLen) This function finalizes a KMAC256 operation as an XOF (KMACXOF256). Unlike wc_Kmac256_Final, the output length is not bound into the result, so any amount of output may be requested. |
| void | wc_Kmac256_Free(wc_Kmac * kmac) This function releases any resources associated with a KMAC256 operation. Passing NULL is safe and does nothing. |
| int | wc_Kmac256Hash(const byte * key, word32 keyLen, const byte * custom, word32 customLen, const byte * in, word32 inLen, byte * out, word32 outLen) This function computes a KMAC256 over a single message in one call, initializing, updating and finalizing internally. |
| int | wc_Kmac256HashXof(const byte * key, word32 keyLen, const byte * custom, word32 customLen, const byte * in, word32 inLen, byte * out, word32 outLen) This function computes a KMACXOF256 over a single message in one call. Like wc_Kmac256Hash but the output length is not bound into the result, so any amount of output may be requested. |
| int | wc_Kmac128_Copy(wc_Kmac * src, wc_Kmac * dst) This function copies the state of a KMAC128 operation so it can be finalized more than once, for example over a common message prefix. |
| int | wc_Kmac256_Copy(wc_Kmac * src, wc_Kmac * dst) This function copies the state of a KMAC256 operation so it can be finalized more than once, for example over a common message prefix. |
| int | wc_InitCshake128(wc_Cshake * cshake, const byte * name, word32 nameLen, const byte * custom, word32 customLen, void * heap, int devId) This function initializes a cSHAKE128 operation (customizable SHAKE, NIST SP 800_185) with a function_name and customization string. cSHAKE is enabled together with KMAC (WOLFSSL_KMAC). When both strings are empty, cSHAKE reduces to plain SHAKE128. |
| int | wc_Cshake128_Update(wc_Cshake * cshake, const byte * in, word32 inLen) This function absorbs message data into a cSHAKE128 operation. |
| int | wc_Cshake128_Final(wc_Cshake * cshake, byte * out, word32 outLen) This function finalizes a cSHAKE128 operation, squeezing outLen bytes of output. cSHAKE is an XOF, so a longer squeeze extends a shorter one over the same input. |
| void | wc_Cshake128_Free(wc_Cshake * cshake) This function releases any resources associated with a cSHAKE128 operation. Passing NULL is safe and does nothing. |
| int | wc_Cshake128(const byte * name, word32 nameLen, const byte * custom, word32 customLen, const byte * in, word32 inLen, byte * out, word32 outLen) This function computes a cSHAKE128 over a single message in one call, initializing, updating and finalizing internally. |
| int | wc_InitCshake256(wc_Cshake * cshake, const byte * name, word32 nameLen, const byte * custom, word32 customLen, void * heap, int devId) This function initializes a cSHAKE256 operation (customizable SHAKE, NIST SP 800_185) with a function_name and customization string. cSHAKE is enabled together with KMAC (WOLFSSL_KMAC). When both strings are empty, cSHAKE reduces to plain SHAKE256. |
| int | wc_Cshake256_Update(wc_Cshake * cshake, const byte * in, word32 inLen) This function absorbs message data into a cSHAKE256 operation. |
| int | wc_Cshake256_Final(wc_Cshake * cshake, byte * out, word32 outLen) This function finalizes a cSHAKE256 operation, squeezing outLen bytes of output. cSHAKE is an XOF, so a longer squeeze extends a shorter one over the same input. |
| void | wc_Cshake256_Free(wc_Cshake * cshake) This function releases any resources associated with a cSHAKE256 operation. Passing NULL is safe and does nothing. |
| int | wc_Cshake256(const byte * name, word32 nameLen, const byte * custom, word32 customLen, const byte * in, word32 inLen, byte * out, word32 outLen) This function computes a cSHAKE256 over a single message in one call, initializing, updating and finalizing internally. |
| int | wc_Cshake128_Copy(wc_Cshake * src, wc_Cshake * dst) This function copies the state of a cSHAKE128 operation so it can be finalized more than once, for example over a common message prefix. dst must already be an initialized wc_Cshake. |
| int | wc_Cshake256_Copy(wc_Cshake * src, wc_Cshake * dst) This function copies the state of a cSHAKE256 operation so it can be finalized more than once, for example over a common message prefix. dst must already be an initialized wc_Cshake. |
Functions Documentation
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_InitKmac128
int wc_InitKmac128(
wc_Kmac * kmac,
const byte * key,
word32 keyLen,
const byte * custom,
word32 customLen,
void * heap,
int devId
)
This function initializes a KMAC128 operation with a key and an optional customization string, per NIST SP 800-185. KMAC128 requires SHAKE128 (WOLFSSL_SHAKE128) and is enabled with WOLFSSL_KMAC.
Parameters:
- kmac pointer to the wc_Kmac structure to initialize.
- key the key bytes.
- keyLen length of the key in bytes.
- custom customization string, or NULL when customLen is 0.
- customLen length of the customization string in bytes.
- heap pointer to a heap hint, may be NULL.
- devId device identifier, or INVALID_DEVID.
See:
Return:
- 0 Returned upon successfully initializing.
- BAD_FUNC_ARG Returned when kmac is NULL, or key/custom is NULL with a non-zero length.
Example
wc_Kmac kmac;
byte key[32];
byte data[] = { Data to authenticate };
byte out[32];
if (wc_InitKmac128(&kmac, key, sizeof(key), NULL, 0, NULL,
INVALID_DEVID) == 0) {
wc_Kmac128_Update(&kmac, data, sizeof(data));
wc_Kmac128_Final(&kmac, out, sizeof(out));
wc_Kmac128_Free(&kmac);
}
function wc_Kmac128_Update
int wc_Kmac128_Update(
wc_Kmac * kmac,
const byte * in,
word32 inLen
)
This function absorbs message data into a KMAC128 operation. It may be called any number of times before finalizing.
Parameters:
- kmac pointer to the wc_Kmac structure holding state.
- in the message data to authenticate.
- inLen length of the message data in bytes.
See:
Return:
- 0 Returned upon successfully adding the data.
- BAD_FUNC_ARG Returned when kmac is NULL, or in is NULL with a non-zero length.
Example
wc_Kmac kmac;
byte data[] = { Data to authenticate };
if (wc_InitKmac128(&kmac, key, keyLen, NULL, 0, NULL,
INVALID_DEVID) == 0) {
wc_Kmac128_Update(&kmac, data, sizeof(data));
wc_Kmac128_Final(&kmac, out, sizeof(out));
wc_Kmac128_Free(&kmac);
}
function wc_Kmac128_Final
int wc_Kmac128_Final(
wc_Kmac * kmac,
byte * out,
word32 outLen
)
This function finalizes a KMAC128 operation, producing outLen bytes of output. The output length is bound into the result, so a KMAC with a different length is a different value.
Parameters:
- kmac pointer to the wc_Kmac structure holding state.
- out buffer to hold the output.
- outLen number of output bytes to produce.
See:
Return:
- 0 Returned upon successfully finalizing.
- BAD_FUNC_ARG Returned when kmac is NULL, or out is NULL with a non-zero length.
Example
byte out[32];
wc_Kmac128_Final(&kmac, out, sizeof(out));
function wc_Kmac128_FinalXof
int wc_Kmac128_FinalXof(
wc_Kmac * kmac,
byte * out,
word32 outLen
)
This function finalizes a KMAC128 operation as an XOF (KMACXOF128). Unlike wc_Kmac128_Final, the output length is not bound into the result, so any amount of output may be requested.
Parameters:
- kmac pointer to the wc_Kmac structure holding state.
- out buffer to hold the output.
- outLen number of output bytes to produce.
See:
Return:
- 0 Returned upon successfully finalizing.
- BAD_FUNC_ARG Returned when kmac is NULL, or out is NULL with a non-zero length.
Example
byte out[64];
wc_Kmac128_FinalXof(&kmac, out, sizeof(out));
function wc_Kmac128_Free
void wc_Kmac128_Free(
wc_Kmac * kmac
)
This function releases any resources associated with a KMAC128 operation. Passing NULL is safe and does nothing.
Parameters:
- kmac pointer to the wc_Kmac structure to free, may be NULL.
See: wc_InitKmac128
Example
wc_Kmac128_Free(&kmac);
function wc_Kmac128Hash
int wc_Kmac128Hash(
const byte * key,
word32 keyLen,
const byte * custom,
word32 customLen,
const byte * in,
word32 inLen,
byte * out,
word32 outLen
)
This function computes a KMAC128 over a single message in one call, initializing, updating and finalizing internally.
Parameters:
- key the key bytes.
- keyLen length of the key in bytes.
- custom customization string, or NULL when customLen is 0.
- customLen length of the customization string in bytes.
- in the message data to authenticate.
- inLen length of the message data in bytes.
- out buffer to hold the output.
- outLen number of output bytes to produce.
See:
Return:
- 0 Returned upon success.
- BAD_FUNC_ARG Returned when a required pointer is NULL with a non-zero length.
Example
byte key[32];
byte data[] = { Data to authenticate };
byte out[32];
wc_Kmac128Hash(key, sizeof(key), NULL, 0, data, sizeof(data),
out, sizeof(out));
function wc_Kmac128HashXof
int wc_Kmac128HashXof(
const byte * key,
word32 keyLen,
const byte * custom,
word32 customLen,
const byte * in,
word32 inLen,
byte * out,
word32 outLen
)
This function computes a KMACXOF128 over a single message in one call. Like wc_Kmac128Hash but the output length is not bound into the result, so any amount of output may be requested.
Parameters:
- key the key bytes.
- keyLen length of the key in bytes.
- custom customization string, or NULL when customLen is 0.
- customLen length of the customization string in bytes.
- in the message data to authenticate.
- inLen length of the message data in bytes.
- out buffer to hold the output.
- outLen number of output bytes to produce.
See:
Return:
- 0 Returned upon success.
- BAD_FUNC_ARG Returned when a required pointer is NULL with a non-zero length.
Example
byte key[32];
byte data[] = { Data to authenticate };
byte out[64];
wc_Kmac128HashXof(key, sizeof(key), NULL, 0, data, sizeof(data),
out, sizeof(out));
function wc_InitKmac256
int wc_InitKmac256(
wc_Kmac * kmac,
const byte * key,
word32 keyLen,
const byte * custom,
word32 customLen,
void * heap,
int devId
)
This function initializes a KMAC256 operation with a key and an optional customization string, per NIST SP 800-185. KMAC256 requires SHAKE256 (WOLFSSL_SHAKE256) and is enabled with WOLFSSL_KMAC.
Parameters:
- kmac pointer to the wc_Kmac structure to initialize.
- key the key bytes.
- keyLen length of the key in bytes.
- custom customization string, or NULL when customLen is 0.
- customLen length of the customization string in bytes.
- heap pointer to a heap hint, may be NULL.
- devId device identifier, or INVALID_DEVID.
See:
Return:
- 0 Returned upon successfully initializing.
- BAD_FUNC_ARG Returned when kmac is NULL, or key/custom is NULL with a non-zero length.
Example
wc_Kmac kmac;
byte key[32];
byte data[] = { Data to authenticate };
byte out[64];
if (wc_InitKmac256(&kmac, key, sizeof(key), NULL, 0, NULL,
INVALID_DEVID) == 0) {
wc_Kmac256_Update(&kmac, data, sizeof(data));
wc_Kmac256_Final(&kmac, out, sizeof(out));
wc_Kmac256_Free(&kmac);
}
function wc_Kmac256_Update
int wc_Kmac256_Update(
wc_Kmac * kmac,
const byte * in,
word32 inLen
)
This function absorbs message data into a KMAC256 operation. It may be called any number of times before finalizing.
Parameters:
- kmac pointer to the wc_Kmac structure holding state.
- in the message data to authenticate.
- inLen length of the message data in bytes.
See:
Return:
- 0 Returned upon successfully adding the data.
- BAD_FUNC_ARG Returned when kmac is NULL, or in is NULL with a non-zero length.
Example
wc_Kmac256_Update(&kmac, data, sizeof(data));
function wc_Kmac256_Final
int wc_Kmac256_Final(
wc_Kmac * kmac,
byte * out,
word32 outLen
)
This function finalizes a KMAC256 operation, producing outLen bytes of output. The output length is bound into the result, so a KMAC with a different length is a different value.
Parameters:
- kmac pointer to the wc_Kmac structure holding state.
- out buffer to hold the output.
- outLen number of output bytes to produce.
See:
Return:
- 0 Returned upon successfully finalizing.
- BAD_FUNC_ARG Returned when kmac is NULL, or out is NULL with a non-zero length.
Example
byte out[64];
wc_Kmac256_Final(&kmac, out, sizeof(out));
function wc_Kmac256_FinalXof
int wc_Kmac256_FinalXof(
wc_Kmac * kmac,
byte * out,
word32 outLen
)
This function finalizes a KMAC256 operation as an XOF (KMACXOF256). Unlike wc_Kmac256_Final, the output length is not bound into the result, so any amount of output may be requested.
Parameters:
- kmac pointer to the wc_Kmac structure holding state.
- out buffer to hold the output.
- outLen number of output bytes to produce.
See:
Return:
- 0 Returned upon successfully finalizing.
- BAD_FUNC_ARG Returned when kmac is NULL, or out is NULL with a non-zero length.
Example
byte out[128];
wc_Kmac256_FinalXof(&kmac, out, sizeof(out));
function wc_Kmac256_Free
void wc_Kmac256_Free(
wc_Kmac * kmac
)
This function releases any resources associated with a KMAC256 operation. Passing NULL is safe and does nothing.
Parameters:
- kmac pointer to the wc_Kmac structure to free, may be NULL.
See: wc_InitKmac256
Example
wc_Kmac256_Free(&kmac);
function wc_Kmac256Hash
int wc_Kmac256Hash(
const byte * key,
word32 keyLen,
const byte * custom,
word32 customLen,
const byte * in,
word32 inLen,
byte * out,
word32 outLen
)
This function computes a KMAC256 over a single message in one call, initializing, updating and finalizing internally.
Parameters:
- key the key bytes.
- keyLen length of the key in bytes.
- custom customization string, or NULL when customLen is 0.
- customLen length of the customization string in bytes.
- in the message data to authenticate.
- inLen length of the message data in bytes.
- out buffer to hold the output.
- outLen number of output bytes to produce.
See:
Return:
- 0 Returned upon success.
- BAD_FUNC_ARG Returned when a required pointer is NULL with a non-zero length.
Example
byte key[32];
byte data[] = { Data to authenticate };
byte out[64];
wc_Kmac256Hash(key, sizeof(key), NULL, 0, data, sizeof(data),
out, sizeof(out));
function wc_Kmac256HashXof
int wc_Kmac256HashXof(
const byte * key,
word32 keyLen,
const byte * custom,
word32 customLen,
const byte * in,
word32 inLen,
byte * out,
word32 outLen
)
This function computes a KMACXOF256 over a single message in one call. Like wc_Kmac256Hash but the output length is not bound into the result, so any amount of output may be requested.
Parameters:
- key the key bytes.
- keyLen length of the key in bytes.
- custom customization string, or NULL when customLen is 0.
- customLen length of the customization string in bytes.
- in the message data to authenticate.
- inLen length of the message data in bytes.
- out buffer to hold the output.
- outLen number of output bytes to produce.
See:
Return:
- 0 Returned upon success.
- BAD_FUNC_ARG Returned when a required pointer is NULL with a non-zero length.
Example
byte key[32];
byte data[] = { Data to authenticate };
byte out[128];
wc_Kmac256HashXof(key, sizeof(key), NULL, 0, data, sizeof(data),
out, sizeof(out));
function wc_Kmac128_Copy
int wc_Kmac128_Copy(
wc_Kmac * src,
wc_Kmac * dst
)
This function copies the state of a KMAC128 operation so it can be finalized more than once, for example over a common message prefix.
Parameters:
- src pointer to the wc_Kmac structure to copy from.
- dst pointer to the wc_Kmac structure to copy into.
See:
Return:
- 0 Returned upon success.
- BAD_FUNC_ARG Returned when src or dst is NULL.
Example
wc_Kmac kmac;
wc_Kmac copy;
wc_InitKmac128(&kmac, key, keyLen, NULL, 0, NULL, INVALID_DEVID);
wc_Kmac128_Update(&kmac, prefix, prefixLen);
wc_Kmac128_Copy(&kmac, ©);
function wc_Kmac256_Copy
int wc_Kmac256_Copy(
wc_Kmac * src,
wc_Kmac * dst
)
This function copies the state of a KMAC256 operation so it can be finalized more than once, for example over a common message prefix.
Parameters:
- src pointer to the wc_Kmac structure to copy from.
- dst pointer to the wc_Kmac structure to copy into.
See:
Return:
- 0 Returned upon success.
- BAD_FUNC_ARG Returned when src or dst is NULL.
Example
wc_Kmac kmac;
wc_Kmac copy;
wc_InitKmac256(&kmac, key, keyLen, NULL, 0, NULL, INVALID_DEVID);
wc_Kmac256_Update(&kmac, prefix, prefixLen);
wc_Kmac256_Copy(&kmac, ©);
function wc_InitCshake128
int wc_InitCshake128(
wc_Cshake * cshake,
const byte * name,
word32 nameLen,
const byte * custom,
word32 customLen,
void * heap,
int devId
)
This function initializes a cSHAKE128 operation (customizable SHAKE, NIST SP 800-185) with a function-name and customization string. cSHAKE is enabled together with KMAC (WOLFSSL_KMAC). When both strings are empty, cSHAKE reduces to plain SHAKE128.
Parameters:
- cshake pointer to the wc_Cshake structure to initialize.
- name function-name string (reserved for NIST-defined functions); use an empty string for application customization via custom.
- nameLen length of the function-name string in bytes.
- custom customization string, or NULL when customLen is 0.
- customLen length of the customization string in bytes.
- heap pointer to a heap hint, may be NULL.
- devId device identifier, or INVALID_DEVID.
See:
Return:
- 0 Returned upon successfully initializing.
- BAD_FUNC_ARG Returned when a required pointer is NULL.
Example
wc_Cshake cshake;
byte out[32];
if (wc_InitCshake128(&cshake, NULL, 0, custom, customLen, NULL,
INVALID_DEVID) == 0) {
wc_Cshake128_Update(&cshake, data, dataLen);
wc_Cshake128_Final(&cshake, out, sizeof(out));
wc_Cshake128_Free(&cshake);
}
function wc_Cshake128_Update
int wc_Cshake128_Update(
wc_Cshake * cshake,
const byte * in,
word32 inLen
)
This function absorbs message data into a cSHAKE128 operation.
Parameters:
- cshake pointer to the wc_Cshake structure holding state.
- in the message data.
- inLen length of the message data in bytes.
See:
Return:
- 0 Returned upon successfully adding the data.
- BAD_FUNC_ARG Returned when cshake is NULL, or in is NULL with a non-zero length.
Example
wc_Cshake128_Update(&cshake, data, dataLen);
function wc_Cshake128_Final
int wc_Cshake128_Final(
wc_Cshake * cshake,
byte * out,
word32 outLen
)
This function finalizes a cSHAKE128 operation, squeezing outLen bytes of output. cSHAKE is an XOF, so a longer squeeze extends a shorter one over the same input.
Parameters:
- cshake pointer to the wc_Cshake structure holding state.
- out buffer to hold the output.
- outLen number of output bytes to produce.
See:
Return:
- 0 Returned upon successfully finalizing.
- BAD_FUNC_ARG Returned when cshake is NULL, or out is NULL with a non-zero length.
Example
byte out[32];
wc_Cshake128_Final(&cshake, out, sizeof(out));
function wc_Cshake128_Free
void wc_Cshake128_Free(
wc_Cshake * cshake
)
This function releases any resources associated with a cSHAKE128 operation. Passing NULL is safe and does nothing.
Parameters:
- cshake pointer to the wc_Cshake structure to free, may be NULL.
See: wc_InitCshake128
Example
wc_Cshake128_Free(&cshake);
function wc_Cshake128
int wc_Cshake128(
const byte * name,
word32 nameLen,
const byte * custom,
word32 customLen,
const byte * in,
word32 inLen,
byte * out,
word32 outLen
)
This function computes a cSHAKE128 over a single message in one call, initializing, updating and finalizing internally.
Parameters:
- name function-name string, or NULL when nameLen is 0.
- nameLen length of the function-name string in bytes.
- custom customization string, or NULL when customLen is 0.
- customLen length of the customization string in bytes.
- in the message data.
- inLen length of the message data in bytes.
- out buffer to hold the output.
- outLen number of output bytes to produce.
See:
Return:
- 0 Returned upon success.
- BAD_FUNC_ARG Returned when a required pointer is NULL with a non-zero length.
Example
byte out[32];
wc_Cshake128(NULL, 0, custom, customLen, data, dataLen, out, sizeof(out));
function wc_InitCshake256
int wc_InitCshake256(
wc_Cshake * cshake,
const byte * name,
word32 nameLen,
const byte * custom,
word32 customLen,
void * heap,
int devId
)
This function initializes a cSHAKE256 operation (customizable SHAKE, NIST SP 800-185) with a function-name and customization string. cSHAKE is enabled together with KMAC (WOLFSSL_KMAC). When both strings are empty, cSHAKE reduces to plain SHAKE256.
Parameters:
- cshake pointer to the wc_Cshake structure to initialize.
- name function-name string (reserved for NIST-defined functions); use an empty string for application customization via custom.
- nameLen length of the function-name string in bytes.
- custom customization string, or NULL when customLen is 0.
- customLen length of the customization string in bytes.
- heap pointer to a heap hint, may be NULL.
- devId device identifier, or INVALID_DEVID.
See:
Return:
- 0 Returned upon successfully initializing.
- BAD_FUNC_ARG Returned when a required pointer is NULL.
Example
wc_Cshake cshake;
byte out[32];
if (wc_InitCshake256(&cshake, NULL, 0, custom, customLen, NULL,
INVALID_DEVID) == 0) {
wc_Cshake256_Update(&cshake, data, dataLen);
wc_Cshake256_Final(&cshake, out, sizeof(out));
wc_Cshake256_Free(&cshake);
}
function wc_Cshake256_Update
int wc_Cshake256_Update(
wc_Cshake * cshake,
const byte * in,
word32 inLen
)
This function absorbs message data into a cSHAKE256 operation.
Parameters:
- cshake pointer to the wc_Cshake structure holding state.
- in the message data.
- inLen length of the message data in bytes.
See:
Return:
- 0 Returned upon successfully adding the data.
- BAD_FUNC_ARG Returned when cshake is NULL, or in is NULL with a non-zero length.
Example
wc_Cshake256_Update(&cshake, data, dataLen);
function wc_Cshake256_Final
int wc_Cshake256_Final(
wc_Cshake * cshake,
byte * out,
word32 outLen
)
This function finalizes a cSHAKE256 operation, squeezing outLen bytes of output. cSHAKE is an XOF, so a longer squeeze extends a shorter one over the same input.
Parameters:
- cshake pointer to the wc_Cshake structure holding state.
- out buffer to hold the output.
- outLen number of output bytes to produce.
See:
Return:
- 0 Returned upon successfully finalizing.
- BAD_FUNC_ARG Returned when cshake is NULL, or out is NULL with a non-zero length.
Example
byte out[32];
wc_Cshake256_Final(&cshake, out, sizeof(out));
function wc_Cshake256_Free
void wc_Cshake256_Free(
wc_Cshake * cshake
)
This function releases any resources associated with a cSHAKE256 operation. Passing NULL is safe and does nothing.
Parameters:
- cshake pointer to the wc_Cshake structure to free, may be NULL.
See: wc_InitCshake256
Example
wc_Cshake256_Free(&cshake);
function wc_Cshake256
int wc_Cshake256(
const byte * name,
word32 nameLen,
const byte * custom,
word32 customLen,
const byte * in,
word32 inLen,
byte * out,
word32 outLen
)
This function computes a cSHAKE256 over a single message in one call, initializing, updating and finalizing internally.
Parameters:
- name function-name string, or NULL when nameLen is 0.
- nameLen length of the function-name string in bytes.
- custom customization string, or NULL when customLen is 0.
- customLen length of the customization string in bytes.
- in the message data.
- inLen length of the message data in bytes.
- out buffer to hold the output.
- outLen number of output bytes to produce.
See:
Return:
- 0 Returned upon success.
- BAD_FUNC_ARG Returned when a required pointer is NULL with a non-zero length.
Example
byte out[32];
wc_Cshake256(NULL, 0, custom, customLen, data, dataLen, out, sizeof(out));
function wc_Cshake128_Copy
int wc_Cshake128_Copy(
wc_Cshake * src,
wc_Cshake * dst
)
This function copies the state of a cSHAKE128 operation so it can be finalized more than once, for example over a common message prefix. dst must already be an initialized wc_Cshake.
Parameters:
- src pointer to the wc_Cshake structure to copy from.
- dst pointer to the wc_Cshake structure to copy into.
See:
Return:
- 0 Returned upon success.
- BAD_FUNC_ARG Returned when src or dst is NULL.
Example
wc_Cshake cshake;
wc_Cshake copy;
wc_InitCshake128(&cshake, NULL, 0, custom, customLen, NULL, INVALID_DEVID);
wc_InitCshake128(©, NULL, 0, custom, customLen, NULL, INVALID_DEVID);
wc_Cshake128_Update(&cshake, prefix, prefixLen);
wc_Cshake128_Copy(&cshake, ©);
function wc_Cshake256_Copy
int wc_Cshake256_Copy(
wc_Cshake * src,
wc_Cshake * dst
)
This function copies the state of a cSHAKE256 operation so it can be finalized more than once, for example over a common message prefix. dst must already be an initialized wc_Cshake.
Parameters:
- src pointer to the wc_Cshake structure to copy from.
- dst pointer to the wc_Cshake structure to copy into.
See:
Return:
- 0 Returned upon success.
- BAD_FUNC_ARG Returned when src or dst is NULL.
Example
wc_Cshake cshake;
wc_Cshake copy;
wc_InitCshake256(&cshake, NULL, 0, custom, customLen, NULL, INVALID_DEVID);
wc_InitCshake256(©, NULL, 0, custom, customLen, NULL, INVALID_DEVID);
wc_Cshake256_Update(&cshake, prefix, prefixLen);
wc_Cshake256_Copy(&cshake, ©);
Source code
int wc_InitSha3_224(wc_Sha3* sha3, void* heap, int devId);
int wc_Sha3_224_Update(wc_Sha3* sha, const byte* data, word32 len);
int wc_Sha3_224_Final(wc_Sha3* sha3, byte* hash);
void wc_Sha3_224_Free(wc_Sha3* sha3);
int wc_Sha3_224_GetHash(wc_Sha3* sha3, byte* hash);
int wc_Sha3_224_Copy(wc_Sha3* sha3, wc_Sha3* dst);
int wc_InitSha3_256(wc_Sha3* sha3, void* heap, int devId);
int wc_Sha3_256_Update(wc_Sha3* sha, const byte* data, word32 len);
int wc_Sha3_256_Final(wc_Sha3* sha3, byte* hash);
void wc_Sha3_256_Free(wc_Sha3* sha3);
int wc_Sha3_256_GetHash(wc_Sha3* sha3, byte* hash);
int wc_Sha3_256_Copy(wc_Sha3* sha3, wc_Sha3* dst);
int wc_InitSha3_384(wc_Sha3* sha3, void* heap, int devId);
int wc_Sha3_384_Update(wc_Sha3* sha, const byte* data, word32 len);
int wc_Sha3_384_Final(wc_Sha3* sha3, byte* hash);
void wc_Sha3_384_Free(wc_Sha3* sha3);
int wc_Sha3_384_GetHash(wc_Sha3* sha3, byte* hash);
int wc_Sha3_384_Copy(wc_Sha3* sha3, wc_Sha3* dst);
int wc_InitSha3_512(wc_Sha3* sha3, void* heap, int devId);
int wc_Sha3_512_Update(wc_Sha3* sha, const byte* data, word32 len);
int wc_Sha3_512_Final(wc_Sha3* sha3, byte* hash);
void wc_Sha3_512_Free(wc_Sha3* sha3);
int wc_Sha3_512_GetHash(wc_Sha3* sha3, byte* hash);
int wc_Sha3_512_Copy(wc_Sha3* sha3, wc_Sha3* dst);
int wc_InitShake128(wc_Shake* shake, void* heap, int devId);
int wc_Shake128_Update(wc_Shake* sha, const byte* data, word32 len);
int wc_Shake128_Final(wc_Shake* shake, byte* hash, word32 hashLen);
int wc_Shake128_Absorb(wc_Shake* sha, const byte* data, word32 len);
int wc_Shake128_SqueezeBlocks(wc_Shake* shake, byte* out, word32 blockCnt);
void wc_Shake128_Free(wc_Shake* shake);
int wc_Shake128_GetHash(wc_Shake* shake, byte* hash);
int wc_Shake128_Copy(wc_Shake* src, wc_Sha3* dst);
int wc_InitShake256(wc_Shake* shake, void* heap, int devId);
int wc_Shake256_Update(wc_Shake* sha, const byte* data, word32 len);
int wc_Shake256_Final(wc_Shake* shake, byte* hash, word32 hashLen);
int wc_Shake256_Absorb(wc_Shake* sha, const byte* data, word32 len);
int wc_Shake256_SqueezeBlocks(wc_Shake* shake, byte* out, word32 blockCnt);
void wc_Shake256_Free(wc_Shake* shake);
int wc_Shake256_GetHash(wc_Shake* shake, byte* hash);
int wc_Shake256_Copy(wc_Shake* src, wc_Sha3* dst);
int wc_InitKmac128(wc_Kmac* kmac, const byte* key, word32 keyLen,
const byte* custom, word32 customLen, void* heap, int devId);
int wc_Kmac128_Update(wc_Kmac* kmac, const byte* in, word32 inLen);
int wc_Kmac128_Final(wc_Kmac* kmac, byte* out, word32 outLen);
int wc_Kmac128_FinalXof(wc_Kmac* kmac, byte* out, word32 outLen);
void wc_Kmac128_Free(wc_Kmac* kmac);
int wc_Kmac128Hash(const byte* key, word32 keyLen, const byte* custom,
word32 customLen, const byte* in, word32 inLen, byte* out, word32 outLen);
int wc_Kmac128HashXof(const byte* key, word32 keyLen, const byte* custom,
word32 customLen, const byte* in, word32 inLen, byte* out, word32 outLen);
int wc_InitKmac256(wc_Kmac* kmac, const byte* key, word32 keyLen,
const byte* custom, word32 customLen, void* heap, int devId);
int wc_Kmac256_Update(wc_Kmac* kmac, const byte* in, word32 inLen);
int wc_Kmac256_Final(wc_Kmac* kmac, byte* out, word32 outLen);
int wc_Kmac256_FinalXof(wc_Kmac* kmac, byte* out, word32 outLen);
void wc_Kmac256_Free(wc_Kmac* kmac);
int wc_Kmac256Hash(const byte* key, word32 keyLen, const byte* custom,
word32 customLen, const byte* in, word32 inLen, byte* out, word32 outLen);
int wc_Kmac256HashXof(const byte* key, word32 keyLen, const byte* custom,
word32 customLen, const byte* in, word32 inLen, byte* out, word32 outLen);
int wc_Kmac128_Copy(wc_Kmac* src, wc_Kmac* dst);
int wc_Kmac256_Copy(wc_Kmac* src, wc_Kmac* dst);
int wc_InitCshake128(wc_Cshake* cshake, const byte* name, word32 nameLen,
const byte* custom, word32 customLen, void* heap, int devId);
int wc_Cshake128_Update(wc_Cshake* cshake, const byte* in, word32 inLen);
int wc_Cshake128_Final(wc_Cshake* cshake, byte* out, word32 outLen);
void wc_Cshake128_Free(wc_Cshake* cshake);
int wc_Cshake128(const byte* name, word32 nameLen, const byte* custom,
word32 customLen, const byte* in, word32 inLen, byte* out, word32 outLen);
int wc_InitCshake256(wc_Cshake* cshake, const byte* name, word32 nameLen,
const byte* custom, word32 customLen, void* heap, int devId);
int wc_Cshake256_Update(wc_Cshake* cshake, const byte* in, word32 inLen);
int wc_Cshake256_Final(wc_Cshake* cshake, byte* out, word32 outLen);
void wc_Cshake256_Free(wc_Cshake* cshake);
int wc_Cshake256(const byte* name, word32 nameLen, const byte* custom,
word32 customLen, const byte* in, word32 inLen, byte* out, word32 outLen);
int wc_Cshake128_Copy(wc_Cshake* src, wc_Cshake* dst);
int wc_Cshake256_Copy(wc_Cshake* src, wc_Cshake* dst);
Updated on 2026-07-31 at 19:54:17 +0000