Skip to content
cybersecurity authentication

PIV (PIV)

piv smart-card yubikey authentication fips-201 certificate
Plain English

PIV is a government-designed standard that defines how a smart card (or a hardware token like a YubiKey) organizes its cryptographic keys. Rather than one key that does everything, PIV gives you a set of dedicated slots: one for logging in, one for digitally signing documents, one for encryption. Each slot has its own security rules - the login key requires a PIN once per session, the signing key requires a PIN every single time (because signing something is a deliberate act). Think of PIV as a standardized, lockable key ring on a chip.

Technical Definition

PIV is defined in NIST FIPS 201-3 (Federal Information Processing Standard) and governs the credentials issued to US federal employees and contractors. The standard specifies card format, key slot structure, certificate requirements, and authentication protocols.

PIV Slot Layout:

SlotNamePIN PolicyTouch PolicyTypical Use
9aPIV AuthenticationOnce/sessionConfigurableSystem login, SSH, VPN
9bCard ManagementNever (mgmt key)NeverAdministrative operations
9cDigital SignatureEvery useConfigurableDocument/code signing
9dKey ManagementOnce/sessionConfigurableEncryption, key unwrapping
9eCard AuthenticationNeverNeverPhysical access control
82-95Retired Key ManagementVariesVariesHistorical key recovery
f9AttestationNeverNeverVerify key was generated on-chip

Key generation on YubiKey:

YubiKey supports ECCP256, ECCP384, RSA2048, and RSA4096 for PIV slots. Keys generated with ykman piv keys generate are created on-chip; keys generated externally and imported are flagged differently in the attestation certificate.

PIV Authentication Protocol:

  1. Authenticator reads the certificate from slot 9a
  2. Verifies the certificate chain up to a trusted root CA
  3. Issues a challenge (random nonce)
  4. PIV card signs the challenge using the 9a private key
  5. Authenticator verifies the signature with the public key from the certificate

PIN and PUK:

  • PIN: 6-8 digits (default: 123456). Entered to authorize use of slots with PIN policy.
  • PUK (PIN Unblocking Key): 8 digits (default: 12345678). Used to reset a blocked PIN. Should be stored offline like a recovery code.
  • Management Key: 24-byte (3DES) or 16/24/32-byte (AES) key for administrative operations. With --protect, stored on-chip and unlocked by PIN.

macOS Integration (CryptoTokenKit):

macOS natively supports PIV smart cards via CryptoTokenKit (since macOS 10.12 Sierra). The PIV token driver is built in - no additional drivers needed. The sc_auth utility pairs smart card identities to local user accounts for login.

In the Wild

PIV originated as the standard behind the US government’s Common Access Card (CAC) and PIV card programs, which issue smart cards to all federal employees, military personnel, and contractors. The same standard runs on a $55 YubiKey. In enterprise environments, PIV-compatible tokens are used for Windows smart card login (via CNG/PKCS#11), macOS FileVault 2 pre-boot authentication, and VPN certificate authentication. For homelab operators, PIV is the cleanest way to implement hardware-backed authentication across Linux SSH, macOS login, and document signing using a single key ring. The ykman CLI provides full PIV management, and the opensc-pkcs11.so module exposes the slots to any PKCS#11-aware application on macOS and Linux.