em4x70 --par deprecation: Step 2: arm-side always uses false

This commit is contained in:
Henry Gabryjelski 2025-06-09 12:58:50 -07:00
commit 31b1117a51
3 changed files with 27 additions and 27 deletions

View file

@ -45,7 +45,7 @@
#define DPRINTF_EXTENDED(x) do { if ((FORCE_ENABLE_LOGGING) || (g_dbglevel >= DBG_EXTENDED)) { Dbprintf x ; } } while (0);
#define DPRINTF_PROLIX(x) do { if ((FORCE_ENABLE_LOGGING) || (g_dbglevel > DBG_EXTENDED)) { Dbprintf x ; } } while (0);
// EM4170 requires a parity bit on commands, other variants do not.
static bool g_command_parity = true;
static bool g_deprecated_command_parity = false;
static em4x70_tag_t g_tag = { 0 };
@ -1097,7 +1097,7 @@ static int authenticate(const uint8_t *rnd, const uint8_t *frnd, uint8_t *respon
em4x70_command_bitstream_t auth_cmd;
const em4x70_command_generators_t *generator = &legacy_em4x70_command_generators;
generator->auth(&auth_cmd, g_command_parity, rnd, frnd);
generator->auth(&auth_cmd, g_deprecated_command_parity, rnd, frnd);
bool result = send_bitstream_and_read(&auth_cmd);
if (result) {
@ -1185,7 +1185,7 @@ static int bruteforce(const uint8_t address, const uint8_t *rnd, const uint8_t *
static int send_pin(const uint32_t pin) {
em4x70_command_bitstream_t send_pin_cmd;
const em4x70_command_generators_t *generator = &legacy_em4x70_command_generators;
generator->pin(&send_pin_cmd, g_command_parity, &g_tag.data[4], pin);
generator->pin(&send_pin_cmd, g_deprecated_command_parity, &g_tag.data[4], pin);
bool result = send_bitstream_wait_ack_wait_read(&send_pin_cmd);
return result ? PM3_SUCCESS : PM3_ESOFT;
@ -1196,7 +1196,7 @@ static int write(const uint16_t word, const uint8_t address) {
em4x70_command_bitstream_t write_cmd;
const em4x70_command_generators_t *generator = &legacy_em4x70_command_generators;
generator->write(&write_cmd, g_command_parity, word, address);
generator->write(&write_cmd, g_deprecated_command_parity, word, address);
bool result = send_bitstream_wait_ack_wait_ack(&write_cmd);
if (!result) {
@ -1283,7 +1283,7 @@ static uint8_t encoded_bit_array_to_byte(const uint8_t *bits, int count_of_bits)
static bool em4x70_read_id(void) {
em4x70_command_bitstream_t read_id_cmd;
const em4x70_command_generators_t *generator = &legacy_em4x70_command_generators;
generator->id(&read_id_cmd, g_command_parity);
generator->id(&read_id_cmd, g_deprecated_command_parity);
bool result = send_bitstream_and_read(&read_id_cmd);
if (result) {
@ -1300,7 +1300,7 @@ static bool em4x70_read_id(void) {
static bool em4x70_read_um1(void) {
em4x70_command_bitstream_t read_um1_cmd;
const em4x70_command_generators_t *generator = &legacy_em4x70_command_generators;
generator->um1(&read_um1_cmd, g_command_parity);
generator->um1(&read_um1_cmd, g_deprecated_command_parity);
bool result = send_bitstream_and_read(&read_um1_cmd);
if (result) {
@ -1319,7 +1319,7 @@ static bool em4x70_read_um1(void) {
static bool em4x70_read_um2(void) {
em4x70_command_bitstream_t read_um2_cmd;
const em4x70_command_generators_t *generator = &legacy_em4x70_command_generators;
generator->um2(&read_um2_cmd, g_command_parity);
generator->um2(&read_um2_cmd, g_deprecated_command_parity);
bool result = send_bitstream_and_read(&read_um2_cmd);
if (result) {
@ -1435,7 +1435,7 @@ void em4x70_info(const em4x70_data_t *etd, bool ledcontrol) {
bool success_with_UM2 = false;
// Support tags with and without command parity bits
g_command_parity = etd->parity;
g_deprecated_command_parity = false;
init_tag();
em4x70_setup_read();
@ -1463,10 +1463,10 @@ void em4x70_info(const em4x70_data_t *etd, bool ledcontrol) {
void em4x70_write(const em4x70_data_t *etd, bool ledcontrol) {
int status = PM3_ESOFT;
g_command_parity = etd->parity;
g_deprecated_command_parity = false;
// Disable to prevent sending corrupted data to the tag.
if (g_command_parity) {
if (g_deprecated_command_parity) {
DPRINTF_ALWAYS(("Use of `--par` option with `lf em 4x70 write` is non-functional and may corrupt data on the tag."));
// reply_ng(CMD_LF_EM4X70_WRITE, PM3_ENOTIMPL, NULL, 0);
// return;
@ -1499,7 +1499,7 @@ void em4x70_unlock(const em4x70_data_t *etd, bool ledcontrol) {
int status = PM3_ESOFT;
g_command_parity = etd->parity;
g_deprecated_command_parity = false;
init_tag();
em4x70_setup_read();
@ -1534,10 +1534,10 @@ void em4x70_auth(const em4x70_data_t *etd, bool ledcontrol) {
uint8_t response[3] = {0};
g_command_parity = etd->parity;
g_deprecated_command_parity = false;
// Disable to prevent sending corrupted data to the tag.
if (g_command_parity) {
if (g_deprecated_command_parity) {
DPRINTF_ALWAYS(("Use of `--par` option with `lf em 4x70 auth` is non-functional."));
// reply_ng(CMD_LF_EM4X70_WRITE, PM3_ENOTIMPL, NULL, 0);
// return;
@ -1562,10 +1562,10 @@ void em4x70_brute(const em4x70_data_t *etd, bool ledcontrol) {
int status = PM3_ESOFT;
uint8_t response[2] = {0};
g_command_parity = etd->parity;
g_deprecated_command_parity = false;
// Disable to prevent sending corrupted data to the tag.
if (g_command_parity) {
if (g_deprecated_command_parity) {
DPRINTF_ALWAYS(("Use of `--par` option with `lf em 4x70 brute` is non-functional and may corrupt data on the tag."));
// reply_ng(CMD_LF_EM4X70_WRITE, PM3_ENOTIMPL, NULL, 0);
// return;
@ -1590,10 +1590,10 @@ void em4x70_write_pin(const em4x70_data_t *etd, bool ledcontrol) {
int status = PM3_ESOFT;
g_command_parity = etd->parity;
g_deprecated_command_parity = false;
// Disable to prevent sending corrupted data to the tag.
if (g_command_parity) {
if (g_deprecated_command_parity) {
DPRINTF_ALWAYS(("Use of `--par` option with `lf em 4x70 setpin` is non-functional and may corrupt data on the tag."));
// reply_ng(CMD_LF_EM4X70_WRITE, PM3_ENOTIMPL, NULL, 0);
// return;
@ -1639,10 +1639,10 @@ void em4x70_write_key(const em4x70_data_t *etd, bool ledcontrol) {
int status = PM3_ESOFT;
g_command_parity = etd->parity;
g_deprecated_command_parity = false;
// Disable to prevent sending corrupted data to the tag.
if (g_command_parity) {
if (g_deprecated_command_parity) {
DPRINTF_ALWAYS(("Use of `--par` option with `lf em 4x70 setkey` is non-functional and may corrupt data on the tag."));
// reply_ng(CMD_LF_EM4X70_WRITE, PM3_ENOTIMPL, NULL, 0);
// return;

View file

@ -233,7 +233,7 @@ static int get_em4x70_info(const em4x70_cmd_input_info_t *opts, em4x70_tag_info_
memset(data_out, 0, sizeof(em4x70_tag_info_t));
// TODO: change firmware to use per-cmd structures
em4x70_data_t edata = { .parity = false };
em4x70_data_t edata = { .deprecated_ignored_use_parity = false };
clearCommandBuffer();
SendCommandNG(CMD_LF_EM4X70_INFO, (uint8_t *)&edata, sizeof(em4x70_data_t));
PacketResponseNG resp;
@ -254,7 +254,7 @@ static int writeblock_em4x70(const em4x70_cmd_input_writeblock_t *opts, em4x70_t
em4x70_data_t etd = {0};
etd.address = opts->block;
etd.word = BYTES2UINT16(opts->value);
etd.parity = false;
etd.deprecated_ignored_use_parity = false;
clearCommandBuffer();
SendCommandNG(CMD_LF_EM4X70_WRITE, (uint8_t *)&etd, sizeof(etd));
@ -273,7 +273,7 @@ static int auth_em4x70(const em4x70_cmd_input_auth_t *opts, em4x70_cmd_output_au
// TODO: change firmware to use per-cmd structures
em4x70_data_t etd = {0};
etd.parity = false;
etd.deprecated_ignored_use_parity = false;
memcpy(&etd.rnd[0], &opts->rn.rn[0], 7);
memcpy(&etd.frnd[0], &opts->frn.frn[0], 4);
@ -298,7 +298,7 @@ static int setkey_em4x70(const em4x70_cmd_input_setkey_t *opts) {
// TODO: change firmware to use per-cmd structures
em4x70_data_t etd = {0};
etd.parity = false;
etd.deprecated_ignored_use_parity = false;
memcpy(&etd.crypt_key[0], &opts->key.k[0], 12);
clearCommandBuffer();
@ -315,7 +315,7 @@ static int brute_em4x70(const em4x70_cmd_input_brute_t *opts, em4x70_cmd_output_
// TODO: change firmware to use per-cmd structures
em4x70_data_t etd = {0};
etd.parity = false;
etd.deprecated_ignored_use_parity = false;
etd.address = opts->block;
memcpy(&etd.rnd[0], &opts->rn.rn[0], 7);
memcpy(&etd.frnd[0], &opts->frn.frn[0], 4);
@ -366,7 +366,7 @@ static int unlock_em4x70(const em4x70_cmd_input_unlock_t *opts, em4x70_tag_info_
// TODO: change firmware to use per-cmd structures
em4x70_data_t etd = {0};
etd.parity = false;
etd.deprecated_ignored_use_parity = false;
etd.pin = BYTES2UINT32(opts->pin);
clearCommandBuffer();
@ -386,7 +386,7 @@ static int setpin_em4x70(const em4x70_cmd_input_setpin_t *opts, em4x70_tag_info_
// TODO: change firmware to use per-cmd structures
em4x70_data_t etd = {0};
etd.parity = false;
etd.deprecated_ignored_use_parity = false;
etd.pin = BYTES2UINT32(opts->pin);
clearCommandBuffer();

View file

@ -38,7 +38,7 @@
/// The only requirement is that this structure remain
/// smaller than the NG buffer size (256 bytes).
typedef struct {
bool parity;
bool deprecated_ignored_use_parity; // BUGBUG: Deprecated, ignored, but kept for structure size compatibility
// Used for writing address
uint8_t address;