KCAPI_MD_DIGEST(3)

πŸ’– kcapi_md_digest β€” calculate message digest on buffer (one-shot)

okay bestie, welcome to the libkcapi manual, page kcapi_md_digest(3) πŸ’… this one's the one-shot digest glow-up β€” no streaming, no drip-feeding bytes, just one call and boom, hash. let's get into it 🫢


✨ SYNOPSIS ✨

ssize_t kcapi_md_digest(struct kcapi_handle * handle,
                        const uint8_t * in, size_t inlen, uint8_t * out,
                        size_t outlen);

that's the whole vibe, fr fr 🌸


πŸŽ€ ARGUMENTS πŸŽ€

  • handle β€” [in] the cipher handle, your main character πŸ”‘
  • in β€” [in] buffer with the input data, aka the stuff you want hashed
  • inlen β€” [in] length of the input buffer, tell her how much she's working with
  • out β€” [out] buffer for the message digest β€” yes it's an out, she gets written into πŸ’–
  • outlen β€” [in] length of out

🌈 DESCRIPTION 🌈

so with this one-shot function, a message digest of the given buffer gets generated. literally one call, one digest, no notes πŸ‘‘

the output buffer must be allocated by the caller β€” that's on you, bestie, not on the library πŸ™ˆ β€” and it has to have at least the length of the message digest size for whichever message digest you chose. undersized buffer? we'll get to that, and it's giving ✨truncated✨.

the message digest handle must have been initialized, potentially by also setting the key using the generic message digest API functions. no init, no digest, that's the rule πŸ’…

also the input buffer can be at most INT_MAX in size. that's the ceiling, periodt.

and here's the return tea β˜•:

  • return size of message digest upon success πŸŽ‰
  • -EIO β€” data cannot be obtained 😭
  • -ENOMEM β€” buffer is too small for the complete message digest, and the buffer is filled with the truncated message digest πŸ’€
bestie warning fr fr: that -ENOMEM case isn't just an error, it's also an action. your out buffer gets stuffed with a truncated message digest. so you get a partial digest AND an error code. iconic behaviour, honestly. check your sizes before you call this, i am begging 🫢

πŸ‘‘ AUTHOR πŸ‘‘

  • Stephan Mueller <smueller@chronox.de>
    • Author.

that's the page, bestie!! this was the libkcapi Manual, version 1.5.0, dated July 2025 β€” kcapi_md_digest(3), no cap. go hash something and slay πŸ’…βœ¨πŸ¦‹πŸŒΈπŸŽ€

πŸ“¦ where this page comes from