Skip to content

Latest commit

 

History

History
51 lines (32 loc) · 1.24 KB

GUID-4458C8F5-B169-436E-A481-E4E7F08BAD48.md

File metadata and controls

51 lines (32 loc) · 1.24 KB

CRYPT_SHA512_Finalize Function

Parent topic:MPLAB® Harmony Crypto Library

C

int CRYPT_SHA512_Finalize(
    CRYPT_SHA512_CTX* sha512, 
    unsigned char* digest
);

Description

This function finalizes the hash and puts the result into digest.

Preconditions

The SHA512 context must be initialized prior to calling this function. The context must not be modified by code outisde of this function.

Parameters

Parameters Description
sha512 Pointer to CRYPT_SHA512_CTX structure which holds the hash values.
digest Pointer to byte array to store hash result.

Returns

  • BAD_FUNC_ARG - An invalid pointer was passed to the function, either in sha512 or digest.

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

Remarks

In order to preserve the validity of the SHA512 hash, nothing must modify the context holding variable between calls to CRYPT_SHA512_DataAdd and CRYPT_SHA512_Finalize.

Example

CRYPT_SHA512_CTX sha512;
uint8_t buffer[1024];
uint8_t sha512Sum[SHA512_DIGEST_SIZE];

CRYPT_SHA512_Initialize(&sha512);
CRYPT_SHA512_DataAdd(&sha512, buffer, sizeof(buffer));
CRYPT_SHA512_Finalize(&sha512, sha512Sum);