SHA3(3)

✨ SHA3 β€” the girlies are hashing ✨

okay so bestie, welcome to SHA3(3) πŸ’– this is the manual page for the SHA-3 crew, and it's giving NIST FIPS PUB 202: SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions. yes that's the whole official name, we don't abbreviate royalty πŸ‘‘


πŸ“š LIBRARY

Message Digest (MD4, MD5, etc.) Support Library β€” aka libmd, link it with -lmd 🫢


🌸 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);

like look at that list. four flavours, all iconic, no notes πŸ’…


πŸ¦‹ DESCRIPTION

so the SHA3 functions implement the cryptographic hash functions of the NIST SHA-3 standard, FIPS PUB 202 ✨ what do they do tho? they compress an arbitrary-length message m into short fixed-length octet strings β€” SHA3-224(m), SHA3-256(m), etc. β€” and that output is called a cryptographic digest or hash. no cap, that's the whole vibe: you put in literally any amount of message, you get out a cute little fixed-size fingerprint 🫢

⚠️ okay important bestie, listen: before using the SHA3 functions, applications should first call SHA3_Selftest(3) and confirm that it succeeded. do the vibe check first, fr fr πŸ™ˆ

ngl, only the SHA3_256 functions are specified in detail here β€” the SHA3_224, SHA3_384, and SHA3_512 functions are exactly analogous. same energy, different digest size, iykyk πŸ’–

the caller has to allocate memory for a SHA3_256_CTX object to hold the state of a SHA3-256 hash computation over a message. and here's the fun part: SHA3_256_CTX objects are slightly over 200 bytes, and they may be copied or relocated in memory 🌈 like they're chill, they travel well, main character energy honestly.

SHA3_256_Init(ctx) : Initialize a SHA3-256 context. must be done before any other operations on ctx. no skipping, it's the first step, periodt πŸ‘‘

SHA3_256_Update(ctx, data, len) : Append len octets at data to the message. feed it, feed it, feed it πŸ“

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.

🚨 and then: subsequent use of ctx is not allowed, unless it is reinitialized with SHA3_256_Init(). like it's done, it's retired, it said what it said. reinit or leave it alone bestie πŸ’€

πŸ‘€ SEE ALSO

go read those too, the lore is deep 🧚


⭐ STANDARDS

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


πŸ’œ AUTHORS

Taylor R Campbell <campbell+sha3@mumble.net> β€” thank you king, we appreciate you 🫢


okay and the cute sign-off: this page came from the Debian crew, dated October 14, 2015, and yeah it's SHA3(3) the whole way down πŸ’… bye bestie, go hash something responsibly 🌸

πŸ“¦ where this page comes from