LIBKECCAK_HMAC_DIGEST(3)

πŸ“¦ version 1.4.3, in arch rolling, opensuse-leap 16.0

πŸ’… 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: hashsum needs 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 πŸ¦‹


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