Commit Graph
100 Commits
Author SHA1 Message Date
Henry Gabryjelski 4d7b647050 Resolve github codepilot recommendations
* 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
2026-06-13 17:45:46 -07:00
Henry Gabryjelski 59c0ed976d Improve git blame by ignoring certain commits 2026-06-13 15:43:54 -07:00
Henry Gabryjelski 7fd1179c9a one more api ... even if silly... 2025-11-17 17:13:14 -08:00
Henry Gabryjelski c0bc988e91 saflok - more self-test capabilities 2025-11-17 17:05:55 -08:00
Henry Gabryjelski af7ec87092 fix typo 2025-11-17 15:42:20 -08:00
Henry Gabryjelski 35afc30e2f saflok - remove trailing \n from calls to PrintAndLogEx() 2025-11-17 15:38:30 -08:00
Henry Gabryjelski 4c10238707 saflok - removal of assert() per iceman request 2025-11-17 14:35:30 -08:00
Henry Gabryjelski 559d63cc35 Fix regression in expiration date handling 2025-11-17 14:30:03 -08:00
Henry Gabryjelski b95a9cf8b6 Saflok: Comment the two assert()s for why they are programmer errors that must cause client to exit. 2025-11-17 03:51:47 -08:00
Henry Gabryjelski 3560850e77 revert removal of waveshare 2025-11-17 03:23:55 -08:00
Henry Gabryjelski 4cb20bde5f saflok selftest -- get_/set_bitfield 2025-11-17 03:18:03 -08:00
Henry Gabryjelski c5cec7ba51 Implement significant portions of saflok selftest 2025-11-17 03:02:37 -08:00
Henry Gabryjelski c98bf9ad3a Fix a few bugs
Discovered by github copilot.
Verified actual bugs by a human.
Fixed by a human.
2025-11-17 02:34:28 -08:00
Henry Gabryjelski 87a144c46a Comments, improved function names, use of common get_days_in_month() function. 2025-11-17 02:02:19 -08:00
Henry Gabryjelski 02056c9515 Saflok - creation year is limited to 7 bits 2025-11-17 01:27:32 -08:00
Henry Gabryjelski 3bf51b1fd4 Migrate more fields to type-safe getter / setter routines 2025-11-17 01:27:32 -08:00
Henry Gabryjelski 444e19212e more use of type-safe routines for getting properties. 2025-11-17 01:27:32 -08:00
Henry Gabryjelski 3d0fe23c17 improved messaging for cards w/o variable keys 2025-11-17 01:27:32 -08:00
Henry Gabryjelski 700a109a8e Saflok: remove redundant CLIParserFreE(ctx) 2025-11-17 01:27:32 -08:00
Henry Gabryjelski dcf7c2dd33 side-by-side check of new vs. old decoding
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.
2025-11-17 01:27:32 -08:00
Henry Gabryjelski 11eaa017d4 Saflok: Fix datetime math helpers 2025-11-17 01:27:32 -08:00
Henry Gabryjelski 1cfeb79003 automated from make style 2025-11-17 01:27:32 -08:00
Henry Gabryjelski a535bdb0e7 list of needed self-test 2025-11-17 01:27:32 -08:00
Henry Gabryjelski cb4ba660ab framework for saflok selftest 2025-11-17 01:27:32 -08:00
Henry Gabryjelski 319339b4cd UNTESTED: Add lots of helper functions to get data into / out of saflok formats
* 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).
2025-11-17 01:27:32 -08:00
Henry Gabryjelski 4ce34c6c1e More type and bufferlen safety, and validation in bit manipulation routines.
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.
2025-11-17 01:27:32 -08:00
Henry Gabryjelski c60c15e184 self-document expr --> expiration 2025-11-17 01:27:32 -08:00
Henry Gabryjelski 5fc6f5275a More type safety for encrypt/decrypt 2025-11-17 01:27:32 -08:00
Henry Gabryjelski 72cf97c622 prevent buffer overrun ... assert with clear message instead. 2025-11-17 01:27:32 -08:00
Henry Gabryjelski 9579a2f4b9 change functions using UID and Key to use structs
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.
2025-11-17 01:27:32 -08:00
Henry Gabryjelski 563abf66ed Update id48lib
* 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
  *
2025-10-20 17:58:59 -07:00
Henry Gabryjelski 276a8bd15d Require fixed facility code for Simplex Grinnell 36-bit
And remove some comments per review.
2025-09-03 23:32:56 -07:00
Henry Gabryjelski 221f531c76 Update changelog 2025-09-03 16:39:10 -07:00
Henry Gabryjelski 55f5b124b2 Improved card limits validation
Unsupported features must have values in `weigand_card_t` data set to zero.
2025-09-03 16:38:42 -07:00
Henry Gabryjelski c389160dde Update name to match screenshot 2025-09-03 16:38:42 -07:00
Henry Gabryjelski 12aef961a2 _Static_assert() requires message
At least until C23, even if GCC allows it w/o errors being raised.
2025-09-03 16:38:42 -07:00
Henry Gabryjelski e6ed87072f HID Simplex 36-bit (Grinnell)
Likely more valid than legacy HID Simplex 36-bit?

