lf indala: --fc/--cn parity and checksum as on genuine cards

PR #2453 computed the parity bits over stream positions and PR #2947
inverted the checksum, so --fc/--cn clones did not match the genuine
cards on record, from issue #2939 and the DangerousThings forum. Both
carry the 26-bit Wiegand parity of getIndalaBits4041x and the checksum
from before #2947, and the encoder now reproduces them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Gabriele GristinaandClaude Opus 5.5 committed 2026-11-07 00:03:58 +01:00
1 parent f90d0d0bf9
commit 451ce54bed
2 files changed
+9 -18

No files matched your search

+8 -18
View File
@@ -1163,12 +1163,13 @@ int getIndalaBits(uint8_t fc, uint16_t cn, uint8_t *bits) {
chk += ((cn >> 2) & 1); //y14 == 89 - 30 = 59
chk += (cn & 1); //y16 == 71 - 30 = 41
if ((chk & 1) == 0) { // If the sum is even, checksum is '10' (binary) = 2.
bits[62] = 1;
bits[63] = 0;
} else { // If the sum is odd, checksum is '01' (binary) = 1.
// as on genuine cards, see issue #2939
if ((chk & 1) == 0) { // If the sum is even, checksum is '01' (binary) = 1.
bits[62] = 0;
bits[63] = 1;
} else { // If the sum is odd, checksum is '10' (binary) = 2.
bits[62] = 1;
bits[63] = 0;
}
// add parity
@@ -1178,20 +1179,9 @@ int getIndalaBits(uint8_t fc, uint16_t cn, uint8_t *bits) {
// 92 = 62
// 93 = 63
bits[34] = 0; // parity for odd bits
bits[38] = 0; // parity for even bits
uint8_t p1 = 1;
uint8_t p2 = 1;
for (int i = 33; i < 64; i++) {
if (i % 2)
p1 ^= bits[i];
else
p2 ^= bits[i];
}
bits[34] = p1; // parity for odd bits
bits[38] = p2; // parity for even bits
// 26-bit wiegand parity, as in getIndalaBits4041x
bits[34] = evenparity16((fc << 4) | (cn >> 12));
bits[38] = oddparity16(cn & 0x0fff);
return PM3_SUCCESS;
}