SHAKE(3)

πŸ’– SHAKE(3) β€” like, the manual page for the SHAKE functions πŸ’–

okay bestie, sit down, hydrate, and let me tell you about SHAKE β€” it's a real one from the Message Digest (MD4, MD5, etc.) Support Library (that's libmd, link it with -lmd) ✨

No cap, this is the page for the functions that do NIST FIPS PUB 202: SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions. Say that five times fast, I dare you 🫢


πŸ¦‹ LIBRARY πŸ¦‹

Message Digest (MD4, MD5, etc.) Support Library β€” that's libmd, and you link it with -lmd. periodt πŸ’…


✨ SYNOPSIS ✨

#include <sha3.h>

void
SHAKE128_Init(SHAKE128_CTX *ctx);

void
SHAKE128_Update(SHAKE128_CTX *ctx, const uint8_t *buf, size_t len);

void
SHAKE128_Final(uint8_t *output[], size_t outlen, SHAKE128_CTX *ctx);

void
SHAKE256_Init(SHAKE256_CTX *ctx);

void
SHAKE256_Update(SHAKE256_CTX *ctx, const uint8_t *buf, size_t len);

void
SHAKE256_Final(uint8_t *output[], size_t outlen, SHAKE256_CTX *ctx);

🌸 DESCRIPTION 🌸

So the SHAKE functions are the extendable-output functions from the NIST SHA-3 standard, FIPS PUB 202. The whole vibe is: you absorb an arbitrary-length message m, and you get back an arbitrary-length output β€” either SHAKE128(m) or SHAKE256(m) β€” truncated to a specified number of octets. Arbitrary in, arbitrary out, that's the whole point, iconic behavior fr fr πŸ”₯

Heads up bestie: before you touch the SHAKE functions, your app should first call SHA3_Selftest(3) and confirm that it succeeded. Do not skip this. It's giving "safety check before the main character moment" πŸ’€

Only the SHAKE128 functions are specified in detail here β€” the SHAKE256 functions are analogous. (Same energy, different number, iykyk 🌈)

The caller must allocate memory for a SHAKE128_CTX object to hold the state of a SHAKE128 computation over a message. And here's the cute part: SHAKE128_CTX objects may be copied or relocated in memory. Slay, they're portable like that πŸŽ€

🧚 SHAKE128_Init(ctx)

Initialize a SHAKE128 context. This must be done before any other operations on ctx. Like, no exceptions, no shortcuts, do it first πŸ’–

🧚 SHAKE128_Update(ctx, data, len)

Append len octets at data to the message. Just keep feeding it, it's hungry, it can take as much as you've got πŸ“

🧚 SHAKE128_Final(output, outlen, ctx)

Store at output the first outlen octets of the SHAKE128 output for the message obtained by concatenating all prior inputs to SHAKE128_Update() on ctx. This is the moment, the finale, the main character walk-off πŸ‘‘

okay so listen: subsequent use of ctx is not allowed after this, unless it is reinitialized with SHAKE128_Init(). No zombie contexts, we don't do that here πŸ™ˆ

πŸ‘€ SEE ALSO πŸ‘€

go read those too, bestie, it's a whole ecosystem πŸ¦‹


⭐ STANDARDS ⭐

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


πŸ’œ AUTHORS πŸ’œ

Taylor R Campbell <campbell+sha3@mumble.net> β€” thank you for your service, king πŸ«ΆπŸ‘‘


and that's the tea! this page came to you from Debian, dated October 14, 2015, and it lives at SHAKE(3) in the manual. mwah, go hash something cute πŸ’…πŸ’–πŸŒˆ

πŸ“¦ where this page comes from