1.51 CRYPT_SHA_DataAdd Function

C

int CRYPT_SHA_DataAdd(
    CRYPT_SHA_CTX* sha, 
    const unsigned char* input, 
    unsigned int sz
);

Description

This function updates the hash with the data provided.

Preconditions

The SHA context must be initialized prior to the first call of this function. The context must not be modified by code outside of this function.

Parameters

ParametersDescription
shaPointer to CRYPT_SHA_CTX structure which holds the hash values.
inputPointer to the data to use to update the hash.
szSize of the data (in bytes) to use to update the hash.

Returns

  • BAD_FUNC_ARG - An invalid pointer was passed to the function. either sha or input.

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

Remarks

In order to preserve the validity of the SHA hash, nothing must modify the context holding variable between calls to CRYPT_SHA_DataAdd.

Example

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

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