Commit Graph
22731 Commits
Author SHA1 Message Date
Antiklesys a47bdebc87 Extended T=1 support
Extended T=1 support with TA1=95 and T1_IFSD_WANTED 254
2026-08-31 15:28:49 +08:00
Iceman be7f55f72b Merge pull request #3555 from munzzyy/fix/xerox-view-info-block-oob
Fix heap out-of-bounds read in hf xerox view on short dump files
2026-08-31 03:50:44 +07:00
Philippe Teuwen c356ce7f14 Restore client and fw capabilities version parity 2026-08-30 22:42:52 +02:00
Cole Munz 18936b2188 Fix heap out-of-bounds read in hf xerox view on short dump files 2026-08-30 15:39:45 -05:00
Iceman 5a1d93a2a4 Merge pull request #3557 from Antiklesys/master
Bugfix: stale ISO14443A scheduler delay
2026-08-31 02:19:43 +07:00
Antiklesys d4c68ec9fb Refactor comment for clarity on time base synchronization
Condensed comment about keeping the absolute transfer scheduler in sync with the time base.

Signed-off-by: Antiklesys <syselkitna@gmail.com>
2026-08-31 03:19:02 +08:00
Iceman ff94b8b376 Merge pull request #3554 from actuallysparky/codex/emrtd-sod-stack-overflow
fix(eMRTD): move EF_SOD parser buffers off the stack
2026-08-31 02:18:08 +07:00
Antiklesys e5f6f39a04 Update iso14443a.h
Signed-off-by: Antiklesys <syselkitna@gmail.com>
2026-08-31 03:17:40 +08:00
Antiklesys aadefed412 Refactor comments in iso14a_rebase_transfer_time
Updated comments for clarity regarding NextTransferTime handling.

Signed-off-by: Antiklesys <syselkitna@gmail.com>
2026-08-31 03:16:51 +08:00
Iceman 7a56985ba5 Merge pull request #3556 from nieldk/master
Change Dbprintf to display voltage in mV instead of V
2026-08-31 02:16:43 +07:00
Antiklesys 9479340e19 Bugfix: stale ISO14443A scheduler delay
Internal Card-API code restarts the SSP clock before every RF APDU, resetting it to zero. ISO14443A retains NextTransferTime as an absolute timestamp from the prior clock instance, so each next transmit waits for stale time.
2026-08-31 02:57:12 +08:00
Niel Nielsen bd62f03669 Change Dbprintf to display voltage in mV instead of V
Signed-off-by: Niel Nielsen <nieldk@gmail.com>
2026-08-30 20:47:31 +02:00
Iceman 8e405a7fe8 Merge pull request #3550 from pkilar/epassport-startup-segfault
Fix ePassport viewer segfault on startup
2026-08-31 01:26:28 +07:00
Paul KilarandClaude Opus 5 dc718d3e29 ePassport: fix the segfault on startup
The app died with SIGSEGV before drawing anything, on every entry point
including --help.

The window minimum size was pre-seeded into Kivy's Config, and
WindowBase.__init__ is the only place Kivy reads it - so it was applied from
inside WindowSDL.create_window(), while Window.initialized was still False.
If the window SDL has just made is smaller than that minimum, SDL resizes it
on the spot; the resize comes back through the SDL event filter into
EventLoop.idle(), which runs the clock and re-enters create_window(). Still
not initialised, that call runs setup_window() again and resizes again, until
the C stack gives out.

A scaled HiDPI session is enough to reach it: with sdl2-compat on SDL3 under
Wayland sizes come back in logical points, so the inherited 800x600 default
arrives as a 500x375 window, under the 760x520 minimum. Set the minimum on
Window once it exists instead, where the same resize takes Kivy's cheap
already-initialised path.

That exposed a second fault on the same path. _install_kivy_logging attached a
bare StreamHandler() to Kivy's own logger, and kivy.logger replaces sys.stderr
with a stream that feeds whatever is written to it back in as a warning -
kivy/logger.py cautions about exactly this. Any warning _KivyNoise did not
drop answered itself until the recursion limit stopped it, with stderr as the
broken part, so nothing legible came out. Not theoretical: this machine logs
"MTD: Unable to open device" at startup, which would have killed the app as
soon as the segfault was out of the way. Point the handler at the real stderr,
which Kivy leaves alone.

Behaviour change: a window that opens smaller than 760x520 is now grown to it,
rather than the constraint being imposed while the window is built.

Testing: 257 passed, 2 skipped (was 254/2); --help, a plain launch, --dump on
a generated sample and -v all start and stay up; black clean. Python-only
change, so no client or firmware build matrix applies.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-30 14:17:37 -04:00
iceman1001 9e2092fc66 capabilities: report device frame size so the client can adapt
PM3_CMD_DATA_SIZE went 512 -> 624 without a capabilities bump, so a new
client connects to old firmware and every oversized command dies at the
device's length check with no message.

