tpf_SHA512_Digest: Create message digest
Use this function to create a 64-byte message digest from contiguous data by using Secure
Hashing Algorithm 512 (SHA-512).
Last updated
Added in 2019.
Format
#include <tpf/tpfapi.h>
int tpf_SHA512_Digest(void *tpf_data_in,
int tpf_data_len,
char *md);
- 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.
- md
- A pointer to the buffer into which the final message digest is placed. The buffer must be at least 64 bytes.
Normal return
- TPF_DIGEST_OK
- The message digest was computed successfully.
Error return
If an error occurred, one of the following error codes is returned:
- 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_MD_BAD
- The pointer to the buffer into which the message digest is placed is not valid because the pointer is bad or the buffer pointed to is not addressable.
- 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 this 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 contiguous data.
#include <tpf/tpfapi.h>
{
char plain_text[];
int size, rc;
char md[64]="";
rc = tpf_SHA512_Digest(plain_text, size, md);
}