SHA3(3) Library Functions Manual SHA3(3)

# [NAME](#NAME)

`SHA3` — NIST FIPS PUB 202: SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions

# [LIBRARY](#LIBRARY)

Message Digest (MD4, MD5, etc.) Support Library (libmd, -lmd)

# [SYNOPSIS](#SYNOPSIS)

`#include <sha3.h>`

`void`  
`SHA3_224_Init`(`SHA3_224_CTX *ctx`);

`void`  
`SHA3_224_Update`(`SHA3_224_CTX *ctx`, `const uint8_t *buf`, `size_t len`);

`void`  
`SHA3_224_Final`(`uint8_t digest[SHA3_224_DIGEST_LENGTH]`, `SHA3_224_CTX *ctx`);

`void`  
`SHA3_256_Init`(`SHA3_256_CTX *ctx`);

`void`  
`SHA3_256_Update`(`SHA3_256_CTX *ctx`, `const uint8_t *buf`, `size_t len`);

`void`  
`SHA3_256_Final`(`uint8_t digest[SHA3_256_DIGEST_LENGTH]`, `SHA3_256_CTX *ctx`);

`void`  
`SHA3_384_Init`(`SHA3_384_CTX *ctx`);

`void`  
`SHA3_384_Update`(`SHA3_384_CTX *ctx`, `const uint8_t *buf`, `size_t len`);

`void`  
`SHA3_384_Final`(`uint8_t digest[SHA3_384_DIGEST_LENGTH]`, `SHA3_384_CTX *ctx`);

`void`  
`SHA3_512_Init`(`SHA3_512_CTX *ctx`);

`void`  
`SHA3_512_Update`(`SHA3_512_CTX *ctx`, `const uint8_t *buf`, `size_t len`);

`void`  
`SHA3_512_Final`(`uint8_t digest[SHA3_512_DIGEST_LENGTH]`, `SHA3_512_CTX *ctx`);

# [DESCRIPTION](#DESCRIPTION)

The `SHA3` functions implement the cryptographic hash functions of the NIST SHA-3 standard, FIPS PUB 202. The `SHA3` functions compress an arbitrary-length message m into short fixed-length octet strings SHA3-224(m), SHA3-256(m), etc., called a cryptographic digest or hash.

Before using the `SHA3` functions, applications should first call [SHA3\_Selftest(3)](/man/os/libmd/SHA3_Selftest.3) and confirm that it succeeded.

Only the `SHA3_256` functions are specified in detail; the `SHA3_224`, `SHA3_384`, and `SHA3_512` functions are exactly analogous.

The caller must allocate memory for a `SHA3_256_CTX` object to hold the state of a SHA3-256 hash computation over a message. `SHA3_256_CTX` objects are slightly over 200 bytes, and may be copied or relocated in memory.

[`SHA3_256_Init`](#SHA3_256_Init)(`ctx`)

Initialize a SHA3-256 context. Must be done before any other operations on `ctx`.

[`SHA3_256_Update`](#SHA3_256_Update)(`ctx`, `data`, `len`)

Append `len` octets at `data` to the message.

[`SHA3_256_Final`](#SHA3_256_Final)(`digest`, `ctx`)

Store at `digest` the 32-octet SHA3-256 hash of the message obtained by concatenating all prior inputs to `SHA3_256_Update`() on `ctx`.

Subsequent use of `ctx` is not allowed, unless it is reinitialized with [`SHA3_256_Init`](#SHA3_256_Init~2)().

# [SEE ALSO](#SEE_ALSO)

[SHA3\_Selftest(3)](/man/os/libmd/SHA3_Selftest.3), [shake(3)](/man/os/libmd/shake.3)

# [STANDARDS](#STANDARDS)

National Institute of Standards and Technology, SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions, August 2015, FIPS PUB 202.

# [AUTHORS](#AUTHORS)

Taylor R Campbell ⟨campbell+sha3@mumble.net⟩

October 14, 2015 Linux 4.19.0-gvisor

---

Document: SHA3_384_Update(3) from libmd 1.3.0-r0 (Chainguard OS)
Source: https://gitlab.freedesktop.org/libbsd/libmd.git
