crypto_Hash_Status_E Crypto_Hash_Shake_Digest(
crypto_HandlerType_E shakeHandlerType_en,
crypto_Hash_Algo_E shakeAlgorithm_en,
uint8_t *ptr_data,
uint32_t dataLen,
uint8_t *ptr_digest,
uint32_t digestLen,
uint32_t shakeSessionId
);
Description
This API performs hash generation for different variants of SHAKE algorithms in a
single step without initializing.
Parameters
No. | Argument Type | Argument Name | Type | Description |
---|
1 | crypto_HandlerType_E | shakeHandlerType_en | Input | Enum for
crypto operation handler i.e., SW, HW |
2 | crypto_Hash_Algo_E | shakeAlgorithm_en | Input | Selection of
SHAKE algorithm variant |
3 | uint8_t* | ptr_data | Input | Input data
which digest needs to calculate |
4 | uint32_t | dataLen | Input | Length of the
input data in number of bytes |
5 | uint8_t* | ptr_digest | Output | Pointer to
store calculated digest |
6 | uint32_t | digestLen | Input | Expected
length of hash/digest input data in number of bytes |
7 | uint32_t | shakeSessionId | Input | It defines the
session ID, must be more than zero |
Returns
Return Type | Description |
---|
crypto_Hash_Status_E | Function
returns the status of the API. |
Prerequisites
- To use the HW handler, the
algorithm must be enabled in Crypto v4 in MPLAB® Code Configurator.
- To use the SW handler, the
algorithm must be enabled in wolfCrypt, and linked to Crypto V4 in MPLAB® Code
Configurator.
Example
#define sessionID 1
crypto_Hash_Status_E status;
crypto_HandlerType_E handlerType_en = CRYPTO_HANDLER_SW_WOLFCRYPT;
crypto_Hash_Algo_E shaAlgorithm_en = CRYPTO_HASH_SHA3_SHAKE128;
uint8_t inputData[32] = {/*data*/};
uint32_t dataLen = sizeof(inputData);
uint8_t outData[100];
uint32_t digestLen = 100;
status = Crypto_Hash_Shake_Digest(
handlerType_en,
shaAlgorithm_en,
inputData,
dataLen,
outData,
digestLen,
sessionID
);