KCAPI_KPP_SETKEY(3)
β¨ NAME β¨
kcapi_kpp_setkey β bestie, this is the one that sets the private key for your DH / ECDH moment π
πΈ SYNOPSIS πΈ
int kcapi_kpp_setkey(struct kcapi_handle * handle, const uint8_t * key,
uint32_t keylen);
π ARGUMENTS π
handleβ [in] the cipher handle, aka the lil passport your cipher carries around π«Άkeyβ [in] the key buffer, the actual key vibes go in here πkeylenβ [in] length of that key buffer, how many bytes we're talking π
π DESCRIPTION π
okay so. with this function, you β the caller β set the key for the DH / ECDH public key generation or shared secret generation operations that come after. like, you're handing the kernel the key and being like "here bestie, hold this" β¨
and here's the iconic part: if the key / keylen is zero, the kernel tries to generate the private key itself and retains it internally. it's giving main character energy, honestly. this is useful when the DH / ECDH operation shall be performed on ephemeral keys where you're only interested in eventually obtaining the shared secret. you don't even need to know the key, you just want the tea at the end π΅
once you've provided the key, you may securely destroy the key, because it is now maintained by the kernel. no cap, it's out of your hands, you can let it go π
but lowkey important: the key can only be set after the DH parameters or the ECC curve has been set. do not skip ahead, that's not the vibe π
so what do you get back? in case of success, a positive integer is returned that denominates the maximum output size of the cryptographic operation β and this value must be used as the size of the output buffer for one cryptographic operation. yes, literally, use it, don't be cute about it. a negative errno-style error code comes back if an error occurred β and the error -EOPNOTSUPP is returned in case a kernel-triggered private key generation is requested, but the underlying cipher implementation does not support this operation. so if you asked the kernel to generate the key for you and it said "not supported", that's the code you'll be staring at π
π AUTHOR π
Stephan Mueller <smueller@chronox.de>
- Author. that's the icon, that's the legend π«Ά
π COPYRIGHT π
libkcapi Manual 1.5.0 β July 2025 πΈ
and that's the whole page, bestie!! thank you for reading the KCAPI_KPP_SETKEY(3) manual with me, go set those keys responsibly, secure-destroy them after, and remember: set the DH params or ECC curve FIRST. mwah πππ¦
π¦ 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