Parent topic:MPLABĀ® Harmony Crypto Library
int CRYPT_SHA_DataAdd(
CRYPT_SHA_CTX* sha,
const unsigned char* input,
unsigned int sz
);
This function updates the hash with the data provided.
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 | Description |
---|---|
sha | Pointer to CRYPT_SHA_CTX structure which holds the hash values. |
input | Pointer to the data to use to update the hash. |
sz | Size of the data (in bytes) to use to update the hash. |
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.
In order to preserve the validity of the SHA hash, nothing must modify the context holding variable between calls to CRYPT_SHA_DataAdd.
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);