KCAPI_MD_SHA256(3)

πŸ’– NAME πŸ’–

kcapi_md_sha256 β€” SHA-256 message digest on one buffer ✨

okay so bestie, this is a one-shot situation, meaning you hand it a buffer, it hands you back the SHA-256 digest, and nobody has to talk about streaming state or whatever. it's giving "get in, hash, get out" πŸ’… (also, the manual page is KCAPI_MD_SHA256(3), in case you were wondering which page you landed on πŸŽ€)


🌸 SYNOPSIS 🌸

ssize_t kcapi_md_sha256(const uint8_t * in, size_t inlen, uint8_t * out,
                        size_t outlen);

like, that's the whole vibe. four arguments, one digest, no cap πŸ”₯


✨ ARGUMENTS ✨

  • in β€” [in] the buffer with your input data, aka the thing you want digested πŸ“
  • inlen β€” [in] how long that input buffer is, fr fr
  • out β€” [out] the buffer where the message digest lands πŸ‘‘
  • outlen β€” [in] length of out, so it knows how much room it's working with

πŸ¦‹ DESCRIPTION πŸ¦‹

With this one-shot convenience function, a message digest of the given buffer is generated. that's it, that's the function, iconic behaviour honestly ✨

heads up bestie: the output buffer must be allocated by the caller and have at least the length of the message digest size for the chosen message digest. we do not allocate it for you. you got this, but like, actually allocate it πŸ’…

and here's the tea on what it hands back β˜•:

  • 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 πŸ’€
not me warning you again: that -ENOMEM case still writes to your buffer β€” just a truncated digest. so don't go treating a partial digest like a full one, okay? read the return value, always 🫢

πŸ’œ AUTHOR πŸ’œ

Stephan Mueller <smueller@chronox.de> β€” Author. shoutout to the main character who wrote this πŸ‘‘


libkcapi Manual 1.5.0, July 2025 β€” that's the version and the date, periodt. take care of yourself and hydrate before you hash πŸ’–πŸ§šπŸŒΈ

πŸ“¦ where this page comes from