Sector trailers are now checked for errors.
Writes should not go through if for whatever reason ACLs provided to write are invalid.
Reminder that ACLs are checked on the 4-byte method of MFP with the encrypted-only exchange byte.
Signed-off-by: team-orangeBlue <63470411+team-orangeBlue@users.noreply.github.com>
Mifare Plus has an extra byte for ACL payloads.
That byte controls if data exchange can be plaintext or must be encrypted.
Support for decoding is added in this commit.
Signed-off-by: team-orangeBlue <63470411+team-orangeBlue@users.noreply.github.com>
Improved hf secc to use default apdu reply from the json file and not the hardcoded one (used as fallback now).
Removed old hardcoded functions no longer in use.
Leveraging doMAC_brute for speed gains.
Precomputation (lines 330-346): Before the loop, sel_brute_idx[i] is set to the brute-byte index j if key_index[i] == bytes_to_recover[j], or 0xFF if that key_sel position is from a already-cracked constant entry. Fixed positions are filled into key_sel once here.
Hot loop (lines 356-361): Replaces:
numbytes_to_recover keytable writes + 8 keytable reads + 8 & 0xFF masks
With: up to numbytes_to_recover (1-3) direct shifts from brute — no keytable touches at all.
Success path (line 386): (brute >> (i * 8)) & 0xFF recovers the exact byte value that was just used for the winning iteration, equivalent to the old keytable[bytes_to_recover[i]] & 0xFF which was the same value that had just been written into the keytable from brute.
Optimized `hf iclass legbrute` throughput: replaced recursive `suc()`/`output()` cipher functions with iterative loops, added 256-entry LUT for the `select()` function eliminating redundant bit arithmetic and halving key lookups per state step, switched successor state to in-place pointer update removing per-call struct copies, added `doMAC_brute()` with byte-wise LSB-first processing and direct output bit packing eliminating all bitstream struct overhead and output reversal calls per key candidate, and replaced per-iteration 64-bit modulo progress check with a countdown counter
Improved `hf iclass legbrute`: fixed multithreaded key-range partitioning so threads cover non-overlapping slices of the 40-bit keyspace, added ETA display, keyboard abort with resume hint, `_Atomic` correctness for shared state, `pthread_create` error handling, and thread count capped at available CPUs .