The DUKPT (Derived Unique Key Per Transaction) system manages payment terminal encryption through a three-tier key hierarchy. The Base Derivation Key (BDK) is the foundation—held securely in an HSM at the acquirer/processor. From this, unique Initial PIN Encryption Keys (IPEKs) are derived for each terminal. These IPEKs are then used to generate up to 21 Future Keys stored in the terminal, which finally produce unique session keys for each transaction.
Scope: BDK (HSM Only)
- Never leaves HSM
- Shared across fleet
- Multiple BDKs possible
- Identified by BDK-ID (6 hex digits)
Scope: IPEK (Terminal Only)
- Generated once per terminal
- Injected into terminal securely
- Discarded after generating Future Keys
- Derived from BDK + unique KSN
The KSN is a 10-byte (20 hex-digit) value that encodes terminal identity and transaction state:
| Field | Bits/Hex Digits | Purpose | Example |
|---|---|---|---|
| BDK-ID | 24 bits (6 hex) | Identifies which BDK to use for derivation | 0003E9 |
| Terminal ID | 19 bits (5 hex) | Semi-unique identifier for the terminal | 00001 |
| Transaction Counter | 21 bits (5 hex) | Increments with each transaction/derivation | 00001 |
0003E900000100000001
BDK-ID: 0003E9 | Terminal ID: 00001 | Counter: 00001
The IPEK is derived using Triple-DES encryption in a specific sequence:
Keys are injected into terminals securely using TR-34 or TR-31 key blocks during a Key Injection Facility (KIF) session:
TR-31 (Symmetric):strong> IPEK wrapped with temporary KEK, MAC applied, KCV calculated.
After IPEK is discarded, the terminal uses Future Keys to derive unique session keys for each transaction:
| Phase | Location | Key Used | Purpose | Result |
|---|---|---|---|---|
| Injection Time | Terminal | IPEK (derived, then discarded) | Generate 21 Future Keys for counter powers of 2 | 21 Future Keys in FK registers |
| Transaction 1 | Terminal | FK21 (for counter 2^0=1) | Derive session key, encrypt PIN/data | FK21 erased, session key used once |
| Transaction 2 | Terminal | FK20 (for counter 2^1=2) | Derive session key, re-generate FK21 for counter 3 | FK20 erased, FK21 regenerated |
| Subsequent | Terminal | FK registers dynamically used/regenerated | Each transaction uses unique derived key | Supports ~1M transactions before re-injection |
The KSN is transmitted with encrypted data so the acquirer can regenerate the same session key for decryption:
- Terminal maintains transaction counter in KSN's rightmost 21 bits
- For each transaction, counter is incremented and set in active KSN
- Working KSN (transaction-specific) is derived from iKSN by updating counter bits
- Working KSN + encrypted data transmitted to acquirer
- Acquirer recovers working KSN from transmitted data, uses with BDK to regenerate session key
| Stage | Input | Process | Output | Storage |
|---|---|---|---|---|
| Pre-Injection | Terminal identity info | Establish iKSN, terminal nonce | iKSN value | KIF records |
| Key Derivation | BDK (in HSM) + iKSN | Triple-DES: Left & Right halves | 16-byte IPEK (unique per terminal) | HSM (temporary) |
| Key Protection | IPEK + Terminal Cert (TR-34) or KEK (TR-31) | RSA/AES encryption + signature/MAC | TR-34/TR-31 key block (safe for transmission) | In-transit (encrypted) |
| Terminal Injection | Encrypted key block + iKSN | Terminal decrypts, verifies KCV | IPEK loaded into terminal (plaintext, secure enclave) | Terminal RAM |
| Future Key Gen | IPEK + counter powers of 2 | 21 derivation cycles using IPEK | 21 Future Keys (FK registers) | Terminal secure memory |
| Post-Injection | iKSN (retained) | IPEK erased; iKSN + FK registers ready | Terminal ready for transactions | iKSN & FK in terminal; BDK in HSM |
Why This Design?
- Scalability: One BDK serves entire terminal fleet
- Uniqueness: Each terminal gets unique IPEK from iKSN
- Isolation: Compromised terminal IPEK doesn't expose BDK
- Transaction Keys: Every transaction uses different derived key
Attack Resistance
- BDK never enters terminal or network
- IPEK discarded after Future Key generation
- Session keys are one-time use (or limited use)
- KCV validates key integrity
- TR-34 adds asymmetric signatures for authenticity