Loopback · PC/SC · STM32 card emulator

APDU Simulator

Beta

Emulate an EMV card, drive a real one, or push a card profile to an STM32 board any terminal can read — with every APDU formatted and raw, a trace of the whole session, and scripted test plans from SELECT PSE to GENERATE AC.

On this page
apdu-simulator · APDU Simulator - Card-1 · MasterCard Debit (Test)

Overview

The APDU Simulator is the card side of an EMV transaction. It holds a card profile — ATR, applications, records, issuer keys — and answers the terminal’s commands from it: SELECT, GET PROCESSING OPTIONS, READ RECORD, VERIFY, GENERATE AC. That card can run in-process, be pushed to an STM32 board that presents a physical contact card to any terminal, or step aside while Studio drives a real card through a PC/SC reader.

Every exchange is shown formatted and raw as it happens, kept in the session trace, and checkable against a scripted test plan.

apdu-simulator · Card Session — Connect, then a contact purchase from SELECT PSE to GENERATE AC — each command parsed to labelled TLV beside its raw hex, the ARQC coming back in the last response

Three Operating ModesLoopback in-process, a real card through a PC/SC reader, or the STM32 card emulator over USB-CDC — pick the role and the transport adapts.
Card ProfilesScheme, ATR, applications with AID, label, PAN, expiry, records and issuer keys. Clone the test profile and personalize it, or start blank.
Terminal ProfilesTerminal type, capabilities, country and currency, floor limit and action codes — the terminal Studio plays when it drives a card.
Formatted and Raw APDUsEvery command and response parsed to labelled TLV beside its raw hex, from SELECT PSE to GENERATE AC.
Risk and Fault InjectionCryptogram policy, PIN try counter, ATC and offline limits, plus wrong status words, tears and delays on demand.
Test PlansScripted APDU sequences with expected status words and data checks, run step by step or end to end, with an L3-style report.

Configuration tabs

APDU Simulator Configuration has five tabs. Each card links to the section that documents it.

01 · Configure

Quick Start

  1. Create a card profile — Open APDU Simulator and add a profile in the left rail, or keep MasterCard Debit (Test).
  2. Pick the mode — On Mode & Transport choose Loopback, Reader (PC/SC) or Card emulator (USB-CDC to STM32). Loopback needs no hardware.
  3. Pick the transport — For the card emulator, select the port the firmware enumerated on (cu.usbmodemXXXX on macOS) and leave the baud at 115200.
  4. Check the profile — Card Profile shows the ATR, AID, PAN and issuer keys the simulator will present; Clone & personalize to change them.
  5. Launch — Launch APDU Simulator opens the session window. Connect, then present the pinboard to the terminal — or run a test plan in loopback.
  6. Read the exchange — Every APDU lands in the four panes, formatted and raw; Trace Log keeps the whole session.
Tip
Develop test plans and personalisation in Loopback first — the EMV runtime is the same one the hardware modes drive, so a plan that passes there is ready for the pinboard.
01 · Configure

Mode & Transport Tab

Pick the role this simulator plays. The transport section below adapts to it.

apdu-simulator · Mode & Transport — the three operating modes, Card emulator selected, and the STM32 transport — port, baud rate and ATR override

Operating modes

ModeWhat happens
Loopback (software-only)EMV runtime in-process against the active card profile. No hardware. Ideal for developing test plans and personalization.
Reader (PC/SC)Studio acts as the terminal and drives a physical card through a PC/SC reader such as the ACS ACR39U-I1. The card profile is informational only — the real card is the source of truth.
Card emulator (USB-CDC to STM32)Studio pushes APDU responses to the Nucleo-L432KC firmware over USB-CDC. The firmware emulates a contact card on the XCRFID pinboard, readable by an external POS terminal.
The hardware modes need hardware you supply
Loopback needs nothing — it is where to start. The other two modes each need a piece of kit that does not ship with ISO8583Studio:
  • Reader (PC/SC) — any PC/SC contact reader, for example an ACS ACR39U-I1.
  • Card emulator — an ST Nucleo-L432KC, an XCRFID 4-in-1 SIM/smart-card pinboard, a USB micro-B cable, and a 3V3↔5V level shifter such as a TXS0108E if your terminal drives Class A 5 V cards.
