Add inline comments throughout wiegand_formatutils and callers to explain
sentinel-bit stripping, HID transport framing, and the normalization contract
between input modes and downstream consumers.
Replace sim-only LF HID online tests with T55xx clone+readback flows and add
a full encode/decode roundtrip harness for hf mf encodehid, including sector
restore/cleanup and an optional --manual flag for external reader verification.
Extract the reusable Wiegand normalization and packing flow into
wiegand_formatutils and move existing callers onto that shared path.
This rebuilds the feat-wiegand branch as one focused commit against
upstream/master instead of trying to preserve the original commit chain.
Key changes:
- add shared helpers for plain binary, raw HID, new PACS, and formatted
Wiegand input
- centralize binary rendering used by cmdwiegand and PACS decode output
- update lf hid sim/clone to resolve one input mode through the shared
Wiegand layer and enforce the LF packed transport limit explicitly
- update hf mf encodehid to accept bin/raw/new/formatted Wiegand input
through the same normalization path
- preserve legacy raw HID transport behavior while clarifying the
packed-HID vs LF transport limits in error reporting
- add offline regression coverage for the new PACS decode output and add
interactive online targets for LF HID Wiegand and MIFARE encodehid
Validation performed:
- make client
- bash -n tools/pm3_tests.sh
- bash -n tools/pm3_online_tests.sh
- ./tools/pm3_online_tests.sh -h
- ./client/proxmark3 -c 'wiegand encode -w H10301 --fc 31 --cn 337'
- ./client/proxmark3 -c 'wiegand encode -w H10301 --fc 31 --cn 337 --new'
- ./client/proxmark3 -c 'wiegand decode --new 068F80A8C0'
- Add auto-detection fallback for MAC mode in value operations
When MAC mode fails with length errors, automatically retry with
plain mode for better compatibility across different card types
- Fix MAC transmission behavior for value operations
Remove CREDIT, LIMITED_CREDIT, and DEBIT from EV1D40TransmitMAC
array to match real card behavior and prevent authentication issues
- Change default algorithm from DES to 2TDEA
Real DESFire cards seem to use 2TDEA by default, improving
out-of-the-box compatibility with factory cards
- Update help text for value commands to follow client patterns
Standardize "Crypt algo (deft: 2TDEA)" format for consistency
- Add online test suite for DESFire value operations
New pm3_online_tests.sh script validates value file creation,
credit/debit operations in both plain and MAC modes with real cards