Skip to content

Latest commit

 

History

History
48 lines (29 loc) · 946 Bytes

GUID-56378969-28DB-4F13-9EB8-36EC4D3AEAA6.md

File metadata and controls

48 lines (29 loc) · 946 Bytes

CRYPT_SHA_Initialize Function

Parent topic:MPLAB® Harmony Crypto Library

C

int CRYPT_SHA_Initialize(
    CRYPT_SHA_CTX* sha
);

Description

This function initializes the internal structures necessary for SHA hash calculations.

Preconditions

None.

Parameters

Parameters Description
sha Pointer to CRYPT_SHA_CTX structure which holds the hash values.

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. Thus function sets the necessary values for the structure.

Example

CRYPT_SHA_CTX sha;
uint8_t shaSum[SHA_DIGEST_SIZE];

CRYPT_SHA_Initialize(&sha);
CRYPT_SHA_DataAdd(&sha, buffer, sizeof(buffer));
CRYPT_SHA_Finalize(&sha, shaSum);