4.4.2.3 Crypto_Hash_Shake_Final

crypto_Hash_Status_E Crypto_Hash_Shake_Final(
    st_Crypto_Hash_Shake_Ctx *ptr_shakeCtx_st, 
    uint8_t *ptr_digest
    );

Description

This API is used to get the calculated hash/digest for different variants SHAKE algorithms in multi-steps. Initialize context by calling Crypto_Hash_Shake_Init function and calculate hash using Crypto_Hash_Shake_Update and then call this function.

Parameters

No.Argument TypeArgument NameTypeDescription
1st_Crypto_Hash_Shake_Ctx*ptr_shakeCtx_stInputHash algorithm and crypto handler selection
2uint8_t*ptr_digestOutputPointer to store calculated digest

Returns

Return TypeDescription
crypto_Hash_Status_EFunction 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.
  • Crypto_Hash_Shake_Init and Crypto_Hash_Shake_Update must be called before calling Crypto_Hash_Shake_Final.

Example

#define sessionID 1
crypto_Hash_Status_E status;
crypto_HandlerType_E handlerType_en = CRYPTO_HANDLER_SW_WOLFCRYPT;
st_Crypto_Hash_Sha_Ctx  Hash_Ctx;
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_Init(
    &Hash_Ctx, 
    shaAlgorithm_en,
    handlerType_en,
    digestLen,  
    sessionID
    );

status = Crypto_Hash_Shake_Update(
    &Hash_Ctx, 
    inputData, 
    dataLen
    );

status = Crypto_Hash_Shake_Final(
    &Hash_Ctx, 
    outData
    );