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