There is no Issue Level ... previously defined Issue Level is actually two parity bits.
2025-09-03 16:38:42 -07:00
Henry Gabryjelski eb3a4df973 Column align fields
Allows for easier format comparisons, and minimal documentation one-liner at top.
2025-09-03 16:38:42 -07:00
Henry Gabryjelski e7c61f86c0 more const correctness
This allows compiler to optimize more, and allows caller to store the data in ROM (instead of RAM).
2025-09-03 16:38:42 -07:00
Henry Gabryjelski af7aa26c14 Update changelog
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.
2025-06-09 15:12:13 -07:00
Henry Gabryjelski 9b37250453 em4x70 --par deprecation: Step 5: remove client parameters entirely 2025-06-09 15:05:28 -07:00
Henry Gabryjelski b5e6d21128 Make it clear that this code was *always* sending a parity bit. All the tags require the parity bit. 2025-06-09 14:54:30 -07:00
Henry Gabryjelski 69a2cc1ff0 em4x70 --par deprecation: Step 4: remove client references to client->arm field that used to store this 2025-06-09 14:03:05 -07:00
Henry Gabryjelski 4dcf12fd8d em4x70 --par deprecation: Step 3: remove client-only variables, hard-code false for client->arm comms 2025-06-09 13:32:37 -07:00
Henry Gabryjelski 31b1117a51 em4x70 --par deprecation: Step 2: arm-side always uses false 2025-06-09 12:58:50 -07:00
Henry Gabryjelski 86bac8fe8c em4x70 --par deprecation: Step 1: client-side always sets false 2025-06-09 12:18:34 -07:00
Henry Gabryjelski 2aa58457e3 Missing lines from my last commit 2025-03-19 02:34:38 -07:00
Henry Gabryjelski 43e026b1c9 Fix LIW to RM delay
* 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
2025-03-18 23:18:36 -07:00
Henry Gabryjelski 8617541660 rename some constants to increase clarity 2025-03-18 23:06:33 -07:00
Henry Gabryjelski a588e74e9d rename global variable g_tag 2025-03-18 22:54:46 -07:00
Henry Gabryjelski ab602794d9 rename global variable g_command_parity 2025-03-18 22:52:19 -07:00
Henry Gabryjelski 22b2d422d6 update changelog 2025-03-16 01:06:19 -07:00
Henry Gabryjelski 21ad101ff5 Major update to EM4x70 support:
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.
2025-03-16 01:05:55 -07:00
Henry Gabryjelski 740cfad457 Fix printf() mismatch 2025-01-15 13:11:41 -08:00
Henry Gabryjelski 1e95dadde9 Remove static assertions 2025-01-15 09:25:21 -08:00
Henry Gabryjelski 715e876c62 Per explicit request of iceman1001 2025-01-15 09:22:18 -08:00
Henry Gabryjelski dc0e6f4f91 Fix regression
Found by iceman1001's code review ... THANK YOU!
2025-01-15 09:18:39 -08:00
Henry Gabryjelski 6613ff7334 Workaround old GCC on Windows builds
This is supported for GCC >= version 13

