SHA3_SELFTEST(3)
π SHA3_SELFTEST π
okay bestie, gather round, because this is SHA3_Selftest from section 3 of the manual β yes, the Library Functions Manual one, the little function that goes "hey, is the crypto actually working or are we all just vibing in the dark" π¦
β¨ NAME β¨
SHA3_Selftest β the whole NIST FIPS PUB 202 situation: SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions. that's the full name, no cap, I'm not shortening it π
π LIBRARY π
Message Digest (MD4, MD5, etc.) Support Library β aka libmd, and you link it with -lmd. that's your ride, bestie π
β¨ SYNOPSIS β¨
#include <sha3.h>
int
SHA3_Selftest(void);
that's it. that's the whole vibe. no arguments, just vibes and a return value πΈ
π DESCRIPTION π
okay so here's the tea π β SHA3_Selftest automatically tests a bunch of SHA-3 computations on fixed inputs with known outputs, just to make sure the sha3(3) library is not catastrophically broken. like, it's the vibe check for your hash function. and honestly? iconic.
not me using "catastrophically broken" as the bar, but that's literally what the manpage says and I respect the honesty π
Applications should call SHA3_Selftest() and confirm that it succeeded before using the sha3(3) or shake(3) functions. yes, before. not after. before. do it first, bestie, please π
SHA3_Selftest() returns 0 if successful, or -1 if the self-test failed. that's it, that's the whole result code situation β 0 good, -1 bad, no in-between main character nonsense π
now, the cost. and bestie, it's not free πΈ β SHA3_Selftest() costs a few hundred thousand cycles on most CPUs. why? because it involves a little over a hundred calls to the Keccak permutation, and those usually take one or two thousand cycles each. so yeah, it's doing a lot. it's giving thorough. it's giving I checked everything. respect β¨
π SEE ALSO π
go read those next, they're the whole reason this little test exists π«Ά
π STANDARDS π
National Institute of Standards and Technology, SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions, August 2015, FIPS PUB 202. the official document, the source material, the blueprint πβ¨
π AUTHORS π
Taylor R Campbell <campbell+sha3@mumble.net> β thank you for your service, legend π«‘π
and that's the whole page, bestie!! this came to you from the Debian crew, dated October 14, 2015, and yeah it's the SHA3_SELFTEST(3) page β now go call that self-test before you hash anything, I'm literally begging π
πΈβ¨
π¦ where this page comes from
- alpine 3.24: libmd-doc 1.2.0-r0 Β· BSD-3-Clause AND BSD-2-Clause AND ISC AND Beerware AND Public Domain
- arch rolling: libmd 1.3.0-1 Β· BSD-3-Clause AND BSD-2-Clause AND ISC AND Beerware AND CC-PDM-1.0
- epel 10: libmd-devel 1.3.0-1.el10_3 Β· BSD-2-Clause AND BSD-3-Clause AND ISC AND Beerware AND LicenseRef-Fedora-Public-Domain
- epel 9: libmd-devel 1.3.0-1.el9 Β· BSD-2-Clause AND BSD-3-Clause AND ISC AND Beerware AND LicenseRef-Fedora-Public-Domain
- fedora 43: libmd-devel 1.2.0-1.fc43
- fedora 43: libmd-devel 1.2.0-1.fc43
- fedora 43: libmd-devel 1.3.0-1.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND ISC AND Beerware AND LicenseRef-Fedora-Public-Domain
- fedora 43: libmd-devel 1.3.0-1.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND ISC AND Beerware AND LicenseRef-Fedora-Public-Domain
- fedora 44: libmd-devel 1.3.0-1.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND ISC AND Beerware AND LicenseRef-Fedora-Public-Domain
- fedora 44: libmd-devel 1.3.0-1.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND ISC AND Beerware AND LicenseRef-Fedora-Public-Domain
- nixpkgs unstable: libmd 1.3.0
- ubuntu stonking: libmd-dev 1.2.0-2
- Copyright (c) 2015 Taylor R. Campbell
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms