Payment Cryptography, Hands-On
Module 7 · Keys on the card

PINs: PIN blocks, ZPKs and translation

A PIN (Personal Identification Number) travels through several companies on its way to the issuer, and none of them may ever see it. It is packed into a PIN block, encrypted for the next hop, and translated from zone to zone inside HSMs.

By the end you can
  • build and parse an ISO format 0 PIN block;
  • explain PIN translation between zones;
  • explain why the issuer stores a PVV, not the PIN.

1. ISO format 0 PIN block

The PIN is mixed with the card number so that the same PIN on two cards gives different blocks:

  • PIN field: 0 (format) ‖ PIN length ‖ PIN ‖ F padding → 16 hex digits.
  • PAN (Primary Account Number, the card number) field: 0000 ‖ the 12 rightmost PAN digits, excluding the check digit.
  • PIN block = PIN field ⊕ PAN field. Then 3DES-encrypt it with the zone’s PIN key.

Newer: ISO (International Organization for Standardization) format 4 — 16 bytes, for AES (Advanced Encryption Standard), with random padding. Same idea.

2. Zones again: PIN translation

PIN padencrypts under its terminal key
→
Acquirer HSM (Hardware Security Module)translate → acquirer–network ZPK (Zone PIN Key)
→
Network HSMtranslate → network–issuer ZPK
→
Issuer HSMverify the PIN

At each hop, the HSM gets “PIN block under key A” and returns “PIN block under key B”. Decrypt and re-encrypt happen inside the HSM; the clear PIN block never exists in the application’s memory. The ZPK (zone PIN key, TR-31 P0) between a processor and a network is exchanged under the ZMK (Zone Master Key) — or derived dynamically, which is why networks also exchange a KEK (Key Encryption Key) just for PIN keys.

3. Verifying without storing: PVV and offsets

The issuer must check the PIN but should not store it. Two common methods:

  • Visa PVV: encrypt (part of the PAN ‖ a key index ‖ the PIN) with the PIN verification key (V2), decimalise to 4 digits, store that. To verify, the HSM recomputes it from the entered PIN.
  • IBM 3624 offset: derive a “natural PIN” from the PAN with the PVK; store the difference between the customer’s PIN and the natural PIN.

Either way, a database leak yields no PINs without the PVK, which lives in the HSM.

Chip cards can also verify the PIN themselves (offline PIN). That’s where issuer scripts with MK-SMC (Master Key for Secure Messaging Confidentiality)/MK-SMI (Master Key for Secure Messaging Integrity) come in: changing the PIN on the chip needs an encrypted, MACed script (module 6).

Exercises

Why is the PAN mixed into an ISO-0 PIN block?

  • So the same PIN on different cards gives different blocks
  • So the issuer can find the card
  • To make the PIN longer
HintUse the widget, or build the two fields by hand and XOR (exclusive OR) them.
HintTwo steps: TDES-ECB decrypt with the ZPK (cipher lab), then XOR with the PAN field.

A processor’s log accidentally contains, for one hour, the clear PIN blocks (not PINs) of all transactions. Is this a PIN compromise?

  • Yes — anyone with the PAN can recover the PIN from a clear block in one XOR
  • No — a PIN block isn’t the PIN
  • Only if the ZPK also leaked