mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-21 15:56:21 +08:00
replace static countones & bitcount by utils in client
This commit is contained in:
parent
e5c5629cf2
commit
f2a0f3e272
|
@ -103,14 +103,6 @@ static inline uint32_t leadingzeros(uint64_t a) {
|
|||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
static inline uint32_t countones(uint64_t a) {
|
||||
#if defined __GNUC__
|
||||
return __builtin_popcountll(a);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
const char *card_types[] = {
|
||||
|
@ -2034,7 +2026,7 @@ static int CmdHFiClass_ReadBlock(const char *Cmd) {
|
|||
|
||||
uint64_t a = bytes_to_num(data, 8);
|
||||
bool starts = (leadingzeros(a) < 12);
|
||||
bool ones = (countones(a) > 16 && countones(a) < 48);
|
||||
bool ones = (bitcount64(a) > 16 && bitcount64(a) < 48);
|
||||
|
||||
if (starts && ones) {
|
||||
PrintAndLogEx(INFO, "data looks encrypted, False Positives " _YELLOW_("ARE") " possible");
|
||||
|
|
|
@ -118,16 +118,6 @@ static void verify_values(uint64_t *animalid, uint32_t *countryid, uint32_t *ext
|
|||
}
|
||||
}
|
||||
|
||||
static inline uint32_t bitcount(uint32_t a) {
|
||||
#if defined __GNUC__
|
||||
return __builtin_popcountl(a);
|
||||
#else
|
||||
a = a - ((a >> 1) & 0x55555555);
|
||||
a = (a & 0x33333333) + ((a >> 2) & 0x33333333);
|
||||
return (((a + (a >> 4)) & 0x0f0f0f0f) * 0x01010101) >> 24;
|
||||
#endif
|
||||
}
|
||||
|
||||
// FDX-B ISO11784/85 demod (aka animal tag) BIPHASE, inverted, rf/32, with preamble of 00000000001 (128bits)
|
||||
// 8 databits + 1 parity (1)
|
||||
// CIITT 16 chksum
|
||||
|
@ -594,7 +584,7 @@ int demodFDXB(bool verbose) {
|
|||
|
||||
uint8_t bt_par = (extended & 0x100) >> 8;
|
||||
uint8_t bt_temperature = extended & 0xff;
|
||||
uint8_t bt_calc_parity = (bitcount(bt_temperature) & 0x1) ? 0 : 1;
|
||||
uint8_t bt_calc_parity = (bitcount32(bt_temperature) & 0x1) ? 0 : 1;
|
||||
uint8_t is_bt_temperature = (bt_calc_parity == bt_par) && !(extended & 0xe00) ;
|
||||
|
||||
if (is_bt_temperature) {
|
||||
|
|
|
@ -37,20 +37,10 @@ const uint8_t translateTable[10] = {8, 2, 1, 12, 4, 5, 10, 13, 0, 9};
|
|||
const uint8_t invTranslateTable[16] = {8, 2, 1, 0xff, 4, 5, 0xff, 0xff, 0, 9, 6, 0xff, 3, 7, 0xff, 0xff};
|
||||
const uint8_t preamble[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}; // zero inside
|
||||
|
||||
static inline uint32_t bitcount(uint32_t a) {
|
||||
#if defined __GNUC__
|
||||
return __builtin_popcountl(a);
|
||||
#else
|
||||
a = a - ((a >> 1) & 0x55555555);
|
||||
a = (a & 0x33333333) + ((a >> 2) & 0x33333333);
|
||||
return (((a + (a >> 4)) & 0x0f0f0f0f) * 0x01010101) >> 24;
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint8_t isEven_64_63(const uint8_t *data) { // 8
|
||||
uint32_t tmp[2];
|
||||
memcpy(tmp, data, 8);
|
||||
return (bitcount(tmp[0]) + (bitcount(tmp[1] & 0xfeffffff))) & 1;
|
||||
return (bitcount32(tmp[0]) + (bitcount32(tmp[1] & 0xfeffffff))) & 1;
|
||||
}
|
||||
|
||||
//NEDAP demod - ASK/Biphase (or Diphase), RF/64 with preamble of 1111111110 (always a 128 bit data stream)
|
||||
|
|
Loading…
Reference in a new issue