KCAPI_AKCIPHER_ENCRY(3)

✨ KCAPI_AKCIPHER_ENCRY ✨

okay bestie, welcome to kcapi_akcipher_encrypt(3) from the libkcapi Manual πŸ’– this one is giving crypto main character energy and honestly? we're obsessed.


🌸 NAME 🌸

kcapi_akcipher_encrypt β€” encrypt data πŸ”βœ¨


πŸŽ€ SYNOPSIS πŸŽ€

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

πŸ’… ARGUMENTS πŸ’…

  • handle β€” [in] the cipher handle, aka ur little crypto bestie 🫢
  • in β€” [in] the plaintext data buffer, the tea before it gets scrambled β˜•
  • inlen β€” [in] how long the in buffer is πŸ“
  • out β€” [out] the ciphertext data buffer, where the scrambled tea goes πŸŒ€
  • outlen β€” [in] how long the out buffer is πŸ“
  • access β€” [in] the kernel access type. and bestie, u have options πŸ‘‘:
    • KCAPI_ACCESS_HEURISTIC β€” uses the internal heuristic to snag the fastest kernel access, lowkey iconic
    • KCAPI_ACCESS_VMSPLICE β€” uses vmsplice access
    • KCAPI_ACCESS_SENDMSG β€” uses sendmsg access

πŸ¦‹ DESCRIPTION πŸ¦‹

not me about to tell u the coolest part first: it is perfectly legal to pass the same buffer as both the plaintext and the ciphertext pointers πŸ’€βœ¨ like literally the same pointer. and if u do that? after the encryption operation, ur plaintext gets overwritten with the ciphertext. gone. replaced. slay but also be aware πŸ’…

now, the memory. it should be aligned at the page boundary using posix_memalign(sysconf(_SC_PAGESIZE)). and if it is not aligned at the page boundary, the vmsplice call may not send all data to the kernel 😭 so like, align it, bestie, it's not that deep.

if the output size is insufficiently large, -EINVAL is returned 🚫 the output buffer must be at least as large as the modululs of the uses key. periodt.

and the return situation, since i know u were wondering: on success u get the number of bytes returned by the encryption operation πŸŽ‰ and if something went wrong, u get a negative errno-style error code instead πŸ™ˆ


πŸ‘‘ AUTHOR πŸ‘‘

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


that's the whole vibe, bestie β€” this was libkcapi Manual version 1.5.0, dated July 2025, and yes the manual page itself is literally named KCAPI_AKCIPHER_ENCRY(3) πŸŒˆπŸ’– go encrypt something iconic, ily, bye ✨

πŸ“¦ where this page comes from