Payment Cryptography, Hands-On
Module 3 · Moving keys between companies

Key exchange: ZMK, components, ceremonies and KCV

Two companies need the same secret key, and there is no channel they trust. The industry’s answer is low-tech and brilliant: split the key into pieces, send the pieces by different people and couriers, and let the HSMs put them back together.

By the end you can
  • explain zones and the Zone Master Key (ZMK, aka ZCMK, KEK, BKEM);
  • combine key components and verify them with KCVs;
  • describe a key ceremony and why it has so many rules;
  • explain why the same key can look completely different in two files.

1. Zones

A zone is a pair (or group) of parties who share keys. A processor typically has one zone with each card network and one with each card bureau. Each zone gets its own Zone Master Key — a key-encrypting key used only to protect other keys travelling in that zone.

NetworkVisa / Mastercard
ProcessorHSM (Hardware Security Module)
Card bureausone ZMK each

Names differ by organisation: ZMK (Thales), ZCMK (Visa: zone control master key), KEK (Key Encryption Key), BKEM, interchange key. Same idea.

Once a ZMK exists, every other key (CVK, IMKs, PIN keys) can be sent by plain email: it’s encrypted under the ZMK, and only the two HSMs that hold the ZMK can open it.

2. Components: splitting the ZMK

The ZMK itself has no safe channel. So it is generated as (usually) three random components, and the key is their XOR (exclusive OR):

ZMK = C1 ⊕ C2 ⊕ C3

Each component is printed, sealed in a tamper-evident envelope, and sent to a different key custodian by a different courier. Any one or two components reveal nothing (module 1: XOR with random is random). That’s split knowledge. Needing all custodians to act together is dual control.

3. The KCV: checking without revealing

How do two people confirm they have the same key without reading it out? They compare a Key Check Value: encrypt a block of zeros with the key and publish the first 3 bytes (6 hex digits).

  • Same key → same KCV. Different key → different KCV (except a ~1 in 16 million fluke).
  • The KCV doesn’t reveal the key (it’s a one-way use of the cipher), and 6 digits are too few to be useful for an attacker.
  • Every component has its own KCV too, so a typo is found per component.
  • AES (Advanced Encryption Standard) keys use a different method: the first bytes of a CMAC (Cipher-based MAC) over zeros.

4. The key ceremony

In a secure room, with no phones, a conductor, a witness and one custodian per component:

  1. Each custodian opens their envelope (checking the seal number against the log), and types their component into the HSM.
  2. The HSM shows the component’s KCV; the custodian compares it with the KCV on their paper.
  3. After the last component, the HSM combines them and shows the final ZMK KCV. Both organisations compare that KCV (by phone or email — KCVs aren’t secret).
  4. Everyone signs the minutes; components are destroyed or re-sealed for storage.

If an envelope arrives opened or a component is lost, the whole ZMK is considered compromised and the ceremony starts again. That’s why ceremonies feel slow: they’re designed so that no person, courier or email ever has the whole key.

(These demo components skip DES parity, so the simulator flags them — a real HSM would reject them at entry.) Try it: change one character in component 2. Its KCV changes, the final KCV no longer matches — and you know exactly which custodian to ask to re-enter.

5. Same key, different hex

Once the ZMK exists, a working key travels as encrypt(ZMK, key). The same working key sent to two partners under their two ZMKs gives two cryptograms that share nothing. That is a very common source of confusion: “why do we have two sets of keys?” Often, they’re the same keys in two wrappings. Compare the KCVs.

6. Beyond XOR: Shamir’s secret sharing

XOR components are n-of-n: lose one and the key is gone. HSMs protect their own admin functions and master-key backups with k-of-n schemes (e.g. any 3 of 5 smart cards). The classic construction is Shamir’s: the secret is a point on a random polynomial; any k shares determine it, k−1 shares reveal nothing.

In the book §3.1 El problema de gestión de claves (p. 89–92) for why key distribution is the hard part, and §5.3.1–5.3.2 Compartición de secretos, Shamir (p. 203–212).
In real life Newer setups avoid paper components entirely with TR-34 (ANSI X9 Technical Report 34, remote key loading with public keys) (RSA-based key transport with certificates) or ECDH (Elliptic-Curve Diffie–Hellman). AWS Payment Cryptography, for example, imports keys via TR-34. Paper ceremonies remain common with card networks and bureaus.

Exercises

A ZMK is shared by…

  • one HSM and nobody else
  • two organisations that need to exchange keys
  • the issuer and each card

Why is it fine to email a KCV, but not a component?

  • A KCV can confirm a key but can’t be used to recover it
  • KCVs are encrypted
  • Components aren’t random
HintKCV calculator, 3DES (Triple DES) method.
HintXOR all three known values together (the XOR playground does two at a time).
HintCompute the KCV of each typed component and compare with the list.
HintCipher lab → TDES (Triple DES), ECB (Electronic Codebook), key = the ZMK, data = the cryptogram, Decrypt. Then compute KCVs.

A partner proposes to save time: “We’ll send all three ZMK components in one encrypted ZIP; the password goes by SMS.” What is the core problem?

  • ZIP encryption is weak
  • One person or channel ends up with all components — split knowledge is broken
  • SMS can be intercepted