KCAPI_CIPHER_ENC_AES(3)

πŸ’– KCAPI_CIPHER_ENC_AES(3) β€” the aes-ctr encryption glow-up πŸ’–

okay bestie, gather round, because we're talking about kcapi_cipher_enc_aes_ctr from the libkcapi manual, and honestly? she's a whole convenience queen. πŸ‘‘


✨ NAME ✨

kcapi_cipher_enc_aes_ctr β€” the convenience function for AES CTR encryption. no cap, that's literally her whole job. πŸŽ€


🌸 SYNOPSIS 🌸

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

πŸ¦‹ ARGUMENTS πŸ¦‹

she takes six things and every single one matters, so pay attention bestie:

  • key β€” [in] the key buffer. your whole secret vibe lives here. πŸ”
  • keylen β€” [in] length of the key buffer. yes we need this, don't be weird about it.
  • in β€” [in] plaintext data buffer. this is the tea before it gets scrambled. πŸ“
  • inlen β€” [in] length of the in buffer.
  • ctr β€” [in] the start counter value that gets used for the cipher operation. ⭐
  • out β€” [out] ciphertext data buffer. this is where the encrypted icon behavior lands. ✨
  • outlen β€” [in] length of the out buffer.

πŸ’… DESCRIPTION πŸ’…

so the convenience function does an AES counter mode encryption operation, using the key you gave her, the input buffer you gave her, and the IV you gave her. the output gets stored in the out buffer. simple. iconic. periodt. πŸ’–

the input buffer can be of arbitrary length. go off, honestly. 🌈

the output buffer must be at least as large as the input buffer. no shrinking allowed, she's not that kind of function. πŸ™ˆ

the start counter can contain all zeros β€” and bestie, listen, that is not a NULL buffer! β€” and it must be exactly 16 bytes in size. not 15, not 17. sixteen. exactly. πŸ’€

the AES type (AES-128, AES-192 or AES-256) is determined by the size of the key you hand over:

  • if the key is 16 bytes long, AES-128 is used.
  • a 24 byte key implies AES-192.
  • a 32 byte key implies AES-256.

and the return value? it's giving: number of bytes generated upon success. and if something went wrong, you get a negative errno-style error code. 😭

lowkey important: the return is the byte count on success and a negative errno-style error code on failure. don't mix those two up, i'm begging. 🫢

πŸ‘‘ AUTHOR πŸ‘‘

Stephan Mueller <smueller@chronox.de>

  • Author. yes, the author. we stan. πŸ’œ

that's the whole page, bestie β€” courtesy of the libkcapi Manual 1.5.0, dated July 2025, and you can find her filed under KCAPI_CIPHER_ENC_AES(3). slay, encrypt responsibly, and remember: exactly 16 bytes of counter. mwah. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from