1.59 CRYPT_SHA256_DataAdd Function
C
int CRYPT_SHA256_DataAdd(
CRYPT_SHA256_CTX* sha256,
const unsigned char* input,
unsigned int sz
);
Description
This function updates the hash with the data provided.
Preconditions
The SHA256 context must be inititialized prior to the first call of this function. The context must not be modified by code outside of this function.
Parameters
Parameters | Description |
---|---|
sha256 | Pointer to CRYPT_SHA256_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. |
Returns
BAD_FUNC_ARG - An invalid pointer was passed to the function, either in sha256 or input.
0 - An invalid pointer was not passed to the function.
Remarks
In order to preserve the validity of the SHA256 hash, nothing must modify the context holding variable between calls to CRYPT_SHA256_DataAdd.
Example
CRYPT_SHA256_CTX sha256;
uint8_t buffer[1024];
uint8_t shaSum[SHA256_DIGEST_SIZE];
CRYPT_SHA256_Initialize(&sha256);
CRYPT_SHA256_DataAdd(&sha256, buffer, sizeof(buffer));
CRYPT_SHA256_Finalize(&sha256, shaSum);