KCAPI_CIPHER_SETKEY(3)

✨ NAME ✨

kcapi_cipher_setkey β€” bestie, this is the one that sets the key for the cipher handle πŸ”‘


🌸 SYNOPSIS 🌸

int kcapi_cipher_setkey(struct kcapi_handle * handle,
                        const uint8_t * key, uint32_t keylen);

πŸŽ€ ARGUMENTS πŸŽ€

  • handle β€” [in] your cipher handle πŸ’… the little main character you've been working with
  • key β€” [in] the key buffer, aka the actual secret vibes πŸ”
  • keylen β€” [in] how long that key buffer is, in bytes

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so with this function, the caller sets the key for all the encryption or decryption operations that come next. That's it. That's the whole job. Setting the key, slaying, moving on. ✨

And here's the part that lowkey eats: after the caller has provided the key, the caller may securely destroy the key, because it's now maintained by the kernel πŸ‘‘ the kernel's got it from here, bestie, you don't need to hold onto it anymore.

So what does it return, you ask?

  • 0 upon success 🫢
  • but wait β€” in the case of an akcipher handle, a positive integer is returned instead, and that number denominates the maximum output size of the cryptographic operation πŸ“ this value must be used as the size of the output buffer for one cryptographic operation. No cap, do not skip this step.
  • and if something goes wrong, you get a negative errno-style error code 😭
fr fr, remember that akcipher exception β€” it's giving "success but with homework" and you cannot ignore the homework πŸ’€

πŸ’œ AUTHOR πŸ’œ

Stephan Mueller <smueller@chronox.de> Author. 🫑 iconic of him honestly



and that's the whole page bestie, ty for coming to my ted talk πŸ’– this was the libkcapi Manual, version 1.5.0, from July 2025, and the page itself is KCAPI_CIPHER_SETKEY(3) β€” go set some keys and stay hydrated 🧚✨

πŸ“¦ where this page comes from