Merge upstream master into em4x50-liw-sync-fix-pr

Resolve CHANGELOG.md: keep both the EM4x50 entries and the entries
from #3756, #3757.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
abou28andClaude Opus 5.5 committed 2026-11-07 02:39:41 +01:00
commit 38f6cb966f
5 files changed
+38 -9

No files matched your search

+2
View File
@@ -5,6 +5,8 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
## [unreleased][unreleased]
- Fixed `lf em 4x50 rdbl/info/dump`, `lf search` - RM was sent into the tag data instead of the second listen window on strong, AC-coupled signals, so every command failed; reads now retry within 1 s (@abou28)
- Added `lf em 4x50 config` - runtime EM4x50 reader timings, and `lf_em4x50_tune.lua` to sweep them; extended debug level captures the raw exchange for `data samples` (@abou28)
- Fixed `hf secc sim` - the ATQA codes the UID size, so readers that check it select a 7 or 10 byte UID, and a zero UID prints as taken from emulator memory (@matrix)
- Fixed `lf keri clone` and `sim` - values the frame can't carry are refused instead of cut, `sim` prints the id and its raw, the help example and the clone hint name `--id` and `lf keri reader` (@matrix)
- Fixed `lf paradox clone` and `sim` - FC above 255 and CN above 65535 are refused instead of cut, the clone hint names `lf paradox reader` (@matrix)
- Fixed NDEF TLV decoding - a NULL TLV has no length, Lock and Memory Control sizes of 0 mean 256 and their page fields are powers of two (@matrix)
- Fixed flashing with redirected output - the progress animation is drawn only when stdout is a terminal (@matrix)
+7 -1
View File
@@ -475,6 +475,11 @@ static int CmdHFHIDConfigSim(const char *Cmd) {
char uid_str[2 * sizeof(uid) + 1];
strncpy(uid_str, sprint_hex_inrow(uid, uidlen), sizeof(uid_str) - 1);
uid_str[sizeof(uid_str) - 1] = '\0';
// an all-zero UID makes the device take a 4-byte UID from emulator memory
bool uid_from_emul = (memcmp(uid, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", sizeof(uid)) == 0);
if (uid_from_emul) {
snprintf(uid_str, sizeof(uid_str), "from emulator memory");
}
PrintAndLogEx(INFO, "HID Config Card sim:"
" UID " _YELLOW_("%s")
" AID " _YELLOW_("%s")
@@ -490,7 +495,8 @@ static int CmdHFHIDConfigSim(const char *Cmd) {
payload.tagtype = 4; // ISO14443-4 base type; ATQA/SAK/ATS overridden by ARM
payload.flags = flags;
payload.exitAfter = exitAfterNReads;
payload.atqa[0] = 0x02; // HID Config Card ATQA high byte
// HID Config Card ATQA high byte, b8 b7 code the UID size (ISO/IEC 14443-3)
payload.atqa[0] = 0x02 | ((uid_from_emul || uidlen == 4) ? 0x00 : ((uidlen == 7) ? 0x40 : 0x80));
payload.atqa[1] = 0x00; // HID Config Card ATQA low byte
payload.sak = 0x38; // HID Config Card SAK
payload.ats_len = (uint8_t)ats_len;
+26 -6
View File
@@ -248,8 +248,8 @@ static int CmdKeriClone(const char *Cmd) {
int typeLen = sizeof(keritype) - 1; // CLIGetStrWithReturn does not guarantee string to be null-terminated
CLIGetStrWithReturn(ctx, 1, keritype, &typeLen);
uint32_t fc = arg_get_int_def(ctx, 2, 0);
uint32_t cid = arg_get_int_def(ctx, 3, 0);
int fc_arg = arg_get_int_def(ctx, 2, 0);
int cn_arg = arg_get_int_def(ctx, 3, 0);
bool q5 = arg_get_lit(ctx, 4);
bool em = arg_get_lit(ctx, 5);
CLIParserFree(ctx);
@@ -259,6 +259,20 @@ static int CmdKeriClone(const char *Cmd) {
return PM3_EINVARG;
}
if (fc_arg < 0 || cn_arg < 0) {
PrintAndLogEx(FAILED, "FC and CN can't be negative");
return PM3_EINVARG;
}
// the MS scramble carries 5 bits of fc and 22 of cn
if (keritype[0] == 'm' && (fc_arg > 31 || cn_arg > 0x3FFFFF)) {
PrintAndLogEx(FAILED, "MS FC has a max value of 31 and CN has a max value of 4194303");
return PM3_EINVARG;
}
uint32_t fc = (uint32_t)fc_arg;
uint32_t cid = (uint32_t)cn_arg;
// Setup card data/build internal id
uint32_t internalid = 0;
switch (keritype[0]) {
@@ -310,7 +324,7 @@ static int CmdKeriClone(const char *Cmd) {
}
PrintAndLogEx(SUCCESS, "Done!");
PrintAndLogEx(HINT, "Hint: Try " _YELLOW_("`lf keri read`") " to verify");
PrintAndLogEx(HINT, "Hint: Try " _YELLOW_("`lf keri reader`") " to verify");
return res;
}
@@ -320,7 +334,7 @@ static int CmdKeriSim(const char *Cmd) {
CLIParserInit(&ctx, "lf keri sim",
"Enables simulation of KERI card with internal ID.\n"
"You supply a KERI card id and it will converted to a KERI internal ID.",
"lf keri sim --cn 112233"
"lf keri sim --id 112233"
);
void *argtable[] = {
@@ -332,6 +346,14 @@ static int CmdKeriSim(const char *Cmd) {
uint64_t internalid = arg_get_u64_def(ctx, 1, 0);
CLIParserFree(ctx);
// the frame carries 31 bits of internal id
if (internalid > 0x7FFFFFFF) {
PrintAndLogEx(FAILED, "Internal Id has a max value of 2147483647");
return PM3_EINVARG;
}
PrintAndLogEx(SUCCESS, "Simulating KERI - Internal Id " _YELLOW_("%" PRIu64) ", Raw: E0000000%08" PRIX64, internalid, internalid | 0x80000000);
internalid |= 0x80000000;
internalid <<= 3;
internalid += 7;
@@ -343,8 +365,6 @@ static int CmdKeriSim(const char *Cmd) {
bs[j++] = ((internalid >> i) & 1);
}
PrintAndLogEx(SUCCESS, "Simulating KERI - Internal Id " _YELLOW_("%" PRIu64), internalid);
lf_psksim_t *payload = calloc(1, sizeof(lf_psksim_t) + sizeof(bs));
if (payload == NULL) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
+2 -2
View File
@@ -13794,7 +13794,7 @@
"command": "lf keri sim",
"description": "Enables simulation of KERI card with internal ID. You supply a KERI card id and it will converted to a KERI internal ID.",
"notes": [
"lf keri sim --cn 112233"
"lf keri sim --id 112233"
],
"offline": false,
"options": [
@@ -16833,6 +16833,6 @@
"metadata": {
"commands_extracted": 937,
"extracted_by": "PM3Help2JSON v1.00",
"extracted_on": "2026-10-23T22:15:17+00:00"
"extracted_on": "2026-11-06T23:18:49+00:00"
}
}
+1
View File
@@ -618,6 +618,7 @@ while true; do
if ! CheckExecute "lf T55 keri_msid test" "$CLIENTBIN -c 'data load -f traces/lf_ATA5577_keri_msid.pm3; lf search -1'" "KERI ID found"; then break; fi
if ! CheckExecute "lf T55 keri_msid test 2" "$CLIENTBIN -c 'data load -f traces/lf_ATA5577_keri_msid.pm3; lf keri demod'" \
"Descrambled MS - FC: 6 Card: 12345"; then break; fi
if ! CheckExecute "lf keri sim help example" "$CLIENTBIN -c 'lf keri sim -h'" "lf keri sim --id 112233"; then break; fi
# if ! CheckExecute "lf T55 motorola test" "$CLIENTBIN -c 'data load -f traces/lf_ATA5577_motorola.pm3; lf search -1'" "Indala ID found"; then break; fi
if ! CheckExecute "lf T55 motorola test 2" "$CLIENTBIN -c 'data load -f traces/lf_ATA5577_motorola.pm3; lf motorola demod'" \
"Motorola - fmt: 26 FC: 258 Card: 2, Raw: A0000000A0002021"; then break; fi