Append max_cmd_data_size, bump to v9. The client now accepts an older
capabilities struct - it only ever grows by appending, so an older layout
is a prefix - and defaults the frame size for pre-v9 firmware.
SendCommandNG bounds by the device value instead of the compile time one.

Also zero init capabilities_t on the device, it leaked stack bytes.
2026-08-30 20:13:38 +02:00
SparkyandCodex 879a4bd273 fix(eMRTD): avoid EF_SOD parser stack overflow
Allocate EF_SOD parsing scratch buffers on the heap so macOS worker threads do not exceed their stack while reading protected travel documents.

Co-Authored-By: Codex <noreply@openai.com>
2026-08-30 10:48:29 -07:00
iceman1001 6d2c35b05b The slight increase of array size makes us use the usb packages the AT91 sends which is 64bytes of size. We maximizing the available bytes basically and it comes with a slight cost of .bss and stack cost. Making bigbuff just abit smaller. We gain: 600 kBs -> 630 kB/s and less number of frames being sent over the wire. \n\nWhen it comes to Pm5 it will need to find its own aligned size to optimize transfers 2026-08-30 19:21:28 +02:00
iceman1001 b7bd6ddadb fix return value that break 'hf search', Thanks @atk! 2026-08-30 19:11:37 +02:00
Iceman 70aa0309e7 Merge pull request #3553 from nieldk/master
Updated BWM usage doc
2026-08-30 23:41:50 +07:00
Niel Nielsen 50b94cf01b Add files via upload
Signed-off-by: Niel Nielsen <nieldk@gmail.com>
2026-08-30 17:36:56 +02:00
iceman1001 26d85264d3 add some more output for speed check 2026-08-30 16:55:15 +02:00
iceman1001 ca5913a2db text 2026-08-30 16:54:20 +02:00
Niel Nielsen fd81dbd10a Add files via upload
Signed-off-by: Niel Nielsen <nieldk@gmail.com>
2026-08-30 15:24:08 +02:00
Niel Nielsen e6220a828f Add files via upload
Signed-off-by: Niel Nielsen <nieldk@gmail.com>
2026-08-30 15:24:08 +02:00
Niel Nielsen 8efb7e5b51 Add files via upload
Signed-off-by: Niel Nielsen <nieldk@gmail.com>
2026-08-30 15:24:08 +02:00
Philippe Teuwen 519e0f6de9 pm5_battery_test: misc fixes 2026-08-30 14:11:47 +02:00
iceman1001 52eb6118e7 text 2026-08-30 14:03:26 +02:00
iceman1001 6d67465d7d hf plot: convert CMD_FPGAMEM_DOWNLOADED to NG
The FPGA trace loop was the last OLD reply on the device outside the two
the bootrom also serves. It stayed OLD because the DMA double-buffer was
sized to the frame payload and an NG header did not obviously fit in
front of it.

DMA straight into chunk->data of a download_chunk_t instead, so a filled
buffer is already a complete NG payload and needs no copy. Chunking now
follows DOWNLOAD_CHUNK_MAX and scales with PM3_CMD_DATA_SIZE. The
terminator carries download_done_t like the other bulk downloads. No
client change needed, dl_it already had the NG branch.

Two fixes fall out of it:

FPGA_TRACE_SIZE is 3072, an exact multiple of 512 but not of
DOWNLOAD_CHUNK_MAX. Each transfer is now armed for exactly the bytes
still expected - arming a full chunk for the short last one would spin in
FPGA_SSC_DMA_RX_Done() forever. This also drops the stray extra DMA the
old loop left armed.

get_tosend() moved after FpgaDownloadAndGo(). The loader calls
BigBuf_free(), which nulls s_toSend.buf, then reuses that same region for
its decompression ring buffer - the old code captured the pointer before
the free and only worked because the loader was done with it in time.

3072 bytes goes from 6 OLD frames to 7 NG frames at PM3_CMD_DATA_SIZE
512, and would be 5 at 688.
2026-08-30 14:02:18 +02:00
Philippe Teuwen aa052ca444 pm5_battery_test: fix missing arg 2026-08-30 13:58:20 +02:00
Philippe Teuwen bf32513d1b pm5_battery_test: merge nieldk version and add test scenarios 2026-08-30 13:44:46 +02:00
iceman1001 1d87a6c192 chunk CMD_READ_MEM_DOWNLOADED by the OLD frame size reply_old clamps its payload to PM3_CMD_DATA_SIZE_OLD but the sender still
chunked by PM3_CMD_DATA_SIZE. Identical today, but if the NG size moves the
chunk would be built oversized, truncated on the wire, and still announced
at full length in oldarg[1] - the client would copy past the valid bytes and
advance by the wrong stride. Bound the client's OLD download branch by the
same constant.
2026-08-30 13:33:50 +02:00
iceman1001 ed066d84aa 'hf mfu cchk' - widen 3-pass chkkey nkeys to a full byte
nkeys was a 6 bit field but the client chunked by what fits in a frame -
123 keys in segment mode. nkeys wrapped to 59 while memcpy copied all 123
and the loop advanced by 123, so 64 of every 123 keys were never tested
and never reported. Full key mode was unaffected, it chunks 30.

