KCAPI_MD_HMAC_SHA256(3)

πŸ’– kcapi_md_hmac_sha256 β€” the manual page, but make it cute ✨

okay so bestie, welcome to section 3 of the manual (that's the library-calls girlies πŸ’…), and today's main character is kcapi_md_hmac_sha256. say it with me: HMAC SHA-256, keyed message digest, one buffer, zero drama. no cap 🫢


🌸 NAME 🌸

kcapi_md_hmac_sha256 β€” HMAC SHA-256 keyed message digest on one buffer

like… that's it. that's the whole vibe. a keyed message digest, one single buffer, done in one shot. iconic behavior fr fr πŸ”₯


✨ SYNOPSIS ✨

ssize_t kcapi_md_hmac_sha256(const uint8_t * key, uint32_t keylen,
                             const uint8_t * in, size_t inlen,
                             uint8_t * out, size_t outlen);

look at her. six arguments. she's giving very "I know what I'm doing" πŸ’… copy it exactly, don't get creative with the types, the compiler will not be forgiving and neither will I 😭


πŸŽ€ ARGUMENTS πŸŽ€

  • key β€” [in] the buffer holding your HMAC key. the secret. the sauce. protect her 🫢
  • keylen β€” [in] how long that HMAC key buffer is. uint32_t, so, like, don't go wild.
  • in β€” [in] the buffer with your input data. the thing getting digested, bestie.
  • inlen β€” [in] length of the input buffer.
  • out β€” [out] the buffer where the message digest lands. it's yours to allocate, nobody's doing it for you πŸ’–
  • outlen β€” [in] length of out.

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜• β€” this is a one-shot convenience function. one call, one keyed message digest, generated from the buffer you handed over. no init, no update, no final, none of that multi-step situationship. just here's my data, here's my key, gimme the digest ✨

⚠️ important, and I mean this with my whole chest: the output buffer must be allocated by the caller and it has to be at least the length of the message digest size for the chosen keyed message digest. nobody is malloc-ing that for you. that's a you task, bestie πŸ™ˆ

and now the return value, because she has opinions:

  • return size of message digest upon success πŸŽ‰ slay.
  • -EIO β€” data cannot be obtained 😭
  • -ENOMEM β€” buffer is too small for the complete message digest… and here's the wild part: the buffer is filled with the truncated message digest. so you get a little half-digest situation. it's giving "partial credit" πŸ’€

πŸ‘‘ AUTHOR πŸ‘‘

Stephan Mueller <smueller@chronox.de> Author.

the literal author. the icon. the blueprint. we stan 🌈


that's the whole page, bestie β€” go forth and HMAC responsibly 🧚

libkcapi Manual 1.5.0 Β· July 2025 Β· KCAPI_MD_HMAC_SHA256(3)

periodt. πŸ’…πŸŒΈβœ¨

πŸ“¦ where this page comes from