mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
refactory parity files a bit
This commit is contained in:
parent
61c9252e15
commit
0942ce7a68
8 changed files with 30 additions and 76 deletions
|
@ -155,7 +155,6 @@ THUMBSRC = start.c \
|
||||||
|
|
||||||
# These are to be compiled in ARM mode
|
# These are to be compiled in ARM mode
|
||||||
ARMSRC = fpgaloader.c \
|
ARMSRC = fpgaloader.c \
|
||||||
parity.c \
|
|
||||||
usb_cdc.c \
|
usb_cdc.c \
|
||||||
cmd.c
|
cmd.c
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,6 @@ add_subdirectory(${PM3_ROOT}/client/deps deps)
|
||||||
set (TARGET_SOURCES
|
set (TARGET_SOURCES
|
||||||
${PM3_ROOT}/common/commonutil.c
|
${PM3_ROOT}/common/commonutil.c
|
||||||
${PM3_ROOT}/common/util_posix.c
|
${PM3_ROOT}/common/util_posix.c
|
||||||
${PM3_ROOT}/common/parity.c
|
|
||||||
${PM3_ROOT}/common/bucketsort.c
|
${PM3_ROOT}/common/bucketsort.c
|
||||||
${PM3_ROOT}/common/crapto1/crapto1.c
|
${PM3_ROOT}/common/crapto1/crapto1.c
|
||||||
${PM3_ROOT}/common/crapto1/crypto1.c
|
${PM3_ROOT}/common/crapto1/crypto1.c
|
||||||
|
|
|
@ -660,7 +660,6 @@ SRCS += bucketsort.c \
|
||||||
iso15693tools.c \
|
iso15693tools.c \
|
||||||
legic_prng.c \
|
legic_prng.c \
|
||||||
lfdemod.c \
|
lfdemod.c \
|
||||||
parity.c \
|
|
||||||
util_posix.c
|
util_posix.c
|
||||||
|
|
||||||
# swig
|
# swig
|
||||||
|
|
|
@ -57,7 +57,6 @@ endif ()
|
||||||
add_library(pm3rrg_rdv4 SHARED
|
add_library(pm3rrg_rdv4 SHARED
|
||||||
${PM3_ROOT}/common/commonutil.c
|
${PM3_ROOT}/common/commonutil.c
|
||||||
${PM3_ROOT}/common/util_posix.c
|
${PM3_ROOT}/common/util_posix.c
|
||||||
${PM3_ROOT}/common/parity.c
|
|
||||||
${PM3_ROOT}/common/bucketsort.c
|
${PM3_ROOT}/common/bucketsort.c
|
||||||
${PM3_ROOT}/common/crapto1/crapto1.c
|
${PM3_ROOT}/common/crapto1/crapto1.c
|
||||||
${PM3_ROOT}/common/crapto1/crypto1.c
|
${PM3_ROOT}/common/crapto1/crypto1.c
|
||||||
|
|
|
@ -190,7 +190,6 @@ add_subdirectory(${PM3_ROOT}/client/deps deps)
|
||||||
set (TARGET_SOURCES
|
set (TARGET_SOURCES
|
||||||
${PM3_ROOT}/common/commonutil.c
|
${PM3_ROOT}/common/commonutil.c
|
||||||
${PM3_ROOT}/common/util_posix.c
|
${PM3_ROOT}/common/util_posix.c
|
||||||
${PM3_ROOT}/common/parity.c
|
|
||||||
${PM3_ROOT}/common/bucketsort.c
|
${PM3_ROOT}/common/bucketsort.c
|
||||||
${PM3_ROOT}/common/crapto1/crapto1.c
|
${PM3_ROOT}/common/crapto1/crapto1.c
|
||||||
${PM3_ROOT}/common/crapto1/crypto1.c
|
${PM3_ROOT}/common/crapto1/crypto1.c
|
||||||
|
|
|
@ -177,12 +177,6 @@ static int print_authentication2(void) {
|
||||||
|
|
||||||
static const char *felica_model_name(uint8_t rom_type, uint8_t ic_type) {
|
static const char *felica_model_name(uint8_t rom_type, uint8_t ic_type) {
|
||||||
// source: mainly https://www.sony.net/Products/felica/business/tech-support/list.html
|
// source: mainly https://www.sony.net/Products/felica/business/tech-support/list.html
|
||||||
|
|
||||||
if (ic_type >= 0x14 && ic_type <= 0x1F) {
|
|
||||||
return "FeliCa Mobile IC Chip V3.0";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
switch (ic_type) {
|
switch (ic_type) {
|
||||||
// FeliCa Standard Products:
|
// FeliCa Standard Products:
|
||||||
case 0x46:
|
case 0x46:
|
||||||
|
@ -239,7 +233,7 @@ static const char *felica_model_name(uint8_t rom_type, uint8_t ic_type) {
|
||||||
case 0x1D:
|
case 0x1D:
|
||||||
case 0x1E:
|
case 0x1E:
|
||||||
case 0x1F:
|
case 0x1F:
|
||||||
return "Mobile FeliCa IC Chip V3.0";
|
return "FeliCa Mobile IC Chip V3.0";
|
||||||
case 0x10:
|
case 0x10:
|
||||||
case 0x11:
|
case 0x11:
|
||||||
case 0x12:
|
case 0x12:
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// See LICENSE.txt for the text of the license.
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// parity functions (all defined in parity.h)
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
#include "parity.h"
|
|
||||||
|
|
||||||
const uint8_t g_OddByteParity[256] = {
|
|
||||||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
|
||||||
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
|
||||||
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
|
||||||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
|
||||||
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
|
||||||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
|
||||||
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, 1, 1, 0, 1, 0, 0, 1,
|
|
||||||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
|
||||||
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
|
||||||
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
|
||||||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
|
||||||
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
|
||||||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
|
||||||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
|
||||||
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0
|
|
||||||
};
|
|
||||||
*/
|
|
|
@ -23,20 +23,42 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
extern const uint8_t g_OddByteParity[256];
|
static const uint8_t g_odd_byte_parity[256] = {
|
||||||
|
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
||||||
|
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
||||||
|
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
||||||
|
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
||||||
|
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
||||||
|
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
||||||
|
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
||||||
|
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
||||||
|
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
||||||
|
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
||||||
|
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
||||||
|
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
||||||
|
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
||||||
|
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
||||||
|
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
||||||
|
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1
|
||||||
|
};
|
||||||
|
|
||||||
|
//extern const uint8_t OddByteParity[256];
|
||||||
|
|
||||||
|
#define ODD_PARITY8(x) { g_odd_byte_parity[x] }
|
||||||
|
#define EVEN_PARITY8(x) { !g_odd_byte_parity[x] }
|
||||||
|
|
||||||
static inline uint8_t oddparity8(const uint8_t x) {
|
static inline uint8_t oddparity8(const uint8_t x) {
|
||||||
return g_OddByteParity[x];
|
return g_odd_byte_parity[x];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint8_t evenparity8(const uint8_t x) {
|
static inline uint8_t evenparity8(const uint8_t x) {
|
||||||
return !g_OddByteParity[x];
|
return !g_odd_byte_parity[x];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint8_t evenparity16(uint16_t x) {
|
static inline uint8_t evenparity16(uint16_t x) {
|
||||||
#if !defined __GNUC__
|
#if !defined __GNUC__
|
||||||
x ^= x >> 8;
|
x ^= x >> 8;
|
||||||
return evenparity8(x);
|
return EVEN_PARITY8(x) ;
|
||||||
#else
|
#else
|
||||||
return (__builtin_parity(x) & 0xFF);
|
return (__builtin_parity(x) & 0xFF);
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,7 +67,7 @@ static inline uint8_t evenparity16(uint16_t x) {
|
||||||
static inline uint8_t oddparity16(uint16_t x) {
|
static inline uint8_t oddparity16(uint16_t x) {
|
||||||
#if !defined __GNUC__
|
#if !defined __GNUC__
|
||||||
x ^= x >> 8;
|
x ^= x >> 8;
|
||||||
return oddparity8(x);
|
return ODD_PARITY8(x);
|
||||||
#else
|
#else
|
||||||
return !__builtin_parity(x);
|
return !__builtin_parity(x);
|
||||||
#endif
|
#endif
|
||||||
|
@ -55,7 +77,7 @@ static inline uint8_t evenparity32(uint32_t x) {
|
||||||
#if !defined __GNUC__
|
#if !defined __GNUC__
|
||||||
x ^= x >> 16;
|
x ^= x >> 16;
|
||||||
x ^= x >> 8;
|
x ^= x >> 8;
|
||||||
return evenparity8(x);
|
return EVEN_PARITY8(x);
|
||||||
#else
|
#else
|
||||||
return (__builtin_parity(x) & 0xFF);
|
return (__builtin_parity(x) & 0xFF);
|
||||||
#endif
|
#endif
|
||||||
|
@ -65,7 +87,7 @@ static inline uint8_t oddparity32(uint32_t x) {
|
||||||
#if !defined __GNUC__
|
#if !defined __GNUC__
|
||||||
x ^= x >> 16;
|
x ^= x >> 16;
|
||||||
x ^= x >> 8;
|
x ^= x >> 8;
|
||||||
return oddparity8(x);
|
return ODD_PARITY8(x);
|
||||||
#else
|
#else
|
||||||
return !__builtin_parity(x);
|
return !__builtin_parity(x);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue