key_create(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… key_create(9)

okay so this one's from the Kernel API Manual and honestly? it's a banger. it's key_create, and it's about ✨making keys✨ β€” like, actually conjuring one into existence and hooking it up to a keyring. main character energy fr.


πŸŽ€ NAME πŸŽ€

key_create β€” Create and instantiate a key. that's it. that's the whole vibe. 🫢


✨ SYNOPSIS ✨

key_ref_t key_create (key_ref_t keyring_ref , const char *type , const
char *description , const void *payload , size_t plen , key_perm_t perm
, unsigned long flags );

like yes it's a long signature, no we're not scared of it, let's go through every single one πŸ’…


🌸 ARGUMENTS 🌸

  • keyring_ref β€” a pointer to the destination keyring, and it's carrying the possession flag with it. so it's not just any pointer, it's got baggage (affectionate).
  • type β€” the type of key. which flavour we're making here.
  • description β€” the searchable description for the key. this is how you'll find it later, so make it good πŸ”
  • payload β€” the actual data used to instantiate or update the key. the good stuff.
  • plen β€” the length of payload. gotta tell it how much data there is, bestie.
  • perm β€” the permissions mask for a new key. who gets to do what πŸ‘‘
  • flags β€” the quota flags for a new key.

πŸ¦‹ DESCRIPTION πŸ¦‹

so what does it do? it creates and instantiates a new key and links it from the destination keyring. boom. new key, fully realized, attached to its home. iconic behaviour honestly πŸ’–

and here's a cute little detail: if perm is KEY_PERM_UNDEF, then an appropriate key permissions mask will be concocted. concocted!! like a little potion πŸ§ͺ✨ so you don't even have to figure it out yourself.

what you get back:

  • a pointer to the new key if it worked πŸŽ‰
  • -EEXIST if a key with the same description already exists (oop, someone got there first πŸ’€)
  • -ENODEV if the key type wasn't available
  • -ENOTDIR if the keyring wasn't a keyring (sir that is not a keyring 😭)
  • -EACCES if the caller isn't permitted to modify the keyring, or if the LSM did not permit creation of the key

and on success? the possession flag from the keyring ref will be tacked on to the key ref before it is returned. tacked on! like a lil sticker ⭐

ngl bestie, those error codes are your whole personality check β€” read them before you assume something worked, fr fr.

🌈 SEE ALSO 🌈


okay that's the whole page, you ate that πŸ“ this one lives in ./security/keys, it's from October 2026, and yeah β€” it's still key_create(9), slay πŸ’œβœ¨

πŸ“¦ where this page comes from