Description

The SHA2Init(), SHA2Update(), SHA2Final() functions implement the SHA224, SHA256, SHA384 and SHA512 message-digest algorithms. The algorithms take as input
a message of arbitrary length and produces a 200-bit “fingerprint” or “message digest” as output. The SHA2 message-digest algorithms are intended for digital signature applications in which large files are “compressed” in a secure manner before
being encrypted with a private (secret) key under a public-key cryptosystem such as RSA.

SHA2Init(), SHA2Update(), SHA2Final()

The SHA2Init(), SHA2Update(), and SHA2Final() functions allow an SHA2 digest to be computed over multiple message blocks. Between blocks, the state of the SHA2 computation is held in
an SHA2 context structure allocated by the caller. A complete digest computation consists of calls to SHA2 functions in the following order: one call to SHA2Init(), one or more calls to SHA2Update(), and one call to
SHA2Final().

The SHA2Init() function initializes the SHA2 context structure pointed to by context. The mech argument is one of SHA224, SHA256, SHA512, and SHA384.

The SHA2Update() function computes a partial SHA2 digest on the inlen-byte message block pointed to by input, and updates the SHA2 context structure pointed to by context accordingly.

The SHA2Final() function generates the final SHA2Final digest, using the SHA2 context structure pointed to by context. The SHA2 digest is written to output. After a call to SHA2Final(),
the state of the context structure is undefined. It must be reinitialized with SHA2Init() before it can be used again.

Alternative APIs exist as named above. The Update() and Final() sets of functions operate exactly as the previously described SHA2Update() and SHA2Final() functions. The SHA224Init(),
SHA256Init(), SHA384Init(), and SHA512Init() functions do not take the mech argument as it is implicit in the function names.

Return Values

These functions do not return a value.

Examples

Example 1 Authenticate a message found in multiple buffers

The following is a sample function that authenticates a message found in multiple buffers. The calling function provides an authentication buffer to contain the result of the SHA2 digest.

The following is a sample function that authenticates a message found in multiple buffers. The calling function provides an authentication buffer that will contain the result of the SHA384 digest, using alternative interfaces.