SHA3\_SELFTEST(3) Library Functions Manual SHA3\_SELFTEST(3)

# [NAME](#NAME)

`SHA3_Selftest` — 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>`

`int`  
`SHA3_Selftest`(`void`);

# [DESCRIPTION](#DESCRIPTION)

The `SHA3_Selftest` function automatically tests a number of SHA-3 computations on fixed inputs with with known outputs to make sure the [sha3(3)](/man/os/libmd/sha3.3) library is not catastrophically broken. Applications should call [`SHA3_Selftest`](#SHA3_Selftest)() and confirm that it succeeded before using the [sha3(3)](/man/os/libmd/sha3.3), or [shake(3)](/man/os/libmd/shake.3) functions.

[`SHA3_Selftest`](#SHA3_Selftest~2)() returns 0 if successful, or -1 if the self-test failed.

The [`SHA3_Selftest`](#SHA3_Selftest~3)() function costs a few hundred thousand cycles on most CPUs, since it involves a little over a hundred calls to the Keccak permutation, which usually take one or two thousand cycles each.

# [SEE ALSO](#SEE_ALSO)

[sha3(3)](/man/os/libmd/sha3.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_Selftest(3) from libmd 1.2.0-r3 (Chainguard OS)
Source: https://gitlab.freedesktop.org/libbsd/libmd.git