Order the parts yourself — or build the board in-house. ISO8583Studio is AGPL v3 open source and the emulator firmware ships with it, at firmware/stm32-card/ in the repository: the C source, its PlatformIO project, the full bill of materials and the C1–C8 wiring table from the Nucleo to the ISO 7816 contacts. If you would rather have the board design than a parts list, open an issue and ask for it.

Transport — STM32 / USB-CDC

PortThe serial port the firmware enumerated on. Rescan lists them again after you plug the board in.
Baud rate115200 by default. The framing is binary, so the baud only affects throughput, not the protocol.
ATR overrideHex; blank uses the card profile’s ATR. Set it when a terminal insists on a particular Answer To Reset.
macOS
The device shows up as /dev/cu.usbmodemXXXX after the firmware boots. If it is missing, check the Firmware tab of the session window — the board may still be in DFU mode.
01 · Configure

Card Profile Tab

The simulator emulates the active profile when running. The tab shows the key fields; the full editor opens from Edit profile.

apdu-simulator · Card Profile — the active profile, MasterCard Debit (Test), and its summary — scheme, ATR, the first application and the issuer key it signs with

ATRThe Answer To Reset sent on power-up — 3B6500002063CB6800 for the Mastercard test profile. Mode & Transport can override it per port.
ApplicationsOne or more ADFs, each with AID, label, priority, PAN, expiry, PAN sequence number and CVN — the Cryptogram Version Number selecting the derivation tree. The PSE directory is built from them.
RecordsThe SFI records returned to READ RECORD — CDOL1 and CDOL2, the CVM list, issuer action codes, application usage control and the rest of the application data.
Issuer keysThe issuer master keys (TDES_AC, TDES_SMI, TDES_SMC) the card derives its UDKs from, referenced by id such as mc-imk-1.

Actions

  • Edit profile — opens the full editor for the active profile — every tag, record and key.
  • Clone & personalize — copies the profile and steps through PAN, expiry, name and keys so a test card becomes yours.
  • New blank — starts an empty profile.
  • Refresh — re-reads the profile list from disk after an import.
Note
In Reader (PC/SC) mode the profile is informational only. The physical card answers, not this.
01 · Configure

The Other Configuration Tabs

Terminal ProfileThe terminal side of the exchange — what the simulated reader claims about itself when loopback drives a transaction. See Terminal Profile Tab.
Risk & BehaviorHow the card decides, and where it misbehaves on purpose. See Risk & Behavior Tab.
Test PlansWhich plans are available to the runtime’s Test Plans tab. See Test Plans Tab.
01 · Configure

Terminal Profile Tab

When Studio plays the terminal — in loopback and reader modes — this profile is what the card sees: the PDOL and CDOL data it is answered with, the CVMs the terminal supports, and the action codes that decide offline, online or decline.

apdu-simulator · Terminal Profile — identity, capability bytes with their decoded meaning, floor limit and action codes, and the AIDs the terminal accepts

TagFieldWhat it sets
9F35Terminal type22 — attended, online capable, operated by the merchant.
9F33Terminal capabilitiesCard data input, CVM and security capability bytes — which CVMs and which offline data authentication the terminal claims.
9F40Additional capabilitiesTransaction types, input and output capabilities.
9F1A · 5F2ACountry and currency0840 USD with exponent 2 in the test profile.
9F1BFloor limitAmounts under it can be approved offline with a TC; over it the TVR bit sends the transaction online.
TACTerminal action codesDenial, Online and Default masks matched against the TVR during terminal action analysis.
01 · Configure

Risk & Behavior Tab

How the emulated card decides. Everything here changes what GENERATE AC returns, how the card treats PIN, counters and issuer scripts — and what goes wrong when you ask it to.

apdu-simulator · Risk & Behavior — cryptogram policy, PIN and counters, issuer authentication and the fault injection switches

Cryptogram policyFollow the terminal’s request, force an ARQC to go online every time, force an AAC to decline, or approve with a TC when the amount is under the floor limit.
PIN and countersOffline PIN with a reference value and try counter, the starting ATC, and the lower and upper consecutive offline limits (9F14, 9F23).
Issuer authenticationVerify the ARPC in EXTERNAL AUTHENTICATE, accept or refuse issuer scripts (71 / 72), and optionally require a valid ARPC before returning a TC.
Fault injectionA response delay, a wrong status word on a chosen command, a tear at GENERATE AC, or one corrupted cryptogram byte — to see how the terminal copes.
01 · Configure

