tpm2_create_primary(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… tpm2_create_primary β€” kernel API manual, but make it cute ✨

okay so bestie, welcome to the tpm2_create_primary(9) page 🫢 it lives in the kernel API manual and it's literally all about creating a primary key using a fixed P-256 template. no cap, that's the whole vibe.


✨ NAME ✨

tpm2_create_primary β€” create a primary key using a fixed P-256 template πŸ’–


🌸 SYNOPSIS 🌸

int tpm2_create_primary (struct tpm_chip *chip , u32 hierarchy , u32
*handle , u8 *name );

that's the whole signature, character for character, no edits from me πŸ‘‘


πŸŽ€ ARGUMENTS πŸŽ€

  • chip β€” the TPM chip to create under 🧚
  • hierarchy β€” the hierarchy handle to create under ✨
  • handle β€” the returned volatile handle on success πŸ’«
  • name β€” the name of the returned key 🏷️

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the situation: for platforms that might not have a persistent primary, this is your girl β€” you can use it to create one quickly on the fly πŸ”₯ and the reason it's fast? it uses Elliptic Curve not RSA, so even slow TPMs can create one fast πŸ˜­πŸ’¨ (yes, even those TPMs. iconic behaviour.)

the template it uses is the TCG mandated H one for non-endorsement ECC primaries, which lowkey means:

  • P-256 elliptic curve β€” the only current one all TPM2s are required to have πŸ‘‘
  • a sha256 name hash 🌈
  • no policy β€” none, zero, nada πŸ™ˆ

⭐ RETURN ⭐

  • 0 β€” OK βœ…
  • -errno β€” a system error πŸ’€
  • TPM_RC β€” a TPM error 😭

πŸ’œ SEE ALSO πŸ’œ

kernel file ./drivers/char/tpm/tpm2-sessions.c, plus these besties:


ok that's the whole page, go forth and create primaries responsibly 🫢

and finally, the cute sign-off: this one's from ./drivers/char/tpm, dated October 2026, and it's tpm2_create_primary(9) forever and always πŸ’…πŸŽ€

πŸ“¦ where this page comes from