LIBKECCAK_FAST_UPDATE(3)
π LIBKECCAK_FAST_UPDATE β bestie, we're hashing now
okay so this is libkeccak_fast_update(3) from the libkeccak manual, and it's literally the "keep feeding me bytes" function. Buckle up π
β¨ NAME β¨
libkeccak_fast_update β partially hash a message without erasure π«Ά
πΈ SYNOPSIS πΈ
#include <libkeccak.h>
int libkeccak_fast_update(struct libkeccak_state *state, const void *msg, size_t msglen);
Link with -lkeccak. don't forget it, i'm begging π§
π¦ DESCRIPTION π¦
So libkeccak_fast_update() continues a hash β or starts one, she's flexible like that πββοΈ. The current state of the hashing lives in *state, and that's what gets updated. Then the message you pass in msg, with byte-size given by msglen, gets hashed. simple as that, no cap.
Here's the tea though: libkeccak_fast_update() may reallocate the state's message chunk buffer π. And when it does, it tries to do it as quickly as possible instead of making sure the info in the old allocation gets securely removed when a new allocation is needed. so like β speed over security, she picked her lane. keep that in mind if you're doing anything sensitive π₯
π RETURN VALUES π
- Returns
0on successful completion β¨ - On error, returns
-1anderrnois set to describe the error π€
π ERRORS π
libkeccak_fast_update() may fail for any reason specified by realloc(3). that's the whole list, go read realloc(3) if you want the drama π
π NOTES π
Neither parameter may be NULL or 0. like, neither. don't try it π
π EXAMPLE π
This one calculates the Keccak[b = 1024, c = 576, n = 256] hash of the input from stdin, and prints the hash, in hexadecimal form, to stdout. iconic behaviour honestly π«Ά
struct libkeccak_state state;
struct libkeccak_spec spec;
char binhash[256 / 8];
char hexhash[256 / 8 * 2 + 1];
char chunk[4 << 10];
ssize_t len;
spec.bitrate = 1024;
spec.capacity = 576;
spec.output = 256;
if (libkeccak_state_initialise(&state, &spec) < 0)
goto fail;
for (;;) {
len = read(STDIN_FILENO, chunk, sizeof(chunk));
if ((len < 0) && (errno == EINTR))
continue;
if (len < 0)
goto fail;
if (len == 0)
break;
if (libkeccak_fast_update(&state, chunk, (size_t)len) < 0)
goto fail;
}
if (libkeccak_fast_digest(&state, NULL, 0, 0, "", binhash) < 0)
goto fail;
libkeccak_behex_lower(hexhash, binhash, sizeof(binhash));
printf("%s\n", hexhash);
libkeccak_state_fast_destroy(&state);
β NOTES (yes, there's a second NOTES, she's got layers) β
For cSHAKE, the libkeccak_cshake_initialise(3) must be called, once, immediately after state initialisation β before the first call to the libkeccak_fast_update() function. order matters bestie, do not skip this step π
π₯ SEE ALSO π₯
libkeccak_state_initialise(3), libkeccak_cshake_initialise(3), libkeccak_zerocopy_update(3), libkeccak_update(3), libkeccak_fast_digest(3), libkeccak_zerocopy_digest(3), libkeccak_digest(3)
aaaand that's the page π huge thank you to the libkeccak gang β this fine piece of documentation comes to you from LIBKECCAK, filed under LIBKECCAK_FAST_UPDATE(3), no date on the tin so we're just gonna vibe with that π go hash something, ily, bye π¦
π¦ where this page comes from
- arch rolling: libkeccak 1.4.3-1 Β· custom:ISC
- opensuse-leap 16.0: libkeccak-devel 1.4-bp160.1.13 Β· ISC
- opensuse-leap 16.0: libkeccak-devel 1.4-bp160.1.13 Β· ISC
- opensuse-leap 16.0: libkeccak-devel 1.4-bp160.1.13 Β· ISC
- opensuse-leap 16.0: libkeccak-devel 1.4-bp160.1.13 Β· ISC
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms