LIBKECCAK_RAWSHAKESUM_FD(3)
π LIBKECCAK_RAWSHAKESUM_FD(3) π
okay bestie, this one is from the Library Functions Manual, and itβs giving βtiny C function, very specific jobβ energy β¨
πΈ NAME πΈ
libkeccak_rawshakesum_fd β Calculate a RawSHAKE hashsum of a file, periodt π
β¨ SYNOPSIS β¨
#include <libkeccak.h>
int libkeccak_rawshakesum_fd(int fd, struct libkeccak_state *state, long int semicapacity, long int output, void *hashsum);
Link with -lkeccak. π«Ά
π DESCRIPTION π
okay so libkeccak_rawshakesum_fd() calculates a RawSHAKE hashsum of a file. The file descriptor is fd, and fr fr it should be at the beginning of the file. π
The hash algorithm is tuned by the semicapacity and output parameters; they specify the half of the capacity and the output size, respectively, in bits:
semicapacityβ half of the capacity, in bits.outputβ output size, in bits.
The hash is stored in binary form to hashsum. hashsum should have an allocation size of at least (((output + 7) / 8) * sizeof(char)). no cap, that formula matters π
β οΈ*stateshould not be initialised.libkeccak_rawshakesum_fd()initialises*stateitself. Therefore there would be a memory leak if*stateis already initialised. bestie please do not pre-initialise it π
π«Ά RETURN VALUES π«Ά
The libkeccak_rawshakesum_fd() function returns 0 upon successful completion. On error, -1 is returned and errno is set to describe the error. simple as that β¨
π ERRORS π
The libkeccak_rawshakesum_fd() function may fail for any reason, except those resulting in errno being set to EINTR, specified for the functions read(2), malloc(3), and realloc(3). thatβs the exception list, iykyk π§
π§ NOTES π§
Be aware, libkeccak_rawshakesum_fd() hashes the file until the end has been reached. For pipes and sockets, this means until the file has been closed. But for character devices, this usually means never. π
β οΈ Attempting to hash files in /dev is therefore usually a bad idea. like, highkey do not do that π
libkeccak_rawshakesum_fd() does not check for the file length or file type before hashing as this could limit what you can do, and make the library more complex. itβs giving βwe trust you, main characterβ energy π¦
libkeccak_rawshakesum_fd() does not stop if interrupted (read(2) returns EINTR.) π«Ά
libkeccak_rawshakesum_fd() assumes all information is non-sensitive, and will therefore not perform any secure erasure of information. π₯
libkeccak_rawshakesum_fd() does not validate the tuning of the algorithm. π
π₯ EXAMPLE π₯
This example calculates the RawSHAKE256(, 512) hash of the input from stdin, and prints the hash, in hexadecimal form, to stdout.
struct libkeccak_state state;
if (libkeccak_rawshakesum_fd(STDIN_FILENO, &state, 256, 512, binhash) < 0)
goto fail;
libkeccak_behex_lower(hexhash, binhash, sizeof(binhash));
printf("%s\n", hexhash);
libkeccak_state_destroy(&state);
slay, thatβs the whole example π
π SEE ALSO π
libkeccak_behex_lower(3)libkeccak_behex_upper(3)libkeccak_generalised_sum_fd(3)libkeccak_keccaksum_fd(3)libkeccak_sha3sum_fd(3)libkeccak_shakesum_fd(3)libkeccak_spec_rawshake(3)libkeccak_spec_check(3)libkeccak_generalised_spec_initialise(3)libkeccak_state_initialise(3)
xoxo, your LIBKECCAK bestie π β source/version vibes: LIBKECCAK; page: LIBKECCAK_RAWSHAKESUM_FD(3); date: the original footer doesnβt give me one, so Iβm not inventing it, periodt π
π¦ 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