Skip to content

Personal Identity Verification (PIV) Specification

1. System Overview

  • Standards: NIST SP 800-73-5, ISO/IEC 7816-4
  • Encoding: BER-TLV (Binary), X.509 (Certificates)
  • Crypto: RSA-2048, ECC P-256/P-384, 3DES
  • Protocol: T=1 (Contact), T=CL (Contactless)

2. Application Identifiers (AID)

ApplicationAID (Hex)Description
PIV Card AppA0 00 00 03 08 00 00 10 00 01 00NIST PIV Application

3. APDU Command Reference

CLA: 00 (ISO) or 80 (Proprietary).

CommandINSP1P2DataLeDescription
SELECTA4040C[AID]-Select Application
GET DATACB3FFF[Tag List]LenRead Data Object
VERIFY200080[PIN]-Verify PIN
GEN AUTH87AlgKey[Data]LenGeneral Authenticate

4. Data Objects (Containers)

Accessed via GET DATA with Tag 5C + [Container Tag]. The response is wrapped in a Template Tag (7E or similar) containing the data object.

NameTagContainer IDDescription
CCC5F C1 07DB 00Card Capability Container
CHUID5F C1 0230 00Card Holder Unique Identifier
Auth Cert5F C1 0501 01X.509 Certificate for PIV Auth (9A)
Sign Cert5F C1 0A01 00X.509 Certificate for Digital Signature (9C)
Card Auth Cert5F C1 0105 00X.509 Certificate for Card Auth (9E)
Key Mgmt Cert5F C1 0B01 02X.509 Certificate for Key Management (9D)
Security Object5F C1 0690 00Security Object (Signed Hashes)
Discovery Obj5F C1 0760 00PIV Discovery Object

5. Key References & Algorithms

Key References (P2 in GEN AUTH / VERIFY)

Key RefUsageDescription
00Global PINGlobal Card PIN
80App PINPIV Application PIN (Verification required for 9A/9C usage)
96Global PINPIV Card Application Global PIN
9AAuthPIV Authentication Key (Internal Auth)
9CSignDigital Signature Key (Internal Auth / Signing)
9DKey MgmtKey Management Key (External Auth / Decryption)
9ECard AuthCard Authentication Key (Physical Access)

Algorithms (P1 in GEN AUTH)

Alg IDDescription
003DES (3 Key)
07RSA 2048
11ECC P-256
14ECC P-384

6. Authentication Flows

6.1 PIN Verification

  1. SELECT PIV App (A0...00).
  2. VERIFY (00 20 00 80) with 8-byte padded PIN (0xFF padding).
    • SW 9000: Success.
    • SW 63Cx: Failure (x retries remaining).

6.2 Internal Authenticate (Signing)

Used for SSH / mTLS.

  1. SELECT PIV App.
  2. VERIFY PIN (80).
  3. GEN AUTH (00 87 <Alg> 9A) with Dynamic Auth Template (7C).
    • Input: Challenge / Hash.
    • Output: Signature.

7. Verification Implementation (Rust)

The PivController now supports high-level user authentication:

  • authenticate_user(pin):
    1. Selects PIV App.
    2. Verifies PIN.
    3. Reads Authentication Certificate (Tag 5F C1 05).
    4. Parses the X.509 certificate to extract the Public Key (RSA or ECC P-256).
    5. Generates a random 32-byte challenge.
    6. Signs the challenge using the card's private key (GEN AUTH).
    7. Verifies the signature against the extracted public key.

Released under the MIT License.