key_create(9)
π 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 ofpayload. 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 π
-EEXISTif a key with the same description already exists (oop, someone got there first π)-ENODEVif the key type wasn't available-ENOTDIRif the keyring wasn't a keyring (sir that is not a keyring π)-EACCESif 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 π
- Kernel file
./security/keys/key.cβ the source of truth, go look at it key_alloc(9)key_payload_reserve(9)key_instantiate_and_link(9)key_reject_and_link(9)key_put(9)key_create_or_update(9)key_update(9)key_revoke(9)key_invalidate(9)generic_key_instantiate(9)register_key_type(9)unregister_key_type(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms