tpf_SHA512_Init: Initialize control structure
Use this function to allocate and initialize the structure that is used by the tpf_SHA512_Update and tpf_SHA512_Final functions to create a 64-byte message digest from discontiguous data by using Secure Hashing Algorithm 512 (SHA-512).
Last updated
Added in 2019.
Format
#include <tpf/tpfapi.h>
tpf_SHA512_CTX *tpf_SHA512_Init(); - tpf_SHA512_CTX
- A pointer to the structure that is allocated and initialized.
Normal return
A nonzero return code is the pointer to the tpf_SHA512_CTX structure.
Error return
If an error occurred, NULL,
0, or the following return code is returned:
- TPF_DIGEST_NOALLOC
- The tpf_SHA512_CTX structure could not be allocated.
Programming considerations
- The CP Assist for Cryptographic Function (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.
- The tpf_SHA512_Final function releases the structure that is allocated by this function.
- 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);
}