TR-31 Key Block
Interoperable Secure Key Exchange — parse TR-31 key blocks, explore the header structure, and understand real-world use cases for secure key distribution between HSMs.
Follows ANSI X9 TR-31:2018 / X9.143 key block headerversions A, B, C, D — parse only·verified Oct 2026· double-checked Oct 2026— parses the TR-31:2018 Annex A worked examples; no KBPK cryptography in the tool
Use test data only. All calculations run locally in your browser — PayProbe never sees, transmits, or stores your PAN, CVV, keys, PINs, or cryptographic inputs. How we handle data →
What is TR-31?
TR-31 (ANS X9.143) defines a standard format for wrapping cryptographic keys when exchanging them between secure modules (HSMs, PEDs, ATMs). The standard ensures that a key's intended usage, algorithm, and exportability are cryptographically bound to the key value — preventing mis-use or substitution attacks.
A TR-31 key block is an opaque ASCII string that contains a 16-character header, optional extension blocks, the encrypted key value, and an authentication MAC — all protected by a Key Block Protection Key (KBPK).
Why TR-31 matters
- Attribute binding — usage and algorithm are authenticated, not just encrypted
- Prevents key substitution — a PIN key cannot be re-used as a MAC key
- Interoperability — Thales, Futurex, Utimaco, nCipher all support the same block format
- PCI PIN compliance — PCI PIN Security requires symmetric keys to be exchanged in key blocks; TR-31 / X9.143 is one of the accepted formats (with ISO 20038 and equivalent proprietary blocks)
- Required for DUKPT, ZPK, and EMV key distribution in modern payment deployments
Key Block Structure
A TR-31 block is an ASCII string. Each coloured segment maps to a header field.
Version Identifiers
Version A
TDEA, key variant binding (KBPK ⊕ 45 / 4D), 4-byte CBC-MAC
DeprecatedVersion B
TDEA, key derivation binding (CMAC-derived KBEK/KBMK), 8-byte CMAC
Version C
TDEA, key variant binding (KBPK ⊕ 45 / 4D), 4-byte CBC-MAC — same as A, with clarified header rules
Version D
AES-128/192/256, key derivation binding (CMAC-derived KBEK/KBMK), 16-byte CMAC