A PIN block is the fixed-size value a terminal builds from your PIN, and usually from part of your card number, immediately before encrypting it, so the PIN never travels or sits anywhere in the clear. The international standard ISO 9564-1 defines five main layouts, formats 0, 1, 2, 3 and 4, and the format a system uses decides how hard the encrypted block is to attack, which encryption algorithm can protect it, and whether two parties can even read each other's data. Formats 0 and 3 still carry most of the world's card PINs under Triple DES, while format 4 is the only one built for AES, the algorithm the industry is slowly moving to.
Key takeaways
- A PIN block combines the PIN with padding and, in most formats, card number digits, so identical PINs on different cards encrypt differently.
- ISO 9564-1 defines formats 0, 1, 2 and 3 as 64-bit blocks for Triple DES, and format 4 as a 128-bit block for AES.
- Format 0 is the oldest and most common; format 3 is the same design with random padding, which makes each block harder to analyze.
- Format 4 is the only ISO format that supports AES, but the PCI Security Standards Council suspended its migration deadlines in 2021 and has not reset them.
- Most "invalid PIN block" errors come from using the wrong card number digits, the wrong format code or the wrong key, not from broken encryption.
What is a PIN block, and why not just encrypt the PIN?
A PIN block exists because a four-digit PIN is far too small to encrypt safely on its own. There are only 10,000 possible four-digit PINs, so if a terminal encrypted "1234" the same way every time, an attacker who captured traffic could build a table of all 10,000 encrypted values and read PINs straight off the wire without ever breaking the key.
The fix is to fill a full cipher block with structured data around the PIN before encryption. Depending on the format, that structure adds a format code, the PIN length, fill characters, random digits and digits from the card number, also called the primary account number or PAN. Mixing in the PAN means the same PIN on two different cards produces two different encrypted blocks, which defeats precomputed lookup tables. The PCI Security Standards Council's format 4 guidance notes that formats 0, 3 and 4 all prevent precomputed table lookups and known-plaintext attacks for exactly this reason.
The PIN block is created inside a secure cryptographic device, usually the PIN pad itself, and stays encrypted until it reaches a hardware security module (HSM) at the issuing bank or its payment processor. Along the way it may be decrypted and re-encrypted several times under different keys, a step called PIN translation, but always inside tamper-resistant hardware. If you want the bigger picture of how a card payment moves between terminal, processor, network and bank, our guide to how a tap-to-pay transaction travels walks through each hop.
The five ISO 9564 formats at a glance
Every ISO format starts with a single hexadecimal digit that names the format, followed by a digit giving the PIN length, which can be anywhere from 4 to 12 digits. After that, the formats differ in what fills the rest of the block and whether the PAN is mixed in.
| Format | Block size | Cipher | Uses the PAN? | Padding | Typical use today |
|---|---|---|---|---|---|
| 0 | 64-bit | Triple DES | Yes, rightmost 12 digits excluding the check digit | Fixed F characters | Most ATM and POS traffic worldwide |
| 1 | 64-bit | Triple DES | No | Transaction or random digits | When the PAN is not available, e.g. some PIN changes |
| 2 | 64-bit | Triple DES | No | Fixed F characters | Offline PIN sent to a chip card only |
| 3 | 64-bit | Triple DES | Yes, same as format 0 | Random A to F characters | Newer Triple DES systems that want non-repeating blocks |
| 4 | 128-bit | AES | Yes, up to 19 digits | A fill plus random digits | AES migrations, newer POI devices |
Older documentation also mentions non-ISO layouts such as ANSI X9.8, VISA-1 and ECI-1. The EFTlab PIN block reference lists how they map: ANSI X9.8, VISA-1 and ECI-1 are the same layout as ISO format 0, which is why format 0 still shows up under so many names in host specifications.
How is a format 0 PIN block built?
A format 0 PIN block is built by creating two 16-character hexadecimal fields, one from the PIN and one from the card number, and combining them with an exclusive-OR (XOR) before encryption. Here is the full calculation for PIN 1234 on the test card number 4111 1111 1111 1111.
- Build the PIN field. Write the format code 0, then the PIN length 4, then the PIN, then pad to 16 characters with F: 041234FFFFFFFFFF.
- Build the PAN field. Drop the last digit of the card number (the Luhn check digit), take the rightmost 12 of the digits that remain, and put four zeros in front: 0000111111111111.
- XOR the two fields digit by digit: 041234FFFFFFFFFF XOR 0000111111111111 = 041225EEEEEEEEEE.
- Encrypt that 64-bit result with the PIN encryption key under Triple DES. The ciphertext is what actually leaves the PIN pad.
Step 2 is where most integrations go wrong. The PAN digits used are the twelve immediately to the left of the check digit, not the last twelve digits of the card number and not the first twelve. Use the wrong slice and every PIN block decrypts to garbage at the host, even though the key and the PIN are correct.
Formats 1, 2 and 3: when the PAN is missing, offline, or randomized
Format 1 leaves the PAN out completely and fills the space with a transaction-unique or random value instead. It exists for situations where the device building the block does not have the card number, but that independence comes at a cost: PCI guidance warns that format 1 can leak information and is potentially weaker than formats 0, 3 or 4, and PCI PIN translation rules allow a format 1 block to be converted into format 0, 3 or 4 but never the other way round.
Format 2 is the odd one out. It is used only to pass a PIN to a chip card for offline verification, where the card itself checks the PIN, and PCI rules permit translation into format 2 solely for submission to an IC card. You should never see format 2 traveling over a network to an issuer.
Format 3 is format 0 with one change: instead of filling unused positions with F, it fills them with random values from A to F. The PIN field for 1234 might be 041234ACFEBDABCF on one transaction and 041234FBDACEAFCB on the next. That randomness means the same PIN on the same card no longer produces an identical encrypted block every time, which removes a useful clue for anyone watching repeated transactions.
Format 4: the AES PIN block
Format 4 was added to ISO 9564-1 in a 2015 amendment and is the only ISO format designed for 128-bit block ciphers such as AES. According to the IBM format reference the plaintext PIN field is 16 bytes long and starts with control digit 4. Rather than a single XOR, it uses a two-stage process that ties the full card number to the PIN.
- PIN field (128 bits): control digit 4, the PIN length, the PIN, fill digits of A up to the 16th position, then 16 random digits, so each block is unique except by chance.
- PAN field (128 bits): a digit giving the PAN length minus 12, then the full PAN of 12 to 19 digits, padded with zeros. Unlike format 0, the whole card number is used, not just twelve digits.
- Encipherment: the PIN field is encrypted under the AES key, the result is XORed with the PAN field, and that value is encrypted again.
Because the PAN is woven in between two encryption passes, format 4 cannot be decrypted without knowing the correct card number, and the random half of the PIN field helps a receiving host spot replayed blocks. The trade-off is practical: the PAN must be present inside the secure device before the PIN is encrypted, and every hop that handles the block, from the terminal to the acquiring bank, the card network and the issuing bank, needs AES-capable hardware and software.
Why the move to AES is taking so long
The industry has known for years that Triple DES is near the end of its life. NIST, the US standards body, withdrew its Triple DES specification on 1 January 2024 and disallowed it for new encryption after 31 December 2023, while still allowing it to decrypt data that was already protected. Payment networks, however, run under their own rules set by the card brands and the PCI Security Standards Council, and those rules still permit TDES-based PIN blocks under managed keys such as DUKPT.
PCI did set dates. Version 3.0 of the PCI PIN Security Requirements planned for all hosts to support format 4 decryption from January 2023 and encryption from January 2025. In March 2021 the Council suspended those format 4 dates after industry feedback, while urging firms to keep migrating from TDES to AES. The reason is the sheer length of the chain. One AES-capable PIN pad is useless if the acquirer's HSM, the network switch or the issuer's host cannot handle a 128-bit block, so migration moves at the pace of the slowest link.
Two things have kept pressure on anyway. Fixed-key Triple DES PIN encryption, where a terminal uses the same key indefinitely, became disallowed under PCI rules after 1 January 2023. And PIN pads approved to PCI PTS POI version 5 or later must support format 4, so the installed base of capable terminals grows every time old devices are replaced.
Why does my system say the PIN block is invalid?
If an HSM or host rejects a PIN block, or decrypts it to something that does not start with a valid format code and length, the cause is almost always one of the following rather than a cryptographic failure.
- Wrong PAN digits: using the last 12 digits instead of the 12 to the left of the check digit, or including the check digit, in formats 0 and 3.
- Wrong format code: the terminal builds format 3 but the host is configured to expect format 0, or the reverse.
- Wrong key or key variant: the block was encrypted under a terminal key but decrypted under a zone key, or a DUKPT key serial number was not passed through.
- Odd-length PAN handling: card numbers of 15 or 19 digits shifted by one position when the PAN field is built.
- Padding or length errors: a PIN length digit that does not match the number of PIN digits, or lowercase hex where the host expects uppercase.
The quickest test is to build the clear PIN block by hand for a known test card and PIN, as in the format 0 example above, and compare it with what your system produces before encryption. If the clear blocks match, the problem is the key; if they do not, it is the formatting.
Where things stand in November 2026
As of November 2026, the PCI PIN Security Requirements remain at version 3.1 and the Council has not published replacement dates for format 4 support, so format 4 is strongly encouraged rather than mandated. Formats 0 and 3 under Triple DES still carry the large majority of PIN traffic, and PCI translation rules continue to allow conversion between formats 0, 3 and 4 as long as the card number is never changed in the process.
Hardware is where the change is happening. The Council extended the expiry of PTS POI version 5 PIN pads to 30 April 2027, giving merchants more time to replace older devices, and it has signaled a new PTS HSM version 5 standard in 2026, which will shape the next generation of issuer and processor hardware. Each refresh cycle brings more of the chain onto AES, and with it format 4. Card security failures have historically forced faster change than any deadline, as the Heartland and Hannaford breaches showed when they reshaped how processors protect card data in transit.
What should payment teams watch next?
Watch for the PCI Security Standards Council to restate format 4 dates, most likely alongside a new major version of the PIN standard, and for the card brands to publish their own timelines, since brand rules are what actually bind acquirers and processors. Watch your HSM vendor's roadmap too, because AES PIN translation and AES DUKPT support usually arrive as firmware or license upgrades rather than new boxes.
For anyone building or auditing a payment system now, the practical advice is simple: support format 4 in anything new, keep format 0 to 3 handling correct and tested for everything that already exists, and treat a working clear-text PIN block calculation as a basic debugging skill. The same discipline applies to stored card data under PCI DSS, which is why many teams pair PIN work with a cardholder data discovery exercise to prove nothing sensitive is sitting where it should not be.
Frequently asked questions
Is ISO format 0 still allowed?
Yes. Format 0 is still permitted under the PCI PIN Security Requirements and remains the most widely used format, provided it is encrypted with managed keys rather than a single fixed Triple DES key, which has been disallowed since 1 January 2023.
What is the difference between format 0 and format 3?
They are built the same way and both mix in 12 digits of the card number. The only difference is padding: format 0 pads with F characters, while format 3 pads with random values from A to F, so repeated transactions do not produce identical blocks.
Does format 4 need the full card number?
Yes. Format 4 uses the full PAN of 12 to 19 digits, and the card number must be available inside the secure device before the PIN is encrypted. Without the correct PAN, the block cannot be decrypted.
Can a PIN block be converted from one format to another?
Yes, inside a hardware security module, subject to PCI rules. Formats 0, 3 and 4 can be translated between each other without changing the card number, format 1 can be translated into 0, 3 or 4, and translation into format 2 is allowed only to send a PIN to a chip card.
Why is the PIN length included in the block?
PINs can be 4 to 12 digits long, so the length digit tells the decrypting system exactly how many PIN digits to read before the padding starts. A mismatch between that digit and the actual PIN is a common cause of verification failures.