This is an old revision of the document!
Table of Contents
cVEND NFC Reader
The cVEND is the NFC reader on the bottom half of the PM3. It is a FEIG cVEND module with its own ARM CPU and embedded Linux, not just a UART peripheral.
The host serial link is /dev/ttymxc3 at 115200 8N1.
The reader application reports version 02.35 and model string
cS01.05.45-49.00-2-2. /etc/issue says FEIG ELECTRONIC GmbH - cVEND Development Kit. The reader OS is Buildroot 2014.05.
The boot sequence was captured on the serial line with a Saleae logic analyzer: Boot capture. Open it with the Saleae app.
Hardware and provisioning limits
The SAM, ISAM, HSM key, Girogo, ITSO, VDV-KA, and EMV configuration paths are present in the firmware, but a surplus unit does not have the matching hardware, keys, or EMV config. The protocol table describes the firmware; it does not mean those paths work on every unit.
Reading raw UIDs
The reader scans ISO14443 cards on its own after its firmware boots. It pushes a frame for every card it sees. No keys, no nx, and no enable sequence are needed to read a UID.
- Open
/dev/ttymxc3at 115200 8N1 after the unit boots. - Do not send the nx init sequence. The
0xE4enables,0xAASetTime, and0xE8certificate read switch the reader into nx's handled-card mode and stop the autonomous base scan. - Send a
0x04status frame about once a second. It is cheap and covers the case where the reader drops into idle. - Watch for
0xBEframes. The 7-byte UID starts at payload offset 11.
Gate on the frame type. 0xBE is the unhandled-card frame. The 0xD1 status and
0xED log frames also contain 0x04 bytes, so looking for the byte instead of
the frame type produces phantom reads.
Direct frames, with sequence 1 and no payload CRC:
stty -F /dev/ttymxc3 115200 cs8 -cstopb -parenb raw -echo # Status keepalive printf '\274\001\000\004\000\000\051' > /dev/ttymxc3 # Version request printf '\274\001\000\002\000\000\370' > /dev/ttymxc3 # Restart the reader application printf '\274\001\000\020\000\001\243\002' > /dev/ttymxc3 # Listen for frames timeout -t 3 dd if=/dev/ttymxc3 bs=1 count=256 2>/dev/null | hexdump -C
The examples use sequence 1. Increment the sequence byte and recompute the CRC-8
if you send more than one frame. The CRC only appears on frames with a type of
0x80 or higher.
What the firmware handles
The cVEND runs a complete card stack on its own ARM core. None of this happens on the PM3's i.MX6:
- RF field and ISO14443A/B anticollision.
- Polling for every card type the reader is configured to look for.
- ISO14443-4 activation, ATS, and protocol selection.
- DESFire native protocol and the EMV Level 2 kernel.
- Card presence tracking and the LED/buzzer feedback.
A host application never talks to a card. It opens the serial port and reads the frames the reader pushes. That is why a UID reader fits in one short file, and it is also the ceiling: if the firmware does not poll a card type, no amount of host code makes it appear.
The base scan is UID-only for the same reason. The reader activates the card,
emits 0xBE, and releases it because no handler owns that card type.
0xD4 Transceive then has nothing selected to talk to and replies status
0x01 (no card). Sending APDUs, reading files, or authenticating needs a
card type enabled and the reader's handled-card path, which is what nx
drives. See nx for that side.
Writing a host application
Every frame is the same seven-byte header, then the payload:
BC seq replyTo type lenHi lenLo crc8 data...
BCis the start byte. The parser resyncs on it.seqcounts host requests. The reader echoes it inreplyToso replies can be matched.lenHi lenLois the payload length, big-endian.crc8is CRC-8/MAXIM over the first six bytes, reflected polynomial0x8C, init0.- A trailing CRC-32 appears only when
type >= 0x80. It is CRC-32/JAMCRC over the payload, little-endian.
Parse in the same order the reader does: find BC, check the header CRC,
then wait until the declared length plus the optional trailer is buffered.
A BC inside a payload cannot be mistaken for a frame start, because its
header CRC will not validate.
A complete reader, no dependencies:
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <poll.h>
#include <termios.h>
#include <time.h>
static uint8_t crc8(const uint8_t *p, size_t n)
{
uint8_t c = 0;
while (n--) {
c ^= *p++;
for (int i = 0; i < 8; i++)
c = (c & 1) ? (c >> 1) ^ 0x8C : c >> 1;
}
return c;
}
static int send_frame(int fd, uint8_t seq, uint8_t type,
const uint8_t *d, uint16_t n)
{
uint8_t b[7 + 64];
b[0] = 0xBC; b[1] = seq; b[2] = 0; b[3] = type;
b[4] = n >> 8; b[5] = n & 0xFF;
b[6] = crc8(b, 6);
if (n)
memcpy(b + 7, d, n);
return write(fd, b, 7 + n) == 7 + n ? 0 : -1;
}
int main(void)
{
int fd = open("/dev/ttymxc3", O_RDWR | O_NOCTTY);
struct termios t;
tcgetattr(fd, &t);
cfmakeraw(&t);
cfsetispeed(&t, B115200);
cfsetospeed(&t, B115200);
tcsetattr(fd, TCSANOW, &t);
uint8_t buf[512], seq = 1, last_uid[8] = {0};
size_t used = 0;
time_t last_ka = 0, last_seen = 0;
for (;;) {
time_t now = time(NULL);
if (now != last_ka) {
send_frame(fd, seq, 0x04, NULL, 0);
if (++seq == 0)
seq = 1;
last_ka = now;
}
struct pollfd p = { fd, POLLIN, 0 };
if (poll(&p, 1, 1000) <= 0)
continue;
ssize_t r = read(fd, buf + used, sizeof buf - used);
if (r <= 0)
continue;
used += r;
size_t i = 0;
while (used - i >= 7) {
if (buf[i] != 0xBC || crc8(buf + i, 6) != buf[i + 6]) {
i++;
continue;
}
uint16_t n = (buf[i + 4] << 8) | buf[i + 5];
size_t total = 7 + n + (buf[i + 3] >= 0x80 ? 4 : 0);
if (used - i < total)
break;
if (buf[i + 3] == 0xBE && n >= 18) {
uint8_t *uid = buf + i + 7 + 11; /* see payload layout below */
int fresh = memcmp(uid, last_uid, 7) != 0 ||
now - last_seen > 3;
last_seen = now;
if (fresh) {
memcpy(last_uid, uid, 7);
for (int j = 0; j < 7; j++)
printf("%02X%s", uid[j], j == 6 ? "\n" : ":");
}
}
i += total;
}
memmove(buf, buf + i, used - i);
used -= i;
}
}
The UID sits at payload offset 11 in every 0xBE seen so far: one status
byte, one length byte, nine reserved bytes, then the UID. Check the frame length
before trusting the offset. The example assumes a 7-byte UID; a 4-byte UID
carries a different length.
Card presence
The reader re-sends 0xBE about once a second for as long as the card is in
the field. It arrives unsolicited with replyTo=0, so the sequence byte does
not help match it. It does not send a leave frame on the base path, so presence
has to be inferred: treat the card as gone when no 0xBE with that UID has
arrived for a couple of seconds. Without that timeout a card parked on the reader
keeps producing events and a queue fills up.
Handled mode does have a leave event. 0xD5 with replyTo=0 is
[subtype][status][7-byte UID]: subtype 0x00 is a card entering,
0x01 a card leaving.
00 00 04 85 92 8a a0 61 81 card entered 01 00 04 85 92 8a a0 61 81 card left
That path only runs with card types enabled and the matching keys present.
What a card frame gives you
0xBE carries more than the UID. After the UID the payload holds the
ATQA, the SAK, and the length-prefixed ATS, so cards can be classified without
selecting them. The full layout is in the card events section below.
SAK 0x20 means ISO14443-4: DESFire, EMV cards, and Java Card.
0x08 is MIFARE Classic 1K, 0x18 Classic 4K, 0x44 Ultralight.
That is enough to decide whether to look for an EMV application or treat the
card as a memory tag.
The same reader has the LED and buzzer frames (0x20 and 0x22), so a
host application can chirp and light the reader on a read without any extra
hardware.
Running a reader next to nx
Only one process can own /dev/ttymxc3. Stop nx and
init-abtproxy first, or the two will interleave frames and neither will
work reliably.
Do not send the 0xE4 enables, 0xAA SetTime, or 0xE8 certificate
read. That switches the reader into nx's handled-card mode and stops the
autonomous base scan. It is a different mode, not an initialization step for
UIDs. Handled reads also need the card keys and, for some schemes, a SAM or
ISAM.
Do not re-initialize the reader on every tap. That stops the scan you are trying
to read from. If scanning does stop, 0x10 02 restarts the reader application
and normally returns scanning in about 6 seconds. If no Startup arrives,
power-cycle the reader. A bare 0x10 with no subcode wedges it.
A loop like the one above has read 74 taps from five different cards over four minutes without a gap.
Card events
| Type | Direction | Meaning |
|---|---|---|
0xBE | reader to host | UnhandledCard. UID is present for card types that are not enabled. |
0xD5 | reader to host | Card in/out for an enabled type. replyTo=0 for an unsolicited event: [subtype][0x00][7-byte UID], subtype 0 enter, 1 leave. Also used as the reply to 0xD4. |
0xB1 | reader to host | ISO14443A read. UID starts at offset 2. |
0xB9 | reader to host | DESFire read. UID starts at offset 2. |
0xBB | reader to host | DESFire card removed. |
0xD1 | reader to host | EMV/status record. See below. |
0xED | reader to host | Log line. First byte is 1 INFO, 2 WARN, 3 ERROR, then a null-terminated ASCII message. |
A 0xBE payload looks like:
00 status (card present) 0c length 00 x9 reserved 04 50 67 0a 81 22 90 7-byte ISO14443A UID (NXP cards start with 04) 44 03 ATQA, little-endian, about 0x0344 20 SAK 06 75 77 81 02 80 ATS, length-prefixed
The bytes before the UID are status/length/reserved fields, not a reliable card-type field.
The 0xD1 status record
0xD1 appears at startup and on state changes. It is not a continuous idle
stream on this firmware, so do not use it as a keepalive indicator. It is
EMV-style BER-TLV:
05 fffee004 39 outer container, 0x39 bytes df fe e0 08 01 10 poll/state counter A df fe e0 09 01 01 poll/state counter B df fe e0 0a 03 000000 df fe e0 0e 08 00...00 card token/UID slot, zero when unhandled df fe e0 0b 01 00 df fe e0 0c 06 00...00 df fe e0 0d 02 0000
The 08/09 counters change between scans. The 0e slot is where a handled
card's token or UID lands once nx has the application keys. Without keys it
stays zero and the UID arrives through 0xBE.
DESFire commands
DESFire cards are read with 0xBC DESFireCommand and 0xBD
DESFireCommandReply. The 0xBC payload is the native DESFire frame, so
m075031_desfire.pdf applies directly.
Enable the handler first with 0xE4 00 07 01 01. This is the handled path, so
it stops the autonomous base scan; pick one mode or the other. The reader then
sends 0xB9 when a DESFire card enters the field and 0xBB when it leaves.
The commands nx sends after the card event:
GetVersion 0xBC -> 60 SelectApplication 0xBC -> 5A <3-byte application id> ReadData 0xBC -> BD <file> <offset, 3 bytes> <length, 3 bytes>
The application ID is issuer-specific. The stock software uses F9C32B;
Portland TriMet cards use E010F2. If you do not know the ID, read it off
the card first.
A GetVersion exchange captured from nx, split into header, payload, and CRC:
host BC 22 00 BC | 00 01 | 58 | 60 | 2A 71 4F 60
reader BC B7 22 BD | 00 1E | 3D | 00 00 04 01 01 33 00 16 05 04
01 01 03 00 16 05 04 8A 6E F2
9B 14 90 20 48 73 30 30 50 22 | C9 8C 7E 9B
0xBD puts two reader bytes ahead of the card data. Here they are 00 00,
and the DESFire data starts at 04 01 01 33. A SelectApplication reply in
the same capture was 01 FD with no data. Check the DESFire status word
instead of assuming a fixed offset.
A host DESFire frame starts BC seq 00 BC. The second 0xBC is the
message type, not an ack of some kind.
IPP packet structure
| offset | length | name | description |
|---|---|---|---|
| 0 | 1 | always 0xBC |
|
| 1 | 1 | seq | increasing from 1, skips 0 on rollover |
| 2 | 1 | replyTo | seq being answered, or 0 for unsolicited |
| 3 | 1 | msgType | |
| 4 | 2 | msgLen | payload length |
| 6 | 1 | hdrCRC | CRC-8 Dallas/Maxim over the previous 6 bytes |
| 7 | msgLen | msgData | payload |
7+msgLen | 4 | msgCRC | little-endian bit-inverted IEEE CRC-32/JAMCRC over msgData, only when msgType >= 0x80 |
IPP Message types
| msgType | dir | name | notes |
|---|---|---|---|
| 0x02 | → | Version | reply 0x03 |
| 0x03 | ← | VersionReply | device id from the Rockchip OTP, model string, firmware, and cwd as length-prefixed strings |
| 0x04 | → | Status | reply 0x05, 00 00 |
| 0x05 | ← | StatusReply | |
| 0x07 | ← | Heartbeat | about every 3.0 s |
| 0x0F | ← | Startup | sent about 1 minute after reader power-on |
| 0x10 | → | Reset | first byte selects the action: 2 exits the app so it is respawned, 3 calls fetrm_reboot, 4 calls fetrm_poweroff, 33-36 reset SAM slot 1-4. Anything else logs Error: Reset Code not implemented yet. [IppBaseTelegram.cpp:157] and answers 0x11 0000. Do not send it without a payload byte. |
| 0x11 | ← | ResetReply | 00 00 |
| 0x20 | → | LEDs | u32 bitmap, big-endian. All eight LEDs are in the low byte. Upper bytes are inert. |
| 0x22 | → | Buzzer | [u16 freq][u16 ms], big-endian. About 2700 Hz is loudest. |
| 0x32 | → | CardRelease | |
| 0x46 | → | AbortCardHandling | |
| 0x96 | → | PutFile | write operation; use with care |
| 0x97 | ← | PutFileReply | |
| 0x98 | → | GetFile | [u16 pathlen][path][u32 offset][u16 count] → 0x99 [u32 len][data] |
| 0x99 | ← | GetFileReply | |
| 0x9A | → | DeleteFile | left alone |
| 0x9B | ← | DeleteFileReply | |
| 0x9C | → | FileInfo | [u16 pathlen][path][u32 off][u32 len] → 0x9D [status:u16][size:u32 BE][crc32:u32 BE]. 0,0 covers the whole file. The CRC is reflected CRC-32 with polynomial 0xEDB88320, initial value 0, final XOR 0xFFFFFFFF. See the 0x9C CRC section. |
| 0x9D | ← | FileInfoReply | |
| 0xA4 | → | FileList | [u16 pathlen][path] → 0xA5 [u32 len][name\0mtime\0...] |
| 0xA5 | ← | FileListReply | |
| 0xAA | → | SetTime | payload is a timestamp. Reply 0xAB 0000. Not an arm command. |
| 0xAB | ← | SetTimeReply | |
| 0xAC | → | ITSOData | needs an ISAM |
| 0xAD | ← | ITSODataReply | |
| 0xAE | → | ITSOCtrl | needs an ISAM |
| 0xAF | ← | ITSOCtrlReply | |
| 0xB1 | ← | ISORead | UID at offset 2 |
| 0xB3 | ← | ISOCardReleased | |
| 0xB4 | → | APDUProx | [devsel][CLA][INS][P1][P2][Lc BE][data][flags][Le BE], total 10 + Lc. The device byte is copied into the reply and not validated. Only dispatches while ProxCardIso is the active handler. |
| 0xB5 | ← | APDUProxReply | [devsel][echo][status][SW1][SW2][data]; status 0x70 no card, 0x6C no session |
| 0xB6 | → | SAMCtrl | needs a fitted SAM |
| 0xB7 | ← | SAMCtrlReply | status 0x72 on error |
| 0xB9 | ← | DESFireRead | |
| 0xBA | → | DESFire second entry | |
| 0xBB | ← | DESFireCardRemoved | |
| 0xBC | → | DESFireCommand | native DESFire command |
| 0xBD | ← | DESFireCommandReply | two reader bytes, then the card data. GetVersion replies 00 00 04 01 01 33 ... |
| 0xBE | ← | UnhandledCard | UID carrier for disabled types |
| 0xCE | → | control | IppHandling |
| 0xD0 | → | EMV | 0 load config, followed by a null-terminated filename that is read on the reader and passed to fetfpd emvco_ep_configure; 1 preprocess, bytes passed to emvco_ep_preprocess; 2 toggle polling, next byte 0 start or 1 stop. Needs an EMV config. |
| 0xD1 | ← | EMVStatus | BER-TLV status record |
| 0xD4 | → | UltralightCommand | subcommands below. Host path is limited; see the warning. |
| 0xD5 | ← | UltralightReply / card event | |
| 0xE4 | → | ProxCardFunction | [00][id][01][00|01]; ids 4 VdvKa, 5 MifareClassic, 6 Iso, 7 Desfire, 8 Girogo, 9 Itso, 10 UltralightC. Enables work. Disable requests return status 0x74; handlers are not disabled at runtime. |
| 0xE5 | ← | ProxCardFunctionReply | 00 id 00 00 on enable, 00 id 00 74 on a failed disable |
| 0xE6 | → | Girogo | not exercised; needs girogo keys and hardware |
| 0xE8 | → | SecurityServices | sub 0 GetVersionOfKey, 1 RemoveX509Cert, 2 RemoveKeyBlock, 3 ImportX509Cert, 4 ExportX509Cert (device cert), 5 ImportKeyBlock, 6 ExportKeyBlock, 7 GenerateKSKPair. The writes need HSM keys that a surplus unit does not have. |
| 0xE9 | ← | SecurityServicesReply | |
| 0xEA | → | Mifare Classic / wake | handler exists but often errors |
| 0xED | ← | Log | level byte plus null-terminated text |
Directions are host to reader (->) and reader to host (<-).
LEDs
The 0x20 payload is a big-endian u32. The eight LEDs live in the low byte:
| bit | LED |
|---|---|
| 0x01 | status row 1, green |
| 0x02 | status row 2, green |
| 0x04 | status row 3, green |
| 0x08 | status row 4, green |
| 0x10 | status row 3, amber (same LED as 0x04) |
| 0x20 | status row 4, red (same LED as 0x08) |
| 0x40 | NFC logo, right |
| 0x80 | NFC logo, left |
struct.pack(">I", 0x0f) lights the four green status LEDs. 0x00 clears them.
The firmware also drives the LEDs during RF activity, so a host write holds only
until the next firmware update. Drive them from a loop if you need them steady.
Reader filesystem
The reader exposes file operations over IPP. The two read operations are useful:
0xA4 FileList [u16 pathlen][path]
-> 0xA5 [u32 len][name\0mtime\0...]
0x98 GetFile [u16 pathlen][path][u32 offset][u16 count]
-> 0x99 [u32 len][data]
0x98 returns one frame per call, so page with offset and use a count under
about 60 KB. 0x9C FileInfo returns the status, size, and a CRC-32 that is
described below.
Worth reading:
/etc/fetpfrc: JSON payment config with permitted SAM slots and crypto/token plugins./home/startup_config.conf:STARTUP_APP="/home/app0"./home/app0/run: app launcher./home/app0/emv/transact-counter.dat: EMV transaction counter./home/app0/config: 160 bytes of zeros on the PM3. It is not the RF or power-timer blob. Those timers are still not located.
Direct example for a directory listing:
stty -F /dev/ttymxc3 115200 cs8 -cstopb -parenb raw -echo printf '\274\001\000\244\000\014\174\000\012\057\150\157\155\145\057\141\160\160\060\227\022\347\031' > /dev/ttymxc3 timeout -t 2 dd if=/dev/ttymxc3 bs=1 count=512 2>/dev/null | hexdump -C
Direct example for reading /home/app0/version, offset 0, count 0x100:
printf '\274\001\000\230\000\032\131\000\022\057\150\157\155\145\057\141\160\160\060\057\166\145\162\163\151\157\156\000\000\000\000\001\000\370\354\104\170' > /dev/ttymxc3 timeout -t 2 dd if=/dev/ttymxc3 bs=1 count=64 2>/dev/null | hexdump -C
The reply length depends on the file. Increase count if a frame is truncated.
These examples also use sequence 1. Increment the sequence byte for each request.
The 0x9C CRC
0x9C hashes the file bytes in [off, off+len) with a reflected CRC-32:
crc = 0x00000000
for each byte b:
crc ^= b
8 times: crc = (crc >> 1) ^ 0xEDB88320 if crc & 1 else crc >> 1
return crc ^ 0xFFFFFFFF
That is polynomial 0x04C11DB7 reflected, initial value 0, final XOR
0xFFFFFFFF. It is not ISO-HDLC (which starts at 0xFFFFFFFF) and not
JAMCRC (which skips the final XOR).
In C, one loop over the file:
static uint32_t file_crc(const uint8_t *p, size_t n)
{
uint32_t crc = 0;
while (n--) {
crc ^= *p++;
for (int i = 0; i < 8; i++)
crc = (crc & 1) ? (crc >> 1) ^ 0xEDB88320 : crc >> 1;
}
return crc ^ 0xFFFFFFFF;
}
The firmware's own routine takes the running CRC as a seed and inverts both ends, so a 4 KB chunk loop composes correctly. The reply is big-endian:
00 00 status 00 00 00 06 size, 6 04 40 bb d8 crc32 of "02.35\n"
Verified against seven files and three ranged reads.
status is 0x00 for a normal file. /home/app0/config answers 0x01
with size 160 and CRC 0xffffffff, yet GetFile still returns 160 zero bytes,
so 0x01 does not mean “missing”.
Sleep and recovery
The reader powers its RF field down after an idle timeout and can drop into a
sub-1 mA hardware standby. There is no host wake opcode in the documented FEIG
command set. A 0x04 Status frame does not reliably wake it.
Leaving the tty open without a keepalive still scanned after 90 seconds. Either the idle timeout is longer than that or an open host tty counts as stimulus. The idle timeout is not established; keep the keepalive running if you need scanning.
Symptoms: scanning stops, only the 0x07 heartbeat continues, and 0xD1/0xBE
stop.
Recovery:
0x10 02
That restarts the application. On a healthy reader it emits 0x11 ResetReply,
aborts, re-initializes, and emits 0x0F Startup after about 6 to 7 seconds.
The serial link is preserved. If no Startup arrives, power-cycle the reader.
The first payload byte selects what Reset does:
2: the app breaks out of its main loop and exits. Whatever supervises it starts it again. This is the recovery command.3: callsfetrm_reboot(), a full reader reboot.4: callsfetrm_poweroff(). The reader stays off until it gets power.33to36(0x21to0x24): reset SAM slot 1 to 4. Needs a fitted SAM.- anything else: no action, and the error above is logged.
The handler reads the first payload byte, so do not send 0x10 with an empty
payload. That has left the reader unresponsive in testing.
Subcode 3 replies 0x11, aborts card handling, and then stops answering.
0x10 02 did not recover it, and it had not returned after 20 seconds, so
that test ended with a physical power cycle. Treat 3 as “reboot the module”, not
as a faster restart.
nx handshake reference
Captured by an LD_PRELOAD shim on nx's serial traffic:
0xEA 0100 wake/prime 0x02 version 0xE4 00 05 01 01 enable Mifare 0xE4 00 07 01 01 enable Desfire 0xE4 00 0a 01 01 enable UltralightC 0xAA <timestamp> SetTime 0xE8 04fe0a0000 read device cert -> 0xE9 (~1.1 KB X.509)
The 0xE4 enables and SetTime switch the reader from the autonomous base scan to
nx's handled-card mode. The certificate read is informational. nx does not send a
periodic poll after this. Continuous scanning is the reader's own behavior.
The 0x0F Startup frame gates the enables. Sends before it are silently dropped.
It does not gate raw UID reading.
Reader internals
The feig binary is a 1.6 MB unstripped ARM C++ program. Every IPP opcode maps
to a named handler, and the binary carries INIT's source paths under
//home/jah/git/init/proxcontroller-feig2/src/.
The reader has:
- a multi-application card controller (
RFIDReaderMultiApp,ProxCardCtrl) - DESFire, Mifare Classic, Ultralight-C, ISO-14443-4, VDV-KA, ITSO, Girogo, and EMV handlers
- a MIFARE SAM AV1/AV2 interface on
0xB6 - a PKCS#11 HSM on
0xE8 - an ITSO ISAM path on
0xAC/0xAE - EMVCo Entry Point and L2 kernels on
0xD0
Handlers register in their constructors: IppBaseTelegram owns 0x02,
0x10, the file ops, and 0xAA; IppHandling owns 0x04 and 0xCE;
ProxCardCtrl owns 0x32, 0x46, 0xB4, and 0xE4; and the card
modules own their own opcodes (ProxCardDesfire 0xBA/0xBC,
ProxCardUltralightC 0xD4, ProxCardMifareClassic 0xEA,
ItsoIppHandler 0xAC/0xAE, SamCtrl 0xB6, EmvIppHandler
0xD0, GirogoIppHandler 0xE6, SecurityServicesIppHandler
0xE8).
The card handlers and crypto are present, but the SAM, ISAM, HSM keys, and EMV configuration are not on a surplus unit. That is a key and provisioning limit, not missing firmware.
Telling transit cards apart
At the RF type layer the big agencies look the same. ORCA (Seattle), Compass (Vancouver), Ventra (Chicago), Peggo (Winnipeg), and NFTA Metro (Buffalo) cards are NXP DESFire, so a base-scan frame gives you:
ATQA 0x0344SAK 0x20, meaning ISO14443-4- an ATS such as
06 75 77 81 02 80
Nothing in that frame names the agency, the fare product, or the card generation. The UID is the only per-card value, and it is NXP stock, not an agency range. An app that wants to behave differently per agency either keeps a UID list or gets past the type layer.
Getting past it does not need the keys. Selecting a DESFire application, or an
ISO AID, answers success or “not found” without authentication. A probe for a
known transit application therefore tells agencies apart. That needs APDU
access, which the base scan does not give you. See 0xD4 below.
Some cards are easier. A MIFARE Ultralight answers ATQA 0x0044,
SAK 0x00, and no ATS. An NTAG sticker or an Ultralight key fob lands
there and is distinguishable without a list. MIFARE Classic is SAK 0x08
for 1K and 0x18 for 4K, which is what most older hotel keys use. DESFire
transit cards are the ones that look identical.
0xD4 UltralightCommand
The command is documented, but the host-driven read path does not work well.
0x02 Read [start_page u8][num_pages u8] 0x03 Write [page u8][4 bytes] 0x04 Auth raw key [16-byte key] 0x05 Auth key index [key index, big-endian u16] 0x06 Auth index+key [u16][16-byte key] 0x07 Abort no payload
Read returns four bytes per page. An NTAG215 is 135 pages, so a full dump is
0x02 00 87 and 540 bytes of data.
The reply is 0xD5 [subcmd][status][payload...], status 0x00 success, 0x01 no card,
0x02 bad parameters. With no card in the field the reader answers
[subcmd][0x01] without attempting the operation.
In practice, 0xD4 returns status 01 on this reader. The reader's internal
handler selects the card, runs its own transceive, and releases it in
milliseconds. Polling 0xD4 also suppresses the reader's own scan. The reader
services host commands or scans autonomously, not both. Use the internal handlers
instead: enable the type, let the reader transceive, and read 0xD1/0xB1/0xD5.
Open questions
- What writes
/home/app0/config, and why it is 160 zero bytes. The path does not appear as a string in the app, so it is written by something else or left over from provisioning. - What
status 0x01from0x9Cmeans, given that the file still reads. - The three-byte
0xB4tail: which bits of the flags byte are chaining and which are Le encoding. The length check and field order are known; the bit layout is not. - How long the idle timeout actually is, since 90 seconds with an open tty was not enough.
- The SAM, ISAM, HSM key provisioning, and the EMV config format.
