KCAPI_CIPHER_ENCRYPT(3)
π kcapi_cipher_encrypt(3) β bestie edition π
okay so, welcome to kcapi_cipher_encrypt(3) from the libkcapi programming interface β¨ this one's your girl for encrypting data, synchronous one-shot style. no drama, no streaming, just one call and we're done. periodt π
β¨ NAME β¨
kcapi_cipher_encrypt β encrypt data (synchronous one shot) π
πΈ SYNOPSIS πΈ
ssize_t kcapi_cipher_encrypt(struct kcapi_handle * handle,
const uint8_t * in, size_t inlen,
const uint8_t * iv, uint8_t * out,
size_t outlen, int access);
like, one function, seven args, and she delivers. π
π ARGUMENTS π
handleβ[in]the cipher handle π«Ά your lil connection to the cipher, bestie.inβ[in]the plaintext data buffer. this is the tea before we encrypt it πinlenβ[in]length ofinbuffer. yes queen, we need to know how big it is.ivβ[in]IV to be used for cipher operation. the initialization vector, iconic behavior only πoutβ[out]ciphertext data buffer. the glow-up version goes here πoutlenβ[in]length ofoutbuffer. don't skip this one, fr fr.accessβ[in]kernel access type, and she's got options πKCAPI_ACCESS_HEURISTICβ use internal heuristic for fastest kernel access (the "let her pick" vibe, main character energy tbh)KCAPI_ACCESS_VMSPLICEβ use vmsplice accessKCAPI_ACCESS_SENDMSGβ sendmsg access
π« DESCRIPTION π«
okay so first things first: it is perfectly legal to use the same buffer as the plaintext and ciphertext pointers π that means after the encryption operation, the plaintext is overwritten with the ciphertext. in-place glow-up, we love to see it. no cap.
now, the memory should be aligned at the page boundary using posix_memalign(sysconf(_SC_PAGESIZE)). and bestie, if it is not aligned at the page boundary, the vmsplice call may not send all data to the kernel π like it'll just leave some of your data behind at the function. not the vibe. please align it.
the IV buffer must be exactly kcapi_cipher_ivsize bytes in size. exactly. not "about that", not "close enough". exactly. π―
and what does she give you back? return number of bytes encrypted upon success β¨ a negative errno-style error code if an error occurred π so like, positive number = slay, negative = we have a problem.
real talk though: that same-buffer trick is legal, but it does overwrite your plaintext. once she's gone, she's gone π plan accordingly.
π¦ AUTHOR π¦
Stephan Mueller <smueller@chronox.de> β Author. the icon who wrote this π
π COPYRIGHT π
part of the libkcapi Manual 1.5.0, dated July 2025 ποΈ
and that's the whole page bestie, go encrypt something and be iconic about it π β¨π¦πΈππ
π¦ where this page comes from
- fedora 43: libkcapi-devel 1.5.0-6.fc43 Β· BSD-3-Clause OR GPL-2.0-only
- fedora 43: libkcapi-devel 1.5.0-6.fc43 Β· BSD-3-Clause OR GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms