KCAPI_CIPHER_ENCRYPT(3)

πŸ’– KCAPI_CIPHER_ENCRYPT(3) πŸ’–

okay bestie, welcome to the Programming Interface section of the libkcapi manual β€” this one's all about kcapi_cipher_encrypt_aio, the async one-shot encryption girlie. she's giving "send your plaintext, get your ciphertext, no drama" and honestly? iconic. let's get into it 🫢


✨ NAME ✨

kcapi_cipher_encrypt_aio β€” encrypt data (asynchronous one shot) πŸ”₯


🌸 SYNOPSIS 🌸

ssize_t kcapi_cipher_encrypt_aio(struct kcapi_handle * handle,
                                 struct iovec * iniov,
                                 struct iovec * outiov, size_t iovlen,
                                 const uint8_t * iv, int access);

πŸŽ€ ARGUMENTS πŸŽ€

  • handle β€” [in] your cipher handle, the main character of this whole operation πŸ’…
  • iniov β€” [in] head of the scatter-gather list array holding the plaintext (the stuff you wanna hide πŸ‘€)
  • outiov β€” [out] head of the scatter-gather list of the destination buffers, which get filled with the ciphertext ✨
  • iovlen β€” [in] number of scatter-gather list entries, bestie. count them.
  • iv β€” [in] the IV to be used for the cipher operation 🌈
  • access β€” [in] kernel access type, and you have three flavors to choose from:
    • KCAPI_ACCESS_HEURISTIC β€” use the internal heuristic for the fastest kernel access πŸƒβ€β™€οΈπŸ’¨
    • KCAPI_ACCESS_VMSPLICE β€” use vmsplice access
    • KCAPI_ACCESS_SENDMSG β€” sendmsg access

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the vibe: each individual scatter-gather list entry gets processed with separate invocations of the given cipher. not one big call β€” separate ones. noted. πŸ’€

Your memory should be aligned at the page boundary using posix_memalign(sysconf(_SC_PAGESIZE)). and like, if it's not aligned at the page boundary, the vmsplice call may not send all data to the kernel β€” so yeah, that's a real one, don't skip it. πŸ™ˆ

Also: the IV buffer must be exactly kcapi_cipher_ivsize bytes in size. not more, not less. periodt.

And what do you get back? the number of bytes encrypted upon success πŸŽ‰ β€” or a negative errno-style error code if an error occurred 😭


πŸ‘‘ AUTHOR πŸ‘‘

Stephan Mueller <smueller@chronox.de> β€” Author.


this one's short and sweet, no cap.

okay that's the whole page, bestie, you ate that πŸ“πŸ§š

libkcapi Manual 1.5.0, July 2025 β€” mwah, take care of her πŸ’–βœ¨

πŸ“¦ where this page comes from