tpf_SHA512_Update: Update message digest value
Use this function to update the 64-byte message digest value that is built by using Secure Hashing Algorithm 512 (SHA-512).
Last updated
Added in 2019.
Format
#include <tpf/tpfapi.h>
int tpf_SHA512_Update(struct tpf_SHA512_CTX *dctx,
void *tpf_data_in,
int tpf_data_len);
- dctx
- A pointer to the tpf_SHA512_CTX structure.
- tpf_data_in
- A pointer to the data to be hashed.
- tpf_data_len
- The length of the data to be hashed. Valid values for this parameter are 0 - 1000000.
Normal return
- TPF_DIGEST_OK
- The message digest was successfully updated.
Error return
If an error occurred, one of the following error codes is returned:
- TPF_SHA_CTX_BAD
- The pointer to the tpf_SHA512_CTX structure is not valid because the pointer is bad or does not point to a valid SHA-512 structure.
- TPF_SHA_PTR_BAD
- The pointer to the data to be hashed is not valid because the pointer is bad or the storage pointed to is not addressable.
- TPF_SHA_LEN_BAD
- The length of the data to be hashed is not valid.
- TPF_SHA_HARDWARE_NOT_INSTALLED
- The CP Assist for Cryptographic Function (CPACF) is not available on the processor or does not support the SHA-512 algorithm.
- TPF_SHA_STATE_CHECK
- The message digest computation was issued before cryptographic restart processing completed.
Programming considerations
- The CPACF must be installed and support the SHA-512 algorithm on the processor that the function call is issued from.
- Use the tpf_SHA512_Init, tpf_SHA512_Update, and tpf_SHA512_Final functions to create a message digest for discontiguous data.
- If the data to be hashed exists in contiguous storage, use the tpf_SHA512_Digest function to create the message digest.
- If this function is called from an assembly language program through the CALLC macro, include the ICPACF.MAC DSECT in the program to define the function return codes.
Examples
The following example creates a message digest from discontiguous data.
#include <tpf/tpfapi.h>
{
char plain_text1[];
char plain_text2[];
struct tpf_SHA512_CTX *dctx;
int size, rc;
char md[64]="";
dctx = tpf_SHA512_Init();
if (dctx == TPF_DIGEST_NOALLOC)
exit(0);
rc = tpf_SHA512_Update(dctx, plain_text1, size);
rc = tpf_SHA512_Update(dctx, plain_text2, size);
rc = tpf_SHA512_Final(md, dctx);
}