KCAPI_AKCIPHER_SETKE(3)

πŸ’– NAME πŸ’–

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


✨ SYNOPSIS ✨

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

πŸŽ€ ARGUMENTS πŸŽ€

  • handle β€” [in] the cipher handle, aka the little guy you're doing all this for 🫢
  • key β€” [in] the key buffer, and it's gotta be in DER format or it's not the vibe
  • keylen β€” [in] how long that key buffer is, in bytes

🌸 DESCRIPTION 🌸

Okay so basically: you call this and the caller sets the key for all the cipher operations that come next. That's it, that's the whole job. ✨

The key must be in DER format, and it has to look exactly like this:

SEQUENCE { version INTEGER, n INTEGER ({ rsa_get_n }), e INTEGER ({ rsa_get_e }), d INTEGER ({ rsa_get_d }), prime1 INTEGER, prime2 INTEGER, exponent1 INTEGER, exponent2 INTEGER, coefficient INTEGER }
Not me being dramatic but πŸ’€ if it's not in this DER shape it's giving "nope".

Once the caller has handed the key over, the caller may securely destroy the key β€” because at that point it's being maintained by the kernel, so it's not your problem anymore. Lowkey iconic. πŸ‘‘

As for what comes back: upon success, the return value is the maximum size for the asymmetric operation (like, say, the modulus size 🌈). And if something went wrong? You get a negative errno-style error code. No cap. 😭


πŸ¦‹ AUTHOR πŸ¦‹

Stephan Mueller <smueller@chronox.de> β€” Author. 🫢


libkcapi Manual 1.5.0 July 2025 β€” that's the version and the date, bestie, and that's the whole page, fr fr πŸŒΈπŸ’–βœ¨

πŸ“¦ where this page comes from