The Root Of Trust
All posts

How card personalization works

October 2026 · 8 minute read

Every card in your wallet started out as a blank rectangle of plastic. Somewhere between the factory and your mailbox it picked up your name, your card number, a PIN that only you will ever know, and a handful of secret keys that let the chip prove it is the real thing. That step is called personalization, and it is one of the most security-sensitive jobs a bank ever runs.

Almost none of it is visible to you. By the time the card lands on your doormat, the interesting part is already over. And the stakes are high in a quiet way. If a single secret leaks during this step, it is not one card at risk. It is every card in the batch.

This is a corner of payments I have spent a lot of time on, and it is one of those topics that sounds routine until you look closely. So let's look closely. We walk through what the issuer has to prepare, what the special security box called an HSM actually does, and where the software layers such as middleware and cloud services fit in.

From my own experience

I started out in payments as a personalization software engineer, working on a package called Samarcande. Its whole job was to build the kind of secured file I am about to describe, the one packed with DGIs laid out in the chip's format. It called the embedded crypto libraries, those libraries reached into the HSM, and the sensitive values were computed on the fly as each card was personalized.

Because the keys and data are so sensitive, our development world and the real one never touched. While building the software we used only test material, test PANs, names, sequence numbers and addresses, paired with test issuer keys. Production happened somewhere else entirely. Inside a physically secured facility, the live keys stayed on the HSM and never appeared in the clear, and the personalization line called those same functions to write live data into each chip as it ran.

Who is involved

Five players take part. It helps to know who does what before we get into the steps.

PlayerWhat they do
Card issuerThe bank or fintech that issues the card. It owns the card numbers and the secret keys behind them.
Card schemeVisa, Mastercard and the rest. They set the rules and vouch for issuers using digital certificates.
Personalization bureauThe factory. It loads data into each chip, prints and embosses the card, and prints the PIN mailer.
HSMA tamper-resistant security box that creates and guards the secret keys.
Middleware or cloud serviceThe software between the bank's systems and the HSM, or a cloud service that offers HSM functions through an API.

Some issuers do all the preparation in-house. Others hand part of it to the bureau or a processor. The steps are the same either way, so it is worth following them end to end once.

The six steps the issuer prepares

The issuer's real job here is a translation. It takes one plain line in a card file, a name and a number, and turns it into a complete, protected data package that a chip can accept and a terminal can later trust. Here is the path, start to finish.

  1. Step 1Start with the card file. For every card, the issuer holds the card number (the PAN), the expiry date, the cardholder's name and a sequence number (the PSN). The sequence number is what tells apart two cards sitting on the same account.
  2. Step 2Set up the keys. This happens once, and again whenever keys are renewed, not for every card. Master keys are created inside the HSM, one key for each job, so card codes, PINs and chip security each get their own. Any key that two parties have to share is built in a key ceremony, where several people each hold one part, so nobody ever holds the whole thing. The issuer and the bureau then agree a transport key to protect everything that moves between them. The issuer also loads the scheme's public keys, which step 4 will need.
  3. Step 3Generate each card's secrets. Now the per-card work begins. For every single card, the HSM produces three things, shown below. Every card gets its own set, so a leak from one card never exposes another.
  4. Step 4Create the chip's certificates. A chip card can prove it is genuine even when the terminal is offline, with no connection to the bank. It does this with a chain of trust, which is the part worth slowing down for. More on that below.
  5. Step 5Assemble the personalization file. Software packs everything into the exact layout the chip expects, in blocks called DGIs, alongside the magnetic stripe and the print data. The HSM supplies the protected pieces, and the software does the packaging. The two jobs stay separate on purpose.
  6. Step 6Encrypt and send to the bureau. The file and its sensitive parts are encrypted under the transport key from step 2, so only the bureau's own HSM can open them. Nothing sensitive travels in the clear.

The three secrets, made for every card

A random PIN

Nobody sees it. The bank does not even keep the PIN. It keeps a check value, a PIN offset or PVV, so it can verify your PIN later without ever storing it.

