diff --git a/CHANGELOG.md b/CHANGELOG.md index a1bedd944..4da21423d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] +- Fixed `lf indala clone`, `sim` and `brute` with `--fc`/`--cn` - parity and checksum bits as on genuine cards (@matrix) - Fixed flashing with redirected output - the progress animation is drawn only when stdout is a terminal (@matrix) - Fixed `proxmark3 --flash`, `--dumpmem` and `--reboot-to-bootloader` exit status - a failure exits 1, a failed flash no longer ends with `All done` (@matrix) - Fixed `data rawdemod` - `--max`, `--samples` and the `--p2` clock no longer wrap above 255, `--fs` refuses values above 255 (@matrix) diff --git a/client/src/cmdlfindala.c b/client/src/cmdlfindala.c index 2843b43cf..dd49ed167 100644 --- a/client/src/cmdlfindala.c +++ b/client/src/cmdlfindala.c @@ -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; }