KCAPI_AKCIPHER_SETPU(3)

πŸ’– KCAPI_AKCIPHER_SETPU(3) πŸ’–

okay bestie, welcome to the Programming Interface section 3 page for kcapi_akcipher_setpubkey β€” yes the man page header truncates it to KCAPI_AKCIPHER_SETPU(3) like a bad screen name, but we know the truth 🫢


✨ NAME ✨

kcapi_akcipher_setpubkey β€” set the public key for the cipher handle πŸ”‘


🌸 SYNOPSIS 🌸

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

πŸŽ€ ARGUMENTS πŸŽ€

  • handle β€” [in] the cipher handle, aka your main character. πŸ’…
  • key β€” [in] the key buffer, and it has to be in DER format, no substitutes. πŸ“œ
  • keylen β€” [in] how long that key buffer is. πŸ“

πŸ¦‹ DESCRIPTION πŸ¦‹

So like, this function is the moment where you hand over the key for all the cipher operations coming after it. No key, no vibes, no crypto. πŸ”₯

The key has to be in DER format, and specifically it looks like this, okay?

SEQUENCE { n INTEGER ({ rsa_get_n }), e INTEGER ({ rsa_get_e }) }

That's the shape. n, e, SEQUENCE, all of it. Not me being extra, that's just literally the requirement. πŸ’€

Once you've passed the key in, you're free to securely destroy it β€” because at that point the kernel is the one maintaining it. She's got it from here, bestie, you can let go. πŸ™ˆ

And on the return tip: when it works, the value returned is the maximum size for the asymmetric operation (like, say, the modulus size). When it doesn't work? You get a negative errno-style error code. So if you're staring at a negative number, that's not a size, that's a whole situation. 😭


πŸ‘‘ AUTHOR πŸ‘‘

Stephan Mueller <smueller@chronox.de>

  • Author. (iconic of him, fr fr ⭐)

This page lives under the libkcapi banner β€” no extra copyright lines were written down here on this page, so that's the whole story. 🧚

okay that's the whole page, no cap. sending you off with all the love: libkcapi Manual 1.5.0, July 2025 β€” go set that public key and slay, bestie πŸ’…βœ¨πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from