Skip to content

Latest commit

 

History

History
52 lines (33 loc) · 1.1 KB

GUID-FBCCBBC0-6478-4058-9FF3-610A99689278.md

File metadata and controls

52 lines (33 loc) · 1.1 KB

CRYPT_HMAC_DataAdd Function

Parent topic:MPLAB® Harmony Crypto Library

C

int CRYPT_HMAC_DataAdd(
    CRYPT_HMAC_CTX* hmac, 
    const unsigned char* input, 
    unsigned int sz
);

Description

This function adds data to the HMAC so that multiple blocks of data can be processed.

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.
input Pointer to the data that will be used to update the hash.
sz Size of the input data in bytes.

Returns

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

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

Remarks

None.

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);