Ambimat GroupAmbimatAmbiSecureeSIM InitiativeEngineering BlogAhmedabad · India · Est. 1981
Architecture · Closed-loop

Card ↔ Reader ↔ SAM — the mutual-authentication architecture.

A reference walkthrough of the trust chain that powers every well-architected closed-loop deployment we have shipped: the card holds the credential, the SAM holds the issuer key, the reader is a router. Everything below is conceptual — we educate engineers on architecture, not on attack tooling.

1. The four trust zones

Every reasoning step in the rest of this page comes back to one diagram: the four trust zones, what each holds, and what crosses each boundary.

The four trust zones in a closed-loop deployment CARD DESFire EV2 / EV3 K_card[i] = KDF(K_app, UID_i) issued + personalised READER · UNTRUSTED routes APDUs UI · gate I/O cheap; replaceable ISSUER TRUST · SECURE BOUNDARY SAM · AV2 / AV3 tamper-resistant SE K_master · K_app field-replaceable unit BACKEND issuer KMS audit · settle offline majority RF host SC deferred
Card, untrusted reader CPU, SAM (the issuer’s trust boundary inside the reader), backend.

2. Key hierarchy

Everything below the master key is derived. No two cards share a working key; no two SAMs share a session key. Compromise is contained.

Key hierarchy from issuer master to per-tap session key K_master · ISSUER stored in issuer HSM K_app[transit] in every SAM K_app[loyalty] in every SAM K_app[access] in every SAM K_card[i] = KDF(K_app, UID_i) on the card & derived in SAM K_session = f(K_card, rndA, rndB, counter) per-tap; bound to a single transaction EVERY APP FOLLOWS THE SAME PATTERN K_app → K_card[i] → K_session per tap No working key ever sits at the reader CPU. Compromise of one card affects only that card.
From issuer master, through application key, to diversified per-card key, to per-tap session key.

3. Mutual authentication — with a SAM

The reader is a state machine that pumps APDUs between two parties that know the same key (the SAM and the card). The reader never sees the key. Crypto operations happen inside the card on one side and inside the SAM on the other; the reader stitches the two halves together.

Card ↔ Reader ↔ SAM mutual authentication sequence (concept-level) CARD READER SAM 1. Open host secure channel (reader ↔ SAM) mutual auth between reader CPU and the SAM, per-boot session keys 2. SELECT APPLICATION (AID) card scopes its key set 3. AUTHENTICATE_EV2_FIRST(keyNo) 4. card → reader → SAM: Enc(K_card, rndB) SAM derives K_card from UID; decrypts rndB; picks rndA 5. SAM → reader → card: Enc(K_card, rndA || rndB') 6. card → SAM: Enc(K_card, rndA') both sides have proven possession of K_card SESSION KEYS DERIVED ON CARD AND ON SAM (rndA, rndB, counter) 7. Subsequent APDUs wrapped in EV2 secure messaging (CMAC + AES-CBC) each command carries the session counter; replays detected; reader still sees only ciphertext 8. SAM-SIGNED RECEIPT BUFFERED FOR DEFERRED SETTLEMENT
Eight steps; reader CPU never holds K_card. Concept-level only.

4. Same flow — without a SAM

For comparison, the no-SAM variant. K_card has to live somewhere; if there is no SAM, it lives in reader firmware. One field-stolen reader becomes a system-wide leak. Acceptable for development benches and small-scale closed-system pilots; not acceptable for transit, payments, or any deployment with more than a handful of readers.

Mutual authentication without a SAM — keys live in reader firmware CARD READER · K_card[*] in firmware 1. SELECT APP / AUTHENTICATE_FIRST 2. card → Enc(K, rndB) 3. reader → Enc(K, rndA || rndB') 4. card → Enc(K, rndA') RISK: K_card lives on the reader CPU. One stolen reader = system-wide compromise.
No-SAM. Functionally simpler, operationally fragile.

5. The offline transaction lifecycle

Most of the world’s transit gates are not online when you tap. They authorise locally against information cached at the validator and reconcile in batches when network is available. The lifecycle below is the reference shape we ship.

Offline transaction lifecycle — depot sync, field operation, deferred settlement DEPOT SYNC blacklist fare config VALIDATOR · FIELD offline auth SAM-signed receipts BATCH BUFFER SD / eMMC tamper-evident UPLOAD cellular / Wi-Fi end-of-shift SETTLE issuer audit Receipts are SAM-signed; the issuer can verify each one against K_app even after a delay of hours. Anti-rollback counter on the SAM bounds replay window for any captured cryptogram.
Depot → validator → batch buffer → upload → settle. Most taps clear without ever being online.

6. Three validator form factors

The same trust chain runs on three very different physical platforms. Each adds operational constraints; the architecture survives them all.

Form factor 1

Gate / turnstile validator

Mains-powered, wired or Wi-Fi backhaul, ~300 ms tap-to-decision budget. Highest throughput. Often dual-redundant SAMs for 24×7 operation.

Form factor 2

Bus / on-vehicle validator

Battery-buffered, intermittent cellular backhaul, vibration / temperature stress. Depot sync at start of shift; uploads at end of shift.

Form factor 3

Handheld inspector

Battery-only, field inspection. Read-only relative to the card; signed inspection records buffered locally, uploaded on shift return.

All three carry a SAM. All three implement the same Card↔Reader↔SAM flow. The only thing that differs is the cadence of depot sync and upload; the field operation is identical.

7. Threats this architecture neutralises

ThreatWhat stops it
Stolen / tampered validatorNo working key on the reader CPU. Replacing the SAM resets exposure to a single device.
Cloned cardDiversified per-card key. Cloning one card does not reveal any other. Card-side counters detect duplication on collision in the depot reconciliation.
Replayed transactionPer-tap session keys + transaction MAC + monotonic counter. Captured cryptograms expire.
Reader firmware downgradeSAM enforces firmware-version attestation on host secure-channel open.
Backend compromiseIssuer master key lives in HSM, not in backend application memory. Settlement is signature-verified, not trusted-by-source.

No architecture neutralises every threat. This one neutralises the threats with the worst consequences for an issuer at scale — the ones where one bad day puts the entire deployment in jeopardy.

Designing a closed-loop deployment?

From SAM personalisation through validator firmware to back-office settlement, we ship the chain.

Talk to engineers