Without options the UID and the Philips MFG string are now read from the
tag, `-r` is gone. `--uid` is the offline path, and the new `--mfg` gives
the Philips toothbrush algo its MFG string offline, which used to need
the tag on the antenna. Help shows a working Philips sample taken from
the generator self test vector, also run by pm3_tests.sh.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bring the SAM commands to parity with Seader's (bettse/seader, GPLv3)
read and save options:
- hf mf sam: MIFARE Classic SE via CMD_HF_SAM_MFC
- hf mfdes sam: DESFire EV1/EV2 via CMD_HF_SAM_SEOS, as Seader drives it
- --dg legacy|sr|prox|mfc and --save on hf iclass / seos / mf / mfdes sam
- wiegand downgrade: the same outputs offline, from a saved credential
or PACS bits, plus --selftest
Outputs follow seader_credential.c:
- legacy / sr: 20 block iCLASS dump, Seader's config, epurse, Kd from the
HID standard key, block 6 03030303 0003E014 (A3 for SR, PACS left
unencrypted), PACS in block 7, SR SIO in blocks 10-17. A CSN read from
iCLASS is kept, anything else gets Seader's fake CSN 7AF53113FEFF12E0.
- mfc: 1K dump with Seader's block 0, MAD, HID sector 1 keys and PACS in
block 5, the layout hf mf encodehid writes.
- prox: lf hid clone --bin, and -w H10301 for 26 bits as Seader does.
- --save: a "hid credential" JSON with PACS, bits, UID, SIO, media type.
The PACS parsing hf iclass sam and hf seos sam each had a copy of moves
to hidsio.c; hf seos sam is now the shared ISO14443-A command.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New client command for VivoKey Thermo / Temptress style implants. The
NTAG 5 link (NTP5332) is used as I2C master: energy harvesting is enabled
through the EH_CONFIG_REG session register (AN12365), the TI sensor is
driven with WRITE I2C / READ I2C / READ SRAM and the I2C master status
register is polled for completion and NAKs. Sensors at 0x48-0x4B are
probed and identified by the TMP117/TMP119 device id register, a one-shot
conversion is triggered and the result printed in C and F.
Pure client side, uses CMD_HF_ISO15693_COMMAND with the field kept on.
Offline self test for the conversions is hooked into pm3_tests.sh, and
hf 15 info hints at the command for NTAG 5 tags.
Not tested on hardware, no implant available.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New `hf goodisplay load` for the NFC-D1 tags GDEY0154D67, GDEY0213B74,
GDEY029T94 and GDEY037T03. They use a Fudan FM1280 talking ISO14443-4
with proprietary CLA F0 APDUs (config F0 DB/DA, image F0 D2 in 250 byte
chained blocks, refresh F0 D4), unlike the raw 14a CD xx frames of
Waveshare tags, hence a separate command family. Protocol and init
sequence from the Flipper Zero NFC Eink app (GPLv3, RebornedBrain).
Image load/crop/dither, save and 1bpp packing move from cmdhfwaveshare.c
into imgutils.c so both commands share them. Waveshare output is
unchanged.
hf 14a info hints at hf waveshare for its known UIDs (now incl. FSTN11m)
and at hf goodisplay for a SAK 28 ATS 0B 78 33 A0 02 90 <UID> 00 tag.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
brew's "openssl" alias follows the newest major (now openssl@4), so
`brew --prefix openssl` returns a prefix that isn't installed on setups
with only openssl@3, and the build fails with evp.h / des.h not found.
Probe the candidate kegs and use the first that actually has the headers.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The page check covers the Hitag 2, S and µ `wrbl`, the data check S and
µ. `htu rdbl -c` stops at the 55 blocks the reply holds, `hts -m` above
3 is refused, `ta -h` shows its help and argument errors free the
parser.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Annotators, `trace extract`, `-x` and `-c` stay inside the frame, the
trace and the row buffer, `-t ht2` inside the Hitag 2 state, and frame
lengths are 16 bit wide. Topaz, FeliCa and five byte ISO14443-A frames
get the right CRC check, Topaz and iCLASS traces tell their ISO14443-A
and ISO15693 frames apart, and the SEOS, 14b, DESFire and Hitag µ
labels are corrected. Six make check expectations on the repository
traces cover the fixes.
Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
demod splits the starting digit from the reserved bits, writes the
animal code as CCC NNNNNNNNNNNN, knows all 249 ISO 3166-1 countries
and shows Bio-Thermo only for the chips' exact trailer. clone and sim
refuse values the frame can't carry, sim sends the data block flag for
--extended 000000 and stops with Enter, reader also tries 125 kHz.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lf destron sim only printed "To be implemented". It now sends the
frame that lf destron clone writes, FSK2 RF/50 as in the clone's T5577
config. Both take 5 bytes of 00-7F: clone wrote a byte above 7F
without its top bit and padded a short uid with FF of bad parity.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clone took negative FC and CN, and MS values above 5 and 22 bits,
without a word: MS FC 40 wrote the card of FC 8. sim let ids of 32
bits or more change the fixed bits, so --id 2147483648 simulated id 0,
and printed the shifted frame as Internal Id. The sim help example
used --cn, the option is --id, and the clone hint named lf keri read.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HPP32 wrote its card number 10 bits past the 32-bit frame, it now uses
bits 13-30 as cardinfo shows. H10320 wrote its first digit over the
leading one, so decode refused most numbers, and two of its parity
masks had typos. S12906b needed ParityValid, which no caller sets.
HGen37 decode checked bit 28 instead of 26. The limits of nine formats
did not match the fields Pack writes. wiegand list printed the usage
of wiegand info.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A NULL TLV has no length, so a run of them swallowed the TLVs after
it. Lock and Memory Control sizes of 0 mean 256, the nibbles of their
third byte are powers of two and the Memory Control size counts bytes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The values went through uint8_t or & 0xFF, so --max 300 ran with 44
and --samples 1000 with 232. The --fs clocks stay 8-bit in the FSK
demod and are now refused above 255.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mfulc_des_brute added the Homebrew openssl@3.6 include directory, which
the macOS runners no longer have, and -Wmissing-include-dirs under
-Werror stopped the build. It now uses brew --prefix openssl, as #3734
did for mfd_aes_brute.
Since MSYS2 filesystem 2026.10.18 /etc/profile runs post-install
scripts on the first start only, so ProxSpace never installed its
packages and the build found no arm-none-eabi-gcc. The workflow now
runs ProxSpace's setup script when setup\installed is missing.
The third mfulc_des_brute test in pm3_tests.sh is now labelled 3/3.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The hardcoded openssl@3.6 include path fails macOS CI when that formula
is absent. Ask brew for the installed OpenSSL prefix and use it for
both headers and libraries.
Built all three mfd_aes_brute tools with Clang and GCC 16 against
OpenSSL 3 and 4 on macOS. Existing linker deprecation warnings remain.
Read SBS before TIME/DATE to latch a coherent snapshot in synchronous
ERTC mode. A rollover between the previous calendar and subsecond reads
could move the tick count backwards and cause false receive timeouts.
Preserve millisecond conversion and shared delta-helper semantics.
Add actual-source rollover, conversion and register-locking coverage.
Leave acquisition limits and RF timing unchanged.
Co-Authored-By: OpenAI coding assistant <noreply@openai.com>
Signed-off-by: nip <182409448+nip-was-here@users.noreply.github.com>
At fc/2 the subcarrier is a one-sample alternation and pskRawDemod_ext finds
wave tops one sample at a time, unfiltered. On a weak tag, sample noise erases
tops; a wave then reads as four samples and counts as a phase shift, and the
bit stream fills with errors although every bit is still in the trace. A T5577
Indala at 22 mm gave the wrong card on 14 of 50 lf search reads.
PSKDemod keeps the tracker's result whenever it is clean, so nothing changes
where master already works. Otherwise, for fc/2, it tries the existing coherent
receiver pm3_psk_demod (now with an optional per-symbol magnitude output) and
keeps that only if it scores well above what level-step leakage can produce,
its bits aren't doubled or constant, and no symbol is weak. The receiver's
output is differential, so one bad decision would flip every later bit: a weak
symbol refuses the trace rather than risk a wrong card (absolute decisions with
weak symbols left to maxErr were tried and gave wrong IDs on dropouts). With no
usable clock from the caller, candidate clocks are tried largest first. Polarity is voted from the
raw level over each phase reversal, the cue pskFindFirstPhaseShift reads at the
first one. Client only; firmware is unchanged.
Base vs this change, same captures:
- T5577 Indala, live lf search: 22 mm 3 right / 14 wrong -> 50 / 0; 24 mm
0 / 2 -> 50 / 0; 26 mm and 0-20 mm unchanged
- lf t55xx dump, live: 22 and 24 mm blocks 0-2 and page 1 correct 5/5 where
master reads nothing; unchanged where master reads
- emulated Indala (Chameleon Ultra, clock drifting against the reader):
lf search right / wrong 56 / 130 -> 91 / 95 of 200; every one of the 95 is
master's own wrong ID on the same capture
- 27 PSK traces in traces/, weakened with Gaussian noise: correct 341 -> 636 of
810, wrong IDs 83 -> 21; with recorded Proxmark noise 367 -> 553 of 648,
33 -> 27. No lost reads and no new wrong IDs in either
- traces/lf_*.pm3 (99): lf search -1 and -1 -c output identical; 1,581
non-PSK probes: lf search and lf t55xx detect identical
- 200 empty-field captures: no decode, either build
tools/pm3_tests.sh: a weak 24 mm Indala trace must read its ID (fails on
master), and a synthetic NRZ with an fc/2 ripple must not decode as a tag
(the level-step leakage the score check rejects).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add bidirectional conversion between DFC v4 credentials and mfdes v1 JSON, with documentation and round-trip coverage. Include H10301 FC69 CN420 factory and field fixtures and an external HID reader test target.
Co-Authored-By: GPT-Daybreak Blue <noreply@openai.com>
PLATFORM=PM3ULTIMATE has not built since c0ecb1c62 (2026-04-14), which
fixed a real heap overflow by changing one character:
- if (total_size > num_infiles * FPGA_CONFIG_SIZE) {
+ if (total_size >= num_infiles * FPGA_CONFIG_SIZE) {
The old '>' checked after the fact, so a round could start with the
buffer already full and write num_infiles * FPGA_INTERLEAVE_SIZE bytes
past the end. But '>=' answers the wrong question: a buffer that is
exactly full is not an error, it is the expected end state for a
platform whose bitstreams are sized to FPGA_CONFIG_SIZE.
Two things had to change.
all_feof() tested the EOF flag, and C only sets that once a read has
already run off the end -- consuming the last byte of a file leaves it
clear. A file whose length is an exact multiple of FPGA_INTERLEAVE_SIZE
therefore still looked unfinished after its final whole chunk, and the
interleave loop ran one more round of pure zero padding. It now peeks a
byte with fgetc/ungetc instead, so a file read to its last byte counts
as finished right away.
PM3ULTIMATE is the only platform this reaches:
fpga_pm3_ult_felica.bit 69984 = 243 * 288 exactly
fpga_pm3_ult_hf_15.bit 69983
fpga_pm3_ult_hf.bit 69980
fpga_pm3_ult_lf.bit 69980
243 rounds * 4 files * 288 = 279936, which is exactly
4 * FPGA_CONFIG_SIZE for 2s50vq144. Round 244 was padding only, and '>='
killed it there. Stock PM3's largest bitstream is 42172, not a chunk
multiple, so its last round trips feof naturally and it never gets that
far -- which is why this went unnoticed, nothing in CI builds ULTIMATE.
The guard now asks whether the next round fits, which is the condition
it was always meant to express and is strictly stronger than the
original '>':
if (total_size + (num_infiles * FPGA_INTERLEAVE_SIZE) > num_infiles * FPGA_CONFIG_SIZE)
Verified: PM3ULTIMATE compresses 279936 bytes to 40195 and all four
bitstreams decompress back byte-exact. Output is byte-identical to
before for stock 2s30vq100 (169344 -> 106628), for icopyx XC3
(72864 -> 27292) and for the '-s' .data section path. fullimage builds
for PM3ULTIMATE, PM3RDV4, PM3GENERIC and PM5.
Note FPGA_CONFIG_SIZE is now exactly the size of the largest ULTIMATE
bitstream. Regenerate that one byte larger and the guard fires again,
correctly; bump the constant by one interleave step rather than touching
the guard.
Co-Authored-By: Claude Opus 5 (1M context)
zlib_decompress() walks its output in whole FPGA_INTERLEAVE_SIZE chunks:
for (long k = 0; k < *outsize / (FPGA_INTERLEAVE_SIZE * num_outfiles); k++)
so a stream that is not a whole number of chunks loses its trailing partial one.
With two or more inputs the read loop zero-pads each stream past EOF and the
total lands on a boundary, but the padding was guarded by 'num_infiles > 1', so
the single input case was left ragged. 42172 bytes of fpga_pm3_hf.bit is 146.43
chunks, and -d handed back 39788 - a clean looking prefix, short by 2384 bytes,
22 of them real bitstream data.
Gate the padding on single_block instead. It must not be 'always pad': -s is the
.data section, and start.c's uncompress_data_section() sizes the decompression
with __data_end__ - __data_start__. Rounding .data from 14944 up to 14976 makes
LZ4_decompress_safe() return an error, and that path is the LED panic loop, so
the firmware would never reach AppMain().
1 bitstream 42172 in -> 42336 packed, -d round trip byte identical,
archive 28730 -> 28731
4 bitstreams archive byte identical to 43fe6c3eb, round trip exact
-s .data byte identical to 43fe6c3eb on the same input, unpadded
The 164 padding bytes never reach the FPGA: DownloadFPGA() shifts out only
bitstream_length bytes, taken from the .bit 'e' section header.
Also simulated the ARM decoder over the new archive - LZ4_decompress_safe_continue()
block by block into a FPGA_RING_BUFFER_BYTES buffer - 3 blocks of 16384/16384/9568,
none over the ring buffer.
Co-Authored-By: Claude Opus 5 (1M context)
The 1 MB block branch exists for the ARM .data section: start.c's
uncompress_data_section() reads one 4-byte length and does one
LZ4_decompress_safe(), so .data has to arrive as a single block. It was
selected by 'num_infiles == 1', which is not what tells the two callers apart.
A build that skips LF, FeliCa and ISO15693 leaves FPGA_BITSTREAMS holding just
fpga_pm3_hf.bit, so the bitstream took that same branch and was packed as one
42 kB block. get_from_fpga_combined_stream() decompresses into a
FPGA_RING_BUFFER_BYTES buffer, 16 kB since 83c3f81b1:
[#] inflate returned: -13247
[#] reset_fpga_stream failed
Before 83c3f81b1 the copy was clamped with MIN(FPGA_RING_BUFFER_BYTES, ...)
whatever buffer_size said, so the blocks came out at 30 kB and the 30 kB ring
buffer still took them. That is why the commit looks like the cause - it only
removed the clamp that was covering for the wrong branch.
Add -s for the single block case and let the FPGA path always chop at
FPGA_RING_BUFFER_BYTES, however many bitstreams went in:
4 bitstreams 169344 in -> 106933 out, byte identical to before
1 bitstream 42172 in -> 28718 out, 3 blocks 13265/13206/2247,
was 1 block of 27627
.data (-s) 14944 in -> 8786 out, byte identical to the
obj/fullimage.data.bin.z in tree
Also hand the ring buffer back when reset_fpga_stream() fails. The early
return left it allocated for the rest of the session, which is the reporter's
[#] BigBuf_size............. 48116
[#] Available memory........ 31732
48116 - 31732 is 16384, exactly FPGA_RING_BUFFER_BYTES.
No CAPABILITIES_VERSION bump: fpga_all.bit.z is objcopy'd into the same
fullimage as the decompressor that reads it, so nothing here is client facing.
Reported and correctly diagnosed by @ewangsoft.
Fixes#3599
Co-Authored-By: Claude Opus 5 (1M context)
The six plain/mac assertion pairs differed only by -m, and the file they ran
against was created with no --amode and no --rawrights - so plain mode, free
access. Free access is served in plain whatever the file says, and the client
derives the mode from the file settings rather than from -m, so both halves of
every pair sent the same bytes:
--op credit -m mac -> 90 0C 00 00 05 02 0A 00 00 00 00
--op credit -m plain -> 90 0C 00 00 05 02 0A 00 00 00 00
They passed on a client that could not do MAC mode at all, which is how
e1598cd62 shipped: it had removed CREDIT/DEBIT/LIMITED_CREDIT from
EV1D40TransmitMAC, and this suite stayed green.
Build a fixture that makes the client answer a different question per file
instead, and drop the -m flags, since deriving the mode is the thing under
test:
data 00 mac EEEE free access, MACed file
data 01 mac 0000 key protected
data 02 encrypt EEEE free access, enciphered file
data 03 encrypt 0000 key protected
value 10 mac 00E0 credit plain, debit MAC, same file
value 11 mac 0000 key protected
value 12 plain EEEE the original case
value 13 encrypt 0000 plus FreeValue, so GetValue is plain
File 10 is the one worth having: credit is granted by read & write only, which
is free there, while debit is also granted by the write right, which is key 0.
A single communication mode for the whole file cannot satisfy both.
Also dump the application. It has no ISO file ids, so the client's
GetISOFileIDs probe is refused and the PICC ends the session on it; a dump
that does not notice reads the first file's plain content as a response CMAC
and reports it as no data.
Checked against a client built at 08e389c0b, before the three fixes: the free
access data writes fail -20, the MACed value credit fails -20, and the dump
loses file 00. The 00E0 and FreeValue cases pass there too - they guard the
derivation against future regressions rather than reproducing an old bug.
Co-Authored-By: Claude Opus 5 (1M context)
A card runs the protocol its TD1 names until a PPS changes it. --t1 only
picked the module's T=1 send opcode, so on a card whose ATR offers T=0 first
the APDU went out as T=1 blocks to a card still speaking T=0 and got no
answer at all:
smart raw --t1 -s -d 00a4040007a000000004101000
[!] smart card response failed
'smart pps --t1' in the same client session made it work, which is what the
help for 'smart pps' already promised was unnecessary:
Note 'smart raw --t1' already switches a card to T=1 by itself when
the ATR offers it; this is for negotiating Fi/Di explicitly.
Do it for real. SmartCardRaw() now runs the PPS when T=1 is asked for and
nothing has selected it yet, taking the ATR it needs first because PPS is
only legal in that window. It fires once per activation: a second --t1 apdu
sees the protocol already in force and sends straight away. A card that does
not offer T=1 is left alone and the apdu still goes out, as before.
Also fix the flag names in the docs and in the error path. 'smart raw's
first example and both 'Choose either' messages said -0 / -1, which have
never existed. tools/pm3_online_tests.sh had copied the example, so its T=0
checks failed with 'invalid option' on every run; its T=1 checks needed no
change beyond dropping the now unnecessary reset.
Co-Authored-By: Claude Opus 5 (1M context)
Three ways this command reported a credential that was not on the tag.
CmdIdteckDemod always passed its local raw[8] to demodIdteck, never NULL, so
without --raw the command decoded a zeroed stack array rather than the
graphbuffer and reported card id 0 every time. The help's own first example,
plain `lf idteck demod`, has been doing that since --raw was added. It now
passes NULL when no --raw is given, which is the signal path demodIdteck
already has and lf idteck reader already uses.
A raw frame whose first word is not 4944544B printed "No genuine IDTECK found"
and then fell through and announced a tag anyway, with a card id read out of
whatever was passed in. It now stops there. The signal path cannot reach this:
detectIdteck matches the full 32 bit preamble, so lf search and lf idteck
reader are unaffected.
Finally the Idteck card id was packed into a 26 bit wiegand_message_t and run
through HIDUnpack, which prints an HID H10301 line with a facility code and
card number. That is not a decode of anything - the id is 24 bits, byte
reversed off the wire, and Unpack_H10301 returns true for any 26 bit message,
so the parity flag is the only hint and it reads ok for 25% of card ids by
chance. Both committed Idteck traces show it: 4944544B351FBE4B prints
FC: 37 CN: 57103 parity ( ok ), AC40E069 prints FC: 52 CN: 61472 parity
( fail ). Dropped, with the wiegand_formats.h include that came in with it.
Added five offline regression tests. Three fail without this change, one per
defect; lf search over every committed lf trace is byte identical before and
after apart from the two removed H10301 lines.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
restore_bufferS32() returns the length it put back and every graph-buffer
caller dropped it, so g_GraphTraceLen kept whatever value the code between
save and restore had left.
In try_detect_modulation() that is the 160 sample psk antenna-settle trim:
`data modulation` gave the buffer's samples back but left it 160 short, and
a following demod lost round(160 / clk) bits off the end. check_chiptype()
loses the same way through the acquisitions its detections make, on the
`lf search` path, and for g_DemodBuffer too. demodTI() loses convLen + 16
on its error path.
save_graphbuffer() / restore_graphbuffer() pair the length and grid offset
with the contents so no call site has to remember them. The visa2000 and
zx8211 sites do not change the length, so converting them is a no-op today
and keeps the next one from being a bug.
Regression test in tools/pm3_tests.sh: `data modulation` on a saved psk1
trace must leave all 20000 samples.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Simulation now completes the full exchange with a genuine Paxton reader in
password mode, and crypto mode read/write passes Proxmark-to-Proxmark.
Firmware:
- SOF was one bit period short. The lead-in that compensated for the lost
head half bit was removed and nothing replaced it, so readers rejected
every answer with a second START_AUTH. Default is now 6.
- The edge-detect threshold was latched before being measured, so the value
chosen depended on whether the Proxmark was in a field when sim started.
It is now measured on field entry and re-armed when the reader leaves.
- The percentile walk latched on run-scoped variables, so one attempt made
outside a field poisoned every later one.
- Field loss was detected from TIMESTAMP, which is free-running MCU time and
never stalls. Detect it from receive silence instead.
- Frames of a length the protocol does not have no longer reach the state
machine; our own modulation tail was resetting the session and breaking
every write.
- A dropped edge merges two or three reader bit periods into one gap. Those
bits were discarded; they are now recovered by decomposition, which is what
made crypto mode work (AUTH decode 15% -> 100%).
- Threshold selection is limited to 20 and 32 and settles in under 25 ms.
Client:
- lf hitag info printed a hardcoded 0x06 and reported 'Password mode' for
every tag. It now reads page 3, takes -k (4 bytes password, 6 bytes
crypto), and says so when the config cannot be read.
- lf hitag restore: writes a dump back in dependency order - user pages,
then key material, then config last - validates the config byte, and
prints the credential the tag will require afterwards.
- lf hitag crack2 now reports why it failed instead of a bare 'fail'.
- trace list: bit count moved to its own column, relative mode shows a
Frame Delay Time row rather than renaming Start/End, --frame and -r
rejected together.
Adds support for more attribute types and safe
error handling for unknown types. Fixes a bug
where the version attribute didn't increment the
cursor correctly causing an infinite loop.
9303 Part 4, positions 29 to 42: "Any special characters, including spaces,
in the personal identification number ... shall be replaced by the filler
character (<). The number shall be followed by the filler character (<)
repeated up to position 42."
So the field holds two different kinds of filler. The trailing run is
padding, which was already stripped, but a filler inside the number stands
for a space or special character substituted on the way in, and those were
printed as they came - a US passport showed its personal number with a '<'
in the middle of it.
Strip the padding, then put a space back for what remains. It is the
closest recovery available: the original could have been a hyphen, and the
MRZ does not keep which.
optional_data itself stays a faithful copy of the field. Nothing else
reads it, and it is the personal number that is being rendered here.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ICAO spills a document number longer than nine characters into the
optional-data field: positions 1 to 9 hold the first nine, position 10 a
filler in place of the check digit, and the optional field opens with the
rest of the number and the check digit for the whole of it.
_extended_document_number() already puts that back together and returns
the optional field with the overflow removed. _parse_td3() bound that
fourth value and then ignored it, re-slicing l2[28:42] raw, so the tail of
the document number stayed in the optional field. From there it was
reported as the holder's personal number, which falls back to the MRZ
optional-data field when DG11 carries none - a 12-character number showed
its last three digits and a check digit as a personal number.
Use the value the function already returns. The check digit still answers
for the field as transmitted, overflow included, since that is what the
MRZ actually carries.
_parse_td1() has always used the return value, which is where the intended
shape comes from. _parse_td2() does not call the helper at all, so TD2
carries no support for long numbers; that is a gap rather than this bug and
is left alone.
Found while checking the decoder against ICAO 9303 Part 4. Nothing else
came out of that: the composite check digit covers lower-line positions
1-10, 14-20 and 22-43 as the spec requires, verified by mutating all 43 and
confirming that nationality and sex are ignored and every other position is
caught; the 7-3-1 digits agree with an independent implementation across
four real TD3 documents.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The tab headers carried their file names as fixed text - "Additional
personal details · EF_DG11" - so a Polish passport, which ships DG13 and
no DG11, was told its details came from a file it does not carry. The
ISSUER header claimed EF_DG12 on the same document, and SECURITY listed
EF_DG15 whether or not it was there.
personal_files, document_files and security_files report what each tab drew
from, and the pages compose their header from those. They sit on the
record rather than in the widgets so they can be tested without a display,
which is how the rest of the suite is built.
PERSONAL names EF_DG1 when the personal number came from the MRZ, that
being the file which supplied it, rather than crediting DG11 for a value
DG11 did not provide. With nothing read the header stays the bare
description: the record is an empty PassportRecord at startup rather than
None, and reporting an absence on a chip nobody read reads as a fault.
"none present" rather than "nothing on this chip", since the app opens
offline dumps too.
The same document showed the other half of this: "Personal number (from
DG13)" renders 203px against a dp(190) caption column, so it wrapped and
left the source on a line of its own. Without the "from" it is 167px.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>