Skip to content

Latest commit

 

History

History
52 lines (33 loc) · 1.13 KB

GUID-67C1AE49-0995-4475-88F9-42850CA52679.md

File metadata and controls

52 lines (33 loc) · 1.13 KB

CRYPT_SHA_DataSizeSet Function

Parent topic:MPLAB® Harmony Crypto Library

C

int CRYPT_SHA_DataSizeSet(
    CRYPT_SHA_CTX* sha, 
    unsigned int msgSize
);

Description

The PIC32MZ hardware encryption module needs to know the size of the data before it starts processing. This function sets that value.

Preconditions

None.

Parameters

Parameters Description
sha Pointer to CRYPT_SHA_CTX structure which holds the hash values.
msgSize Size of the data (in bytes) that will be processed.

Returns

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

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

Remarks

All SHA hashes have to start at a particular value before adding new data to it. This function sets the necessary values for the structure.

Example

CRYPT_SHA_CTX sha;
uint8_t buffer[1024];
uint8_t shasum[SHA_DIGEST_SIZE];

CRYPT_SHA_Initialize(&sha);
CRYPT_SHADataSizeSet(&sha, sizeof(buffer));
CRYPT_SHA_DataAdd(&sha, buffer, sizeof(buffer));
CRYPT_SHA_Finalize(&sha, shasum);