LIBKECCAK_SPEC_CHECK(3)
π LIBKECCAK_SPEC_CHECK(3) β validate hashing parameters π
okay so bestie, welcome to the Library Functions Manual page for libkeccak_spec_check β aka the vibe check for your Keccak spec π this is LIBKECCAK_SPEC_CHECK(3), and we're about to make sure your hashing parameters are not a chaotic mess.
πΈ NAME πΈ
libkeccak_spec_check β validate hashing parameters. That's the whole name, no cap: it checks whether your spec is usable before you send it into the wild π¦
β¨ SYNOPSIS β¨
#include <libkeccak.h>
int libkeccak_spec_check(const struct libkeccak_spec *spec);
Link with -lkeccak. π«Ά
π DESCRIPTION π
The libkeccak_spec_check() function validates the parameters of *spec, so that unusable configurations can be detected. It is recommended to call this function after calling libkeccak_spec_sha3(3), libkeccak_spec_cshake(3), libkeccak_spec_rawshake(3), libkeccak_spec_shake(3), or, especially, after setting the parameters manually for Keccak hashing. Basically: don't just yolo your custom values, let this icon do a quick check first π
Here's the struct in question:
struct libkeccak_spec {
long int bitrate; /* bitrate (in bits) */
long int capacity; /* capacity (in bits) */
long int output; /* output size (in bits) */
};
π₯ RETURN VALUES π₯
The libkeccak_spec_check() function returns 0 if the settings are usable. Otherwise it will return one of the following constants. Like, it's giving error-code menu π
LIBKECCAK_SPEC_ERROR_BITRATE_NONPOSITIVEβ the specified bitrate was non-positive.LIBKECCAK_SPEC_ERROR_BITRATE_MOD_8β the specified bitrate was not equivalent to 0 modulus 8, that is, it was not in whole bytes.LIBKECCAK_SPEC_ERROR_CAPACITY_NONPOSITIVEβ the specified capacity was non-positive.LIBKECCAK_SPEC_ERROR_CAPACITY_MOD_8β the specified capacity was not equivalent to 0 modulus 8, that is, it was not in whole bytes.LIBKECCAK_SPEC_ERROR_OUTPUT_NONPOSITIVEβ the specified output size was non-positive.LIBKECCAK_SPEC_ERROR_STATE_TOO_LARGEβ the state size, that is the sum of the bitrate and the capacity, exceeded the supported limit (currently at 1600 bits).LIBKECCAK_SPEC_ERROR_STATE_MOD_25β the state size, that is the sum of the bitrate and the capacity, in bits, was not equivalent to 0 modulus 25. Meaning the state size cannot cover all lanes equivalently.LIBKECCAK_SPEC_ERROR_WORD_NON_2_POTENTβ the word size, that is the state size divided by 25, is not a power of 2.LIBKECCAK_SPEC_ERROR_WORD_MOD_8β the word size, that is the state size divided by 25, is not equivalent to 0 modulus 8, that is, it is not in whole bytes.
Note that there may be more than one error. Only the first detected is returned. So yes, it's a "first problem wins" situation, no cap π
π ERRORS π
The libkeccak_spec_check() function cannot fail. Literally. It's just built different π
π¦ SEE ALSO π¦
libkeccak_spec_sha3(3)libkeccak_spec_cshake(3)libkeccak_spec_rawshake(3)libkeccak_spec_shake(3)libkeccak_generalised_spec_initialise(3)libkeccak_state_initialise(3)libkeccak_hmac_initialise(3)
xoxo, your LIBKECCAK bestie π this was LIBKECCAK_SPEC_CHECK(3) from the Library Functions Manual β source/version LIBKECCAK, page LIBKECCAK_SPEC_CHECK(3), and the footer didn't show a date so we're not making one up, 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