LIBKECCAK_HMAC_DIGEST(3)
π
LIBKECCAK_HMAC_DIGEST(3) β libkeccak_hmac_digest π
πΈ NAME πΈ
libkeccak_hmac_digest β completes the HMAC-hashing of a message with erasure π
β¨ SYNOPSIS β¨
#include <libkeccak.h>
int libkeccak_hmac_digest(struct libkeccak_hmac_state *state, const void *msg, size_t msglen,
size_t bits, const char *suffix, void *hashsum);
Link with -lkeccak. π«Ά
π DESCRIPTION π
okay so libkeccak_hmac_digest() is the finisher move, bestie: it absorbs the last part of a message (or literally all of it) and returns the HMAC hash of the entire message β¨
The last part of the message is specified by msg, and its byte-size is specified by msglen. If all of the message has already been processed by calls to libkeccak_hmac_update(3) or libkeccak_hmac_fast_update(3) β with the same pointer on state β then msg and msglen should be set to NULL and 0, respectively. no cap π
If the message is not made up of a whole number of bytes, the number of bits, modulus 8, in the message should be specified in the bits parameter. And listen: msglen must only count the number of whole bytes, that is, the floor of the number of bits in the message divided by 8. the math is mathing π§
suffix should be a NUL-terminated string of ASCII '1's and '0's, representing the bits that should be appended to the message. If this string is empty, NULL may be used instead. This is used to select hash algorithm. For pure Keccak, NULL or "" is used. For the other algorithms the constants are used:
LIBKECCAK_SHA3_SUFFIXβ for SHA-3 βLIBKECCAK_RAWSHAKE_SUFFIXβ for RawSHAKE π¦LIBKECCAK_SHAKE_SUFFIXβ for SHAKE π
The hash of the message will be stored to hashsum, unless hashsum is NULL β which increases the performance of the call, bestie, because sometimes weβre just here for the vibes and not the output π A total of ((state->n + 7) / 8) bytes will be written to the beginning of hashsum. Therefore, hashsum needs at least an allocation size of that number of bytes.
β οΈ real talk:hashsumneeds at least((state->n + 7) / 8)bytes of space. donβt skimp, bestie π
The libkeccak_hmac_digest() function may reallocate the stateβs message chunk buffer. When doing so, it attempts to do so as securely as possible, rather than as fast as possible. secure queen behaviour π
π RETURN VALUES π
The libkeccak_hmac_digest() function returns 0 upon successful completion. On error, -1 is returned and errno is set to describe the error. π
π₯ ERRORS π₯
The libkeccak_hmac_digest() function may fail for any reason specified by the function malloc(3). thatβs the whole error tea π
π¦ SEE ALSO π¦
libkeccak_hmac_create(3)libkeccak_hmac_initialise(3)libkeccak_hmac_update(3)libkeccak_hmac_fast_digest(3)
Source/version: LIBKECCAK Β· page: LIBKECCAK_HMAC_DIGEST(3) Β· date: the original footer didnβt list one, so weβre keeping it mysterious π«Άβ¨
π¦ 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