What is TR-31?
TR-31 (now formalized as ANSI X9.143) is a key-block format that wraps a symmetric key together with binding attributes — what kind of key this is (ZPK, BDK, PEK, IPEK, etc.), what algorithms it may be used with, its allowed modes, and its lifecycle state. The wrap is cryptographically bound: any attempt to alter the attributes without the wrapping key voids the MAC and the key block is rejected on unwrap.
TR-31 was created to close a class of attacks that existed against older "raw" key-wrapping schemes where a wrapped ZMK could be tricked into being unwrapped as a PEK (or vice versa), enabling cross-purpose key misuse. By binding attributes inside the wrap, TR-31 makes such attacks cryptographically impossible.
TR-31 vs Thales Key Block
Thales payShield HSMs originally shipped with a proprietary "Thales Key Block" format conceptually similar to TR-31 but with vendor-specific encoding. PCI PIN Security v3.1 made TR-31 / ANSI X9.143 mandatory for new key exchanges, so the modern payShield supports both formats and translation between them via the B0 / BA commands.
The practical difference: TR-31 is interoperable (every HSM vendor implements it), while Thales Key Block is single-vendor. For any new cross-vendor key exchange, use TR-31.