See GCC bug 85487:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85487
2025-01-14 20:35:45 -08:00
Henry Gabryjelski 99e8de3687 fix build break on some compilers 2025-01-14 18:01:09 -08:00
Henry Gabryjelski 05319463fb improve comment 2025-01-14 18:01:09 -08:00
Henry Gabryjelski 1c3f84503a Quiet a spurious warning
The compiler warning is incorrect.
Since `calloc()` zero's memory, can
remove redundant line setting value
to zero, giving quieter builds.
2025-01-14 18:01:09 -08:00
Henry Gabryjelski 18f6604eb0 Prevent potential stack corruption 2025-01-14 18:01:09 -08:00
Henry Gabryjelski 1c75690b1a Various codeQL fixes
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.
2025-01-14 18:01:09 -08:00
Henry Gabryjelski 91be146ecb CodeQL fixes for "Comparison between A of type TypeA and B of wider type TypeB" 2025-01-14 17:54:58 -08:00
Henry Gabryjelski 20c4756f2a no-op 2025-01-14 17:52:51 -08:00
Henry Gabryjelski 4d67f56656 Mismatched format string specifier (need to deref size pointer) 2025-01-14 17:52:51 -08:00
Henry Gabryjelski 4c6ccfedc1 See if this avoids changelist warnings when building in a fork 2025-01-10 12:20:17 -08:00
Henry Gabryjelski 7eefd358d3 Allow manual initiation of CodeQL 2025-01-10 12:06:49 -08:00
Henry Gabryjelski 1d4e5e8d90 Fix .PM3 traces that exceed single-byte range
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.
2024-09-16 23:35:03 -07:00
Henry Gabryjelski 1a7267ca53 Fix .PM3 traces that exceed single-byte range
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`
2024-09-16 23:05:15 -07:00
Henry Gabryjelski f2ff5f757d writeup from discord, plus extra text
Created as a strawman response to iceman's
suggestion that this would be useful in the repo.

Feel free to move it elsewhere / edit, as you prefer.
2024-08-23 21:08:13 -07:00
Henry Gabryjelski f9dbe3fb6e Update CHANGELOG.md
Signed-off-by: Henry Gabryjelski <henrygab@users.noreply.github.com>
2024-05-14 21:34:43 -07:00
Henry Gabryjelski 20711e7037 Add em4x70 tests 2024-05-14 21:06:35 -07:00
Henry Gabryjelski f58992922d limit freen color to calculated values 2024-05-14 20:35:27 -07:00
Henry Gabryjelski 2757881945 functions should be static where possible 2024-05-14 20:22:30 -07:00
Henry Gabryjelski 2952d55904 Add lf em 4x70 calc 2024-05-14 20:21:42 -07:00
Henry Gabryjelski b7fff95b7c Improve editor folding (some editors use indentation as cue) 2024-05-14 19:16:37 -07:00
Henry Gabryjelski d27c084819 Internal code cleanup.
Reduce ambiguity in function and parameter names.
2024-05-14 19:16:05 -07:00
Henry Gabryjelski 483b192d40 rename parameter for em4x70_receive
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.
2024-05-13 10:19:00 -07:00
Henry Gabryjelski 0de99805cd Fix broken test 2024-05-06 09:09:46 -07:00
Henry Gabryjelski c40f4be3e6 re-enable broken hitag2 test 2024-05-06 07:59:41 -07:00
Henry Gabryjelski 7712acff64 Use actions/setup-python for Ubuntu also 2024-05-05 18:35:38 -07:00
Henry Gabryjelski 9d33646b80 Disable broken hitag2 test so github actions work 2024-05-05 18:27:35 -07:00
Henry Gabryjelski 3d824425d2 Use actions/setup-python for MacOS 2024-05-05 18:23:45 -07:00
Henry Gabryjelski 18cbc7259c prevent sending corrupt data to em4x70 tags 2024-05-05 16:00:16 -07:00
Henry Gabryjelski b0b9f4fa42 Add key that tests autorecovery more quickly
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.
2024-05-05 15:57:26 -07:00
Henry Gabryjelski 569d57719d Fix firmware return value for em4x70 to always be of type PM3_* 2024-05-05 15:54:00 -07:00
Henry Gabryjelski c7d7680cd6 Decoder must not write more bit than requested 2024-03-13 23:23:31 -07:00
Henry Gabryjelski cc2bae2f4d lf em 4x70 writekey --> lf em 4x70 setkey 2024-03-13 09:38:35 -07:00
Henry Gabryjelski ba83ac065e lf em 4x70 writepin --> lf em 4x70 setpin 2024-03-13 09:25:43 -07:00
Henry Gabryjelski 7fbc6b2e47 fix formatting error 2024-03-11 18:28:47 -07:00
Henry Gabryjelski 7036e91f2e Add to changelog 2024-03-11 18:16:59 -07:00
Henry Gabryjelski 0a598b254c make style changes 2024-03-11 17:28:05 -07:00
Henry Gabryjelski 160d61682b Add lf em 4x70 autorecover
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.
2024-03-11 17:14:03 -07:00
Henry Gabryjelski b4cfeca9fa Use INFO instead of NORMAL for PrintAndLogEx() 2024-03-03 12:17:02 -08:00
Henry Gabryjelski 12ee192782 disable assertions in PM3 build 2024-03-03 12:17:02 -08:00
Henry Gabryjelski 6c1aa10c91 bugfix: random alt nonce wasn't.
also improve output of multiple potential keys (remove extra `\n`)
2024-03-03 12:17:02 -08:00
Henry Gabryjelski d4942584ec Add CHANGELOG entry 2024-03-03 12:16:57 -08:00
Henry Gabryjelski 545c152d72 Remove large (128k) lookup table 2024-03-03 12:16:16 -08:00
Henry Gabryjelski 4ebd6d4bff Add id48lib and second half of key recovery. 2024-03-03 12:16:16 -08:00