Test Plans Tab

A test plan is a scripted sequence of APDUs with the status word and data each step must return. Plans are stored with the profile and run from the session window, step by step or end to end.

apdu-simulator · Test Plans — the built-in plans and the steps of the online ARQC purchase passing one by one

  • Step — a command by name or raw hex, with the fields the simulator fills at run time — amount, date, unpredictable number.
  • Expect SW — the status word the step must return; anything else fails the plan at that step.
  • Expect data — a tag that must be present, or a tag with an exact value — 82 = 18 00, 9F27 = 80.
  • Report — each run ends in a pass / fail line per step with timing, and feeds the L3 Report tab.
Tip
Start from the built-in plans — online ARQC purchase, offline TC under the floor limit, PIN try counter exhaustion, unknown AID — and clone one to add your own assertions.
02 · Run

The Session Window

Launch APDU Simulator opens the session window for the profile. Seven tabs, all live:

TabWhat it does
Card SessionThe live exchange. In loopback and reader modes it is active — a quick-action toolbar, a raw APDU composer, and the last exchange split into formatted and raw command and response. In card-emulator mode it is passive: the external terminal drives and Studio answers, so there is no composer.
Trace LogEvery exchange as a log entry, with the same filter, auto-scroll and stats chrome as the other simulators. A non-9000 status word is coloured as an error.
Test PlansPick a built-in plan, run it through the connected transport, see pass/fail per case, export the report in the scheme’s preferred format.
Wire SniffImports a sigrok .sr or CSV capture from a 24 MHz logic analyzer and lines it up against the exchange log, so you can confirm the firmware emitted on I/O, CLK, RST and VCC what the runtime says it sent.
L3 ReportGenerates a certified-format report from the most recent test-plan run.
FirmwareBuilds and flashes the stm32-card firmware, with the build log in the shared log panel.
SettingsA live view of how the running simulator is wired. Changing anything means going back to the configuration screen.

apdu-simulator · Trace Log — the seven exchanges of a contact purchase arriving in order, with the L2 phases ticking off above them

Card Session status strip

FieldWhat it shows
StatusIdle, or connected and exchanging.
PhaseWhich part of the EMV flow the session has reached.
Last AIDThe application most recently selected.
ExchangesHow many command/response pairs this session has carried.
Two things are still landing
Hold next APDU in a passive session is a UI placeholder until the firmware-side interception ships, and Wire Sniff imports captures but is not yet a full overlay. L3 Report covers Visa VCPS and Mastercard M/Chip; other schemes can run plans but skip the certified export until their templates are in.
Note
For the terminal side of the same transaction, pair this with the POS Simulator; for key derivation and cryptogram checks, use the EMV & Card Tools.

Common Status Words

SW1 SW2Meaning
9000Success.
61xxResponse available; xx bytes remain. Issue GET RESPONSE.
6CxxWrong Le; correct Le is xx.
6300Authentication failed (PIN verification with no retry counter).
63CxPIN verification failed; x tries remaining.
6700Wrong length.
6982Security status not satisfied.
6985Conditions of use not satisfied.
6A82File or application not found.
6A86Incorrect P1 / P2.
6D00Instruction code not supported.
6E00Class not supported.

Tips & Troubleshooting

  1. No serial port listed — The firmware has to boot before the device appears. Wait for /dev/cu.usbmodemXXXX, then press Rescan.
  2. No PC/SC readers detected — Check the PC/SC service is running and no other smartcard application is holding the reader exclusively.
  3. ATR mismatch — Some terminals validate the ATR against a list. Set an ATR override on Mode & Transport to match the card you are impersonating.
  4. Terminal times out — A passive session answers as fast as the firmware relays it; if the terminal still gives up, check the wire capture rather than the runtime.
  5. Plan passes in loopback but fails on hardware — Loopback and the hardware modes share the EMV runtime, so the difference is on the wire. Wire Sniff is the tab for that.

Try it on your own cards

Free and open source. Download the studio and run this simulator on your desk in minutes.

✦ Pro

Testing with a team, or certifying with a scheme? Pro raises the CPS ceiling, unlocks the full algorithm set and deep simulator tweaks, plus hosted endpoints and priority support.

Register for Pro