Calculate and reverse ISO 9564 Format 0 PIN Blocks.
A PIN Block is a standardized 64-bit (or 128-bit for Format 4) data structure that securely encodes a Personal Identification Number for transmission across the payment processing chain. Defined by ISO 9564, PIN blocks bind the cardholder's PIN to the Primary Account Number (PAN) using XOR, producing a clear block that is then encrypted under a PIN Encryption Key (PEK or ZPK) before leaving any device — ATM, POS terminal, mobile wallet, or HSM. The ISO 9564 standard defines five PIN Block formats: Format 0 (the workhorse — used by virtually every acquirer and issuer worldwide), Format 1 (no PAN dependency, used when the PAN is unknown at PIN entry, like remote verification), Format 2 (offline EMV PIN verification on the chip), Format 3 (Format 0 with random padding for added entropy), and Format 4 (the newest AES-based 128-bit format, required by PCI PIN Security v3.1 for new deployments). Format 0 remains the most common because it is required for online PIN authorization through Visa, Mastercard, and most national payment networks, and is the format every payShield HSM CA/CY command operates on by default.
Format 4 (often written ISO-4, or just 'PIN block format 4') is the AES-based PIN block introduced in ISO 9564-1:2017 and required by PCI PIN Security for new PIN-acceptance deployments. It replaces the 64-bit 3DES-era formats with a 128-bit block — and unlike Format 0, a clear Format 4 block never exists, because encryption is part of the construction itself.
The construction is encipher–mix–encipher. The 32-nibble PIN field starts with control nibble 4, then the PIN length, the PIN digits, fill nibbles of A up to position 16, and random nibbles in positions 17–32. The 32-nibble PAN field carries the PAN length (encoded as length minus 12) in its first nibble, followed by the full PAN, zero-padded. The device then computes: Intermediate A = AES-Encrypt(PEK, PIN field); Intermediate B = A XOR PAN field; PIN block = AES-Encrypt(PEK, B). Decoding runs the same steps in reverse — inside the HSM, never in application code.
This page's tool calculates Format 0, the format the vast majority of production traffic still uses. For Format 4 and Formats 1–3 — with step-by-step intermediates validated against published test vectors — use the PIN Block Formats tool in the app.
Open the PIN Block Formats tool (Formats 0, 1, 2, 3 and 4) →