KCAPI_CIPHER_STREAM_(3)

πŸ’– NAME πŸ’–

kcapi_cipher_stream_init_enc β€” bestie, this is the one that starts up an encryption operation in stream mode ✨ (and yeah, the page itself lives in section 3 of the manual, KCAPI_CIPHER_STREAM_(3), iykyk πŸŽ€)


πŸ¦‹ SYNOPSIS πŸ¦‹

ssize_t kcapi_cipher_stream_init_enc(struct kcapi_handle * handle,
                                     const uint8_t * iv,
                                     struct iovec * iov, size_t iovlen);

🌸 ARGUMENTS 🌸

okay so here's who's coming to the party πŸ‘‘ every single one of them matters, no skips:

  • handle β€” [in] the cipher handle. your main character, your ride-or-die 🫢
  • iv β€” [in] the IV that's gonna be used for this cipher operation. yes it has to be the right size, we'll get to that πŸ’…
  • iov β€” [in] a scatter/gather list holding the data you wanna encrypt. if you're passing in an actual array of iov entries, this is the pointer to the first one. wanna know how iov is meant to be used? go read sendmsg(2), it's literally right there πŸ“–. and lowkey? this pointer is allowed to be NULL if there's just no data to encrypt yet at the moment you make the call πŸ™ˆ
  • iovlen β€” [in] how many scatter/gather list elements there are. and heads up: if iov is NULL, this value must be zero. not negotiable bestie ⚠️

✨ DESCRIPTION ✨

so this call is what kicks off a stream encryption operation 🌈 once you've done that, you can hit kcapi_cipher_stream_update over and over, one after another, to keep feeding more plaintext in to be encrypted πŸ“

the kernel holds onto your input, just chilling in the buffer, until kcapi_cipher_stream_op comes along and picks up the encrypted data. and the moment that plaintext actually gets encrypted during the kcapi_cipher_stream_op, it's removed from the kernel buffer. gone. bye πŸ’€

the way that you can mix kcapi_cipher_stream_update and kcapi_cipher_stream_op calls together?? iconic. and not just in a single-threaded lil baby program β€” multiple threads of an application can do it too 🧚 the multitasking ate fr fr

⚠️ okay important one: the IV buffer must be exactly kcapi_cipher_ivsize bytes in size. not more, not less. get this wrong and it's giving chaos πŸ’…

and what do you get back?

  • on success: the number of bytes sent to the kernel ⭐
  • on failure: a negative errno-style error code 😭

πŸŽ€ AUTHOR πŸŽ€

Stephan Mueller <smueller@chronox.de> β€” the author, the legend, the moment πŸ‘‘


that's all from me bestie, hope your encryption streams slay πŸ’…βœ¨

libkcapi Manual 1.5.0 β€” July 2025 β€” and yeah, you'll find it filed under KCAPI_CIPHER_STREAM_(3) πŸ¦‹ mwah, bye 🫢

πŸ“¦ where this page comes from