Card verification codes

The CVVs, worked out from the card number, expiry and a secret key. One for the magnetic stripe, one printed on the card, and a separate one for the chip, the iCVV.

Chip keys

Derived from the issuer's master keys using the card number and sequence number. The chip uses them to prove each payment is genuine, and the issuer can recreate the same key later to check it.

The chain of trust, in three links

This is how a card convinces a terminal it is real without phoning home. Each link signs the one below it, and the terminal follows the chain back up to a key it already trusts.

The issuer's own key pair is made once. Each card gets its own key pair and certificate, and the card's private key only ever leaves the HSM in encrypted form.

Once the package is built and encrypted, the bureau takes over. It loads the data into each chip over a secure channel, encodes the stripe, embosses the card, and prints the PIN in a sealed mailer. That mailer is usually posted separately from the card, so the two never travel together.

What the HSM really does

You will have noticed the HSM in almost every step. That is the point of it. The HSM is the vault where every secret is made and used, and the bank's software never once touches a key. The software sends a request, something like "calculate the CVV for this card," and gets back only the answer. The key stays inside.

From my own experience

That last point is not just theory to me. To generate the root key inside an HSM, two or three separate security officers each hold their own key component. They walk up and enter those components one at a time, and only then does the HSM assemble them into the master key it keeps for itself, the LMK. No single person ever sees the whole key, and no single person ever could. That is the entire point of the ceremony.

Where middleware and cloud services fit in

The HSM does the cryptography, but something has to tell it what to do, thousands of times a minute. That is the job of the software layers sitting above it.

Middleware is the traffic controller. Applications ask it for simple things, like "make a PIN for this card," and it translates each request into the HSM's own low-level commands. It also handles the unglamorous work that keeps a big run alive.

A cloud service is a different animal. Something like AWS Payment Cryptography (APC) is not middleware. It is closer to an HSM you rent. The hardware sits in the cloud provider's data centers, you call it through an API, and you pay by use instead of buying and running your own devices. From the application's point of view, it does the same job as an on-site HSM.

PieceWhat it doesWhere it lives
HSMHolds the keys and does the cryptographyIn your own data center
Cloud service (e.g. APC)The same job, delivered as an APIIn the cloud provider's data centers
MiddlewareSits between your applications and either of the aboveIn your software stack

Plenty of organizations run both. Some keys and tasks stay on on-site HSMs, others move to the cloud, and good middleware can hide that split so the applications above it never need to change. One honest caution, though. Bulk card personalization is still a newer area for cloud services, so before planning a move, check which personalization functions the service actually supports today.

Why scale is the hard part

None of the individual steps are exotic. The difficulty is in the multiplication. One card needs around ten separate secret operations. That is a PIN and its check value, three card codes, several chip keys, and a key pair with a signed certificate.

~10
secret operations per card
1M
cards in a single run
~10M
operations for that one run

The RSA key pairs are the slowest piece by a wide margin, which is why middleware builds a stock of them ahead of time. And a failure halfway through a batch is its own kind of pain, because a half-finished run is genuinely hard to untangle. The teams that plan for retries, progress tracking and clean restarts have far fewer bad days than the ones that do not.

A few mistakes show up again and again, and all of them are avoidable.

The thread running through all four is the same discipline. One key, one job, and a written record of every hand that touched it. That is the whole philosophy of payment key management in a single line.

The short version

Mini glossary

TermPlain meaning
PANThe long card number
PSNA number that tells apart two cards on the same account
CVV / iCVVA short security code, calculated with a secret key. The iCVV is the chip's own version
PVV / offsetA check value the bank stores so it can verify a PIN without keeping the PIN
HSMHardware security module, a tamper-resistant box for keys
Key ceremonyA controlled process where several people each hold part of a key
Transport keyA key used only to protect other keys and files in transit
CertificateA signed digital ID that lets a terminal check a card is genuine
DGIA block of data in the layout a chip expects
BureauThe company that loads the data and makes the physical card