mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
use partiy.h and textual
This commit is contained in:
parent
5fd951f7d4
commit
e5fc1d83b2
2 changed files with 32 additions and 24 deletions
|
@ -27,7 +27,7 @@
|
||||||
#include "cmdlft55xx.h" // verifywrite
|
#include "cmdlft55xx.h" // verifywrite
|
||||||
#include "cliparser.h"
|
#include "cliparser.h"
|
||||||
#include "cmdlfem4x05.h" // EM defines
|
#include "cmdlfem4x05.h" // EM defines
|
||||||
|
#include "parity.h" // parity
|
||||||
#define INDALA_ARR_LEN 64
|
#define INDALA_ARR_LEN 64
|
||||||
|
|
||||||
static int CmdHelp(const char *Cmd);
|
static int CmdHelp(const char *Cmd);
|
||||||
|
@ -112,17 +112,6 @@ static void decodeHeden2L(uint8_t *bits) {
|
||||||
PrintAndLogEx(SUCCESS, " Heden-2L | %u", cardnumber);
|
PrintAndLogEx(SUCCESS, " Heden-2L | %u", cardnumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parityEven(uint16_t x) {
|
|
||||||
x ^= x >> 1;
|
|
||||||
x ^= x >> 2;
|
|
||||||
x ^= x >> 4;
|
|
||||||
x ^= x >> 8;
|
|
||||||
x ^= x >> 16;
|
|
||||||
return (x & 0x01);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool parityOdd(uint16_t x) { return(!parityEven(x)); }
|
|
||||||
|
|
||||||
// Indala 26 bit decode
|
// Indala 26 bit decode
|
||||||
// by marshmellow, martinbeier
|
// by marshmellow, martinbeier
|
||||||
// optional arguments - same as PSKDemod (clock & invert & maxerr)
|
// optional arguments - same as PSKDemod (clock & invert & maxerr)
|
||||||
|
@ -635,10 +624,11 @@ static int CmdIndalaClone(const char *Cmd) {
|
||||||
|
|
||||||
CLIParserContext *ctx;
|
CLIParserContext *ctx;
|
||||||
CLIParserInit(&ctx, "lf indala clone",
|
CLIParserInit(&ctx, "lf indala clone",
|
||||||
"clone Indala UID to T55x7 or Q5/T5555 tag\n"
|
"clone Indala UID to T55x7 or Q5/T5555 tag using different known formats\n"
|
||||||
_RED_("\nWarning, encoding with FC/CN doesn't always work"),
|
_RED_("\nWarning, encoding with FC/CN doesn't always work"),
|
||||||
"lf indala clone --heden 888\n"
|
"lf indala clone --heden 888 --> use Heden 2L format\n"
|
||||||
"lf indala clone --fc 123 --cn 1337\n"
|
"lf indala clone --fc 123 --cn 1337 --> use standard 26b format\n"
|
||||||
|
"lf indala clone --fc 123 --cn 1337 --4041x --> use 4041x format\n"
|
||||||
"lf indala clone -r a0000000a0002021\n"
|
"lf indala clone -r a0000000a0002021\n"
|
||||||
"lf indala clone -r 80000001b23523a6c2e31eba3cbee4afb3c6ad1fcf649393928c14e5");
|
"lf indala clone -r 80000001b23523a6c2e31eba3cbee4afb3c6ad1fcf649393928c14e5");
|
||||||
|
|
||||||
|
@ -805,7 +795,7 @@ static command_t CommandTable[] = {
|
||||||
{"demod", CmdIndalaDemod, AlwaysAvailable, "Demodulate an Indala tag (PSK1) from GraphBuffer"},
|
{"demod", CmdIndalaDemod, AlwaysAvailable, "Demodulate an Indala tag (PSK1) from GraphBuffer"},
|
||||||
{"altdemod", CmdIndalaDemodAlt, AlwaysAvailable, "Alternative method to demodulate samples for Indala 64 bit UID (option '224' for 224 bit)"},
|
{"altdemod", CmdIndalaDemodAlt, AlwaysAvailable, "Alternative method to demodulate samples for Indala 64 bit UID (option '224' for 224 bit)"},
|
||||||
{"reader", CmdIndalaReader, IfPm3Lf, "Read an Indala tag from the antenna"},
|
{"reader", CmdIndalaReader, IfPm3Lf, "Read an Indala tag from the antenna"},
|
||||||
{"clone", CmdIndalaClone, IfPm3Lf, "Clone Indala 4041X tag to T55x7 or Q5/T5555"},
|
{"clone", CmdIndalaClone, IfPm3Lf, "Clone Indala tag to T55x7 or Q5/T5555"},
|
||||||
{"sim", CmdIndalaSim, IfPm3Lf, "Simulate Indala tag"},
|
{"sim", CmdIndalaSim, IfPm3Lf, "Simulate Indala tag"},
|
||||||
{NULL, NULL, NULL, NULL}
|
{NULL, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -932,8 +922,8 @@ int getIndalaBits4041x(uint8_t fc, uint16_t cn, uint8_t *bits) {
|
||||||
bits[41] = (cn & 0x01); // LSB L
|
bits[41] = (cn & 0x01); // LSB L
|
||||||
|
|
||||||
// Parity
|
// Parity
|
||||||
bits[34] = parityEven((fc << 4) | (cn >> 12));
|
bits[34] = evenparity16((fc << 4) | (cn >> 12));
|
||||||
bits[38] = parityOdd(cn & 0x0fff);
|
bits[38] = oddparity16(cn & 0x0fff);
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,24 @@ static inline uint8_t evenparity8(const uint8_t x) {
|
||||||
return !OddByteParity[x];
|
return !OddByteParity[x];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline uint8_t evenparity16(uint16_t x) {
|
||||||
|
#if !defined __GNUC__
|
||||||
|
x ^= x >> 8;
|
||||||
|
return evenparity8(x);
|
||||||
|
#else
|
||||||
|
return (__builtin_parity(x) & 0xFF);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint8_t oddparity16(uint16_t x) {
|
||||||
|
#if !defined __GNUC__
|
||||||
|
x ^= x >> 8;
|
||||||
|
return oddparity8(x);
|
||||||
|
#else
|
||||||
|
return !__builtin_parity(x);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static inline uint8_t evenparity32(uint32_t x) {
|
static inline uint8_t evenparity32(uint32_t x) {
|
||||||
#if !defined __GNUC__
|
#if !defined __GNUC__
|
||||||
x ^= x >> 16;
|
x ^= x >> 16;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue