KCAPI_AEAD_DECRYPT(3)
πΈ NAME πΈ
kcapi_aead_decrypt β bestie, this is the one that synchronously decrypts your AEAD data in a single shot. one and done, no cap β¨
β¨ SYNOPSIS β¨
ssize_t kcapi_aead_decrypt(struct kcapi_handle * handle,
const uint8_t * in, size_t inlen,
const uint8_t * iv, uint8_t * out,
size_t outlen, int access);
π ARGUMENTS π
handleβ [in] your cipher handle, the main character of this whole operation πinβ [in] the ciphertext data buffer, aka the locked little secret we're about to crack openinlenβ [in] how long theinbuffer isivβ [in] the IV that gets used for the cipher operationoutβ [out] the plaintext data buffer, where the truth comes out π¦outlenβ [in] how long theoutbuffer isaccessβ [in] the kernel access type, pick your fighter:KCAPI_ACCESS_HEURISTICβ use the internal heuristic to find the fastest kernel access π₯KCAPI_ACCESS_VMSPLICEβ use vmsplice accessKCAPI_ACCESS_SENDMSGβ use sendmsg access
π DESCRIPTION π
okay so, AEAD is not like the other ciphers β it wants its associated authentication data, like it literally requires you to furnish it. and if you don't need that data at all? no problem, set it to NULL and the length value must be set to zero. that's the rule, periodt.
and here's the gag: it is perfectly legal to use the same buffer for both the plaintext and the ciphertext pointers. so what that means is β after the encryption operation, the ciphertext is overwritten with the plaintext. same buffer, glow-up complete π«
now, the memory? it should be aligned at the page boundary using posix_memalign(sysconf(_SC_PAGESIZE)). because if it's not aligned at the page boundary, the vmsplice call may not send all of your data to the kernel. and we do NOT want half your data just ghosting the kernel, bestie π
also the iv buffer must be exactly kcapi_cipher_ivsize bytes in size. exactly. not a byte more, not a byte less, iykyk.
and to catch authentication errors (aka integrity violations, the sneaky ones) during decryption, you gotta check the return value of this call. if this function returns -EBADMSG, an authentication error was detected. that's your red flag, do not ignore it π©
π IMPORTANT NOTE π
the kernel will only processsysconf(_SC_PAGESIZE)*ALG_MAX_PAGESat one time. longer input data cannot be handled by the kernel. like, it literally cannot, so don't try it π
and the return? on success you get the number of bytes decrypted back. if something went wrong, you get a negative errno-style error code instead. that's it, that's the tea π
π AUTHOR π
- Stephan Mueller
<smueller@chronox.de>β Author. we stan π
π COPYRIGHT π
that's the whole page bestie, hope it slayed for you π«Άβ¨ this was the libkcapi Manual, version 1.5.0, dated July 2025 β and that's the vibe check, we're done here π
π¦ 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