* Shell script NOT updated to use an atomic rename after writing to temp file. Don't commit if it's not right.
* Shell script `set -e` is now `set -euo pipefail`
* Shell script uses short-form options for `sort`
* Three typos fixed in markdown
* .gitignore updated to ignore codeql trash
run `hf saflok decode` twice ... and it will run old decoder one time, and new decoder the other time. Makes it easy to compare side-by-side in this interrim build.
* Small, testable functions
* `set_` functions return boolean so they can indicate out-of-bounds values and similar failures.
* const-correctness for all helper functions
Note: The new functions are NOT used extensively yet ... they still need testing. But they should make the code more self-documenting / readable (if somewhat verbose).
Again, these should have zero impact on resulting
instructions. At the same time, this will enable
static analysis to more accurately validate a buffer
(here `saflock_mfc_data_t`) points to sufficiently
large allocated memory.
Additional validation for `extract_bits()` and
`insert_bits()` will prevent accidental corruptions
(and assert, if assertions are enabled).
These changes also makes the code easier to follow.
This should have zero effect on an optimized build,
as there are effectively zero changes to the instructions.
Rather, this provides greater clarity as to the size of buffers
being passed to various functions, which improves the
long-term maintainability of code, especially when
maintained by someone other than the original author.
* Add its own CMakeLists.txt
* Add id48 unit tests for its recovery API
* Add id48 unit tests for its generator API
* Add id48 espresso files, generator for those files, and validation test
* Proxmark3-specific:
* update client/Makefile
* update client/deps/id48lib.cmake
*
Parity was always used for commands, even when the code seemed to suggest it was optional. This was due to a bug in `LIW` delays sending 1.25 bits too early, coupled with the parity bit happening to align with non-transmission when needed.
Parity option was deprecated earlier, and now is fully removed.
* Change from 40 FC to 72 FC as default delay between detecting LIW and sending the command.
* Use parity for ID, UM1, and UM2 commands
* Remove extra bit hack from AUTH, PIN, and WRITE commands
1. Rework how communications with tag occur.
a. bitstream to be sent to the tag is now fully pre-generated.
b. bits sent and received are logged with start / end times.
2. Support built-in `hw dbg` for controlling verbosity of debug output
The new bitstream generation and logging has exposed a surprising legacy behavior ... each of the command that sent additional data (beyond the command) were:
* inserting an extra RM zero bit
* force-enabling command parity is used
This was not expected. However, this PR maintains the behavior of the existing code.
TODO: Root-cause why the third RM bit is needed. Fix code to remove that hack.
TODO: change the arm/client interface to ONLY use arrays of bytes, with well-defined content endianness, to avoid this problem.
Code was previously performing arithmetic in
various loop check conditions. Integer promotion rules could cause unintended comparisons.
`spiffs` defined `fs->block_count` as `uint32_t`, but defined `spiffs_page_ix` as `uint16_t`. Various overflow checks detected by CodeQL and fixed by checking for those conditions before looping.
This was done programmatically using python.
The `lf_Keri.pm3` was in range `[-508 .. 491]` (1000 value range).
Each value was divided by four, cast to integer, and then adjusted by +1 (to center the values).
The data plot in the pm3 client now shows discernible changes in amplitude.
The resulting samples are all within range [-128,127].
This final fix allows ALL sample `.pm3` traces to be converted to one-byte-per-sample binary format.
This was done programmatically using python.
Files with a range that fell outside of [-128,127], but which would fit into that range, were offset by the noted amount to ensure the file woul now fit within range [-128,127]. This allows the trace files to be converted to one-byte-per-sample binary format, for example.
offset | filename
-----|-----
`-14` | `lf_Q5_mod-manchester.pm3`
`-14` | `lf_Q5_mod-nrz.pm3`
`-10` | `lf_Q5_mod-fsk1.pm3`
`-15` | `lf_Q5_mod-biphase.pm3`
`-9` | `lf_Q5_mod-fsk2.pm3`
Avoid generic "length" parameters, as they are often ambiguous.
Prefer `byte_count`, `element_count`, `bit_count` or more explicit names to reduce misunderstandings and thus reduce bugs.
This autorecovery test key also has three potential matches
for the last phase, thus ensuring authentication test is
required to determine which of those keys was actually used.
Also:
* common.h: Increase safety of some of the macros.
Parenthesizing the macro parameters ... a best practice.
* firmware: partially-tracked source of "extra bits" messages.
Add a TODO comment for further study.
* Improve reliability of `lf em 4x70 writekey`
Authenticate w/new key after it is written.
Particularly important for glass modules,
or other tags with weaker coupling.