Give nkeys its own byte. MIFAREU3P_CHKKEY_HEADER goes 18 -> 19, costing
one byte of payload, and segment mode chunks 123 again

Payload layout changed: client and firmware must be updated together.
Thanks Claude!
2026-08-30 13:25:50 +02:00
iceman1001 25d958e5e6 split PM3_CMD_DATA_SIZE_OLD out of PM3_CMD_DATA_SIZE
The OLD frame size was tied to the NG one, but the bootloader only speaks
OLD - growing PM3_CMD_DATA_SIZE would silently change sizeof(PacketCommandOLD)
and break flashing against every deployed bootrom in both directions.

Pin the OLD structs to their own constant and use it on every OLD path:
reply_old and the OLD receive branch on both sides, the bootrom, and the
flasher's write_block/send_finish_write_cmd, which memcpy into a
PacketCommandOLD using the NG size.

No behaviour change - both constants are 512 and armsrc .text is
byte-identical before and after.
2026-08-30 13:03:53 +02:00
iceman1001 50c63690cd iso15693: share one response buffer across the reader helpers
Each helper had its own uint8_t recvbuf[ISO15693_MAX_RESPONSE_LENGTH],
2116 bytes, and the SLIX/AFI helpers nest up to three deep - write_afi
-> set_pass_Slix -> set_pass_SlixRnd put over 6 kB of the 8.4 kB stack
into one chain. No helper reads its response across a nested call, so
one shared buffer serves all of them.

Worst chain from AppMain 6848 -> 4544 bytes, measured with -fstack-usage.
Costs 2120 bytes of bss, so BigBuf goes 35108 -> 32988.

SimTagIso15693 keeps its own buffer, it does not nest.\n Thanks Claude!
2026-08-30 12:06:51 +02:00
iceman1001 2f6cb9e45c text 2026-08-30 11:36:17 +02:00
iceman1001 87cea09fd7 don't inline version info on device side, keeps 1.5kB out of the AppMain stack frame
SendVersion holds three PM3_CMD_DATA_SIZE sized buffers. Inlined into AppMain they sat in its frame for the whole main loop, not just while CMD_VERSION was handled. Marking it noinline makes the frame transient.

AppMain frame 2160 -> 1160 bytes, measured with -fstack-usage.  Thanks Claude!
2026-08-30 11:34:17 +02:00
iceman1001 2714628baf swap to bigbuf_calloc in pcf7939 Write on device side to lessen RAM footprint, Thanks Claude! 2026-08-30 11:29:39 +02:00
iceman1001 27dd62e329 use bigbuf_calloc to dynamic allocate sniffing arrays when iso15693 sniffing. Thanks Claude 2026-08-30 11:27:41 +02:00
iceman1001 d3f1c6dd5e fix proper calloc failure handling. Thanks Claude! 2026-08-30 10:19:59 +02:00
iceman1001 02f2c0ad34 fix a hidden starvation of bigbuf during long running sc sessions. Thanks Claude! 2026-08-30 10:12:33 +02:00
Iceman 26fcf38864 Merge pull request #3551 from Antiklesys/master
NULL-check fix
2026-08-30 14:48:52 +07:00
Antiklesys 49dd2478f1 NULL-check fix
iso14443a.c called BigBuf_calloc() and wrote to the result without checking it:

uint8_t *real_cmd = BigBuf_calloc(cmd_len + 4);
if (real_cmd == NULL) {
    return -1;
}
BigBuf_malloc returns NULL once s_bigbuf_hi - s_trace_len < chunksize. Since clear_trace() is never called anywhere in the SAM path — only from the four standalone 14a entry points — s_trace_len grows monotonically for the life of a session and can eventually starve that allocation. -1 matches the function's existing error convention, and callers already map apdu_len < 2 to PM3_ECARDEXCHANGE.
2026-08-30 14:27:45 +08:00
Philippe Teuwen 0197fe8484 Battery test graph: elapsed time 2026-08-30 00:06:13 +02:00
Philippe Teuwen 8017246fd5 Battery test scripts 2026-08-30 00:06:13 +02:00
Iceman 1d035e8643 Merge pull request #3498 from 0x6r1an0y/20260823-ndefnlen
Correct NLEN log message and empty record example
2026-08-30 04:28:30 +07:00
歐歪 910f6ba41f Update cmdhf14a.c
Signed-off-by: 歐歪 <brian20020925@gmail.com>
2026-08-30 03:46:41 +08:00
iceman1001 a1053ad70d New individual json dump file formats for ht1, ht2, htS, htU. '.bin' / binary format for hitag has been deprecated 2026-08-29 20:58:59 +02:00
Iceman dda9d7dd1c Merge pull request #3548 from nieldk/master
add hw bwmwifi status
2026-08-30 01:51:45 +07:00
iceman1001 009490134b revert 2026-08-29 20:37:18 +02:00
iceman1001 d1386baae2 honor T=x framing 2026-08-29 20:29:09 +02:00