Skip to content

Latest commit

 

History

History
50 lines (31 loc) · 1.16 KB

GUID-89653DD6-F6DA-41EE-BB71-EA0802087DAB.md

File metadata and controls

50 lines (31 loc) · 1.16 KB

CRYPT_HMAC_Finalize Function

Parent topic:MPLAB® Harmony Crypto Library

C

int CRYPT_HMAC_Finalize(
    CRYPT_HMAC_CTX* hmac, 
    unsigned char* digest
);

Description

This function completes the HMAC calculations. The results are placed in the location pointed to by the digest parameter.

Preconditions

The CRYPT_HMAC_CTX context must be initialized using the CRYPT_HMAC_SetKey function prior to any call to this function.

Parameters

Parameters Description
hmac Pointer to context that saves state between calls.
digest Pointer to where the final HMAC digest results will be stored.

Returns

  • BAD_FUNC_ARG - An invalid pointer was passed to the function.

  • 0 - An invalid pointer was not passed to the function.

Remarks

The area pointed to by the digest parameter must be large enough to hold the results.

Example

CRYPT_HMAC_CTX mcHmac;
byte           mcDigest[CRYPT_SHA512_DIGEST_SIZE];

CRYPT_HMAC_SetKey(&mcHmac, CRYPT_HMAC_SHA, key, 4);
CRYPT_HMAC_DataAdd(&mcHmac, ourData, OUR_DATA_SIZE);
 CRYPT_HMAC_Finalize(&mcHmac, mcDigest);