crypto_Hash_Status_E Crypto_Hash_Sha_Digest (
crypto_HandlerType_E shaHandler_en,
uint8_t *ptr_data,
uint32_t dataLen,
uint8_t *ptr_digest,
crypto_Hash_Algo_E shaAlgorithm_en,
uint32_t shaSessionId
);
Description
This API performs hash generation for different variants of SHA-1, SHA-2, and SHA-3
(Excluding SHAKE) algorithms in a single step without initializing.
Parameters
No. | Argument Type | Argument Name | Type | Description |
---|
1 | crypto_HandlerType_E | shaHandler_en | Input | Enum for
crypto operation handler i.e., SW, HW. |
2 | uint8_t* | ptr_data | Input | Input data
which digest needs to calculate. |
3 | uint32_t | dataLen | Input | Length of the
input data in number of bytes. |
4 | uint8_t* | ptr_digest | Output | Pointer to
store calculated digest. |
5 | crypto_Hash_Algo_E | shaAlgorithm_en | Input | Selection of
SHA algorithm variant, i.e., SHA-2-224 or SHA-1 or SHA3-224,
etc. |
6 | uint32_t | shaSessionId | 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_HW_INTERNAL;
crypto_Hash_Algo_E shaAlgorithm_en = CRYPTO_HASH_SHA2_224;
uint8_t inputData[32] = {/*data*/};
uint32_t dataLen = sizeof(inputData);
uint8_t digest[28];
status = Crypto_Hash_Sha_Digest(
handlerType_en,
inputData,
dataLen,
digest,
shaAlgorithm_en,
sessionID
);