KCAPI_PAD_IV(3)

πŸ’– KCAPI_PAD_IV πŸ’–

okay bestie, so this one's from the libkcapi manual, and it's literally just kcapi_pad_iv β€” the girl whose whole job is fixing up your IV so the cipher will actually accept it. no cap.


✨ NAME ✨

kcapi_pad_iv β€” realign the IV as necessary for cipher


🌸 SYNOPSIS 🌸

int kcapi_pad_iv(struct kcapi_handle * handle, const uint8_t * iv,
                 uint32_t ivlen, uint8_t ** newiv, uint32_t * newivlen);

πŸŽ€ ARGUMENTS πŸŽ€

  • handle β€” [in] the cipher handle, your main character 🫢
  • iv β€” [in] the current IV buffer
  • ivlen β€” [in] how long that IV buffer is
  • newiv β€” [out] the buffer of the aligned IV (the glow-up version ✨)
  • newivlen β€” [out] how long the newly aligned IV is

πŸ¦‹ DESCRIPTION πŸ¦‹

so the way this works is: the function pads the least significant bits of the IV you handed it with zeros, all the way up to the block size of the cipher. cute, right?

and if your IV is longer than the block size? not me being extra β€” the least significant bits just get truncated down to the block size. periodt.

πŸ’… the function allocates memory for newiv when the return code says success. the consumer must free that memory after use. yes, that means you. don't leave her hanging.

it returns 0 for success, or a negative errno-style error code if something went wrong 😭


πŸ‘‘ AUTHOR πŸ‘‘

Stephan Mueller <smueller@chronox.de> Author.


that's the whole thing, bestie β€” libkcapi Manual 1.5.0, dated July 2025, and the page is KCAPI_PAD_IV(3). slay, go free your memory now 🌈⭐

πŸ“¦ where this page comes from