A TR-31 key block is a format for protecting and exchanging symmetric cryptographic keys, published by the Accredited Standards Committee X9 as ANSI X9 TR-31. A key block wraps an encrypted key together with a readable header stating its permitted use, algorithm, exportability and other attributes, and it seals the whole block with a message authentication code. Any change to the header or the key makes the block fail verification, so a key cannot be moved out of its intended role, for example by using a PIN-encryption key to decrypt ordinary data, which older symmetric key wrapping methods did not always prevent.
TR-31 key blocks are used between hardware security modules (HSMs), terminals and processors for key management in card payments, including the keys that protect online PIN blocks. The PCI PIN Security requirements have made key blocks mandatory for key exchange in phases, and the format was later issued as the standard ANSI X9.143.