From ab602794d9ee3240474528df163d417ec1f278f3 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Tue, 18 Mar 2025 22:52:19 -0700 Subject: [PATCH] rename global variable `g_command_parity` --- armsrc/em4x70.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/armsrc/em4x70.c b/armsrc/em4x70.c index 1e1b59347..5d65cc32f 100644 --- a/armsrc/em4x70.c +++ b/armsrc/em4x70.c @@ -44,10 +44,10 @@ #define DPRINTF_DEBUG(x) do { if ((FORCE_ENABLE_LOGGING) || (g_dbglevel >= DBG_DEBUG )) { Dbprintf x ; } } while (0); #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 em4x70_tag_t tag = { 0 }; -// EM4170 requires a parity bit on commands, other variants do not. -static bool command_parity = true; #if 1 // Calculation of ticks for timing functions @@ -1106,7 +1106,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, command_parity, rnd, frnd); + generator->auth(&auth_cmd, g_command_parity, rnd, frnd); bool result = send_bitstream_and_read(&auth_cmd); if (result) { @@ -1194,7 +1194,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, command_parity, &tag.data[4], pin); + generator->pin(&send_pin_cmd, g_command_parity, &tag.data[4], pin); bool result = send_bitstream_wait_ack_wait_read(&send_pin_cmd); return result ? PM3_SUCCESS : PM3_ESOFT; @@ -1205,7 +1205,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, command_parity, word, address); + generator->write(&write_cmd, g_command_parity, word, address); bool result = send_bitstream_wait_ack_wait_ack(&write_cmd); if (!result) { @@ -1292,7 +1292,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, command_parity); + generator->id(&read_id_cmd, g_command_parity); bool result = send_bitstream_and_read(&read_id_cmd); if (result) { @@ -1309,7 +1309,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, command_parity); + generator->um1(&read_um1_cmd, g_command_parity); bool result = send_bitstream_and_read(&read_um1_cmd); if (result) { @@ -1328,7 +1328,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, command_parity); + generator->um2(&read_um2_cmd, g_command_parity); bool result = send_bitstream_and_read(&read_um2_cmd); if (result) { @@ -1444,7 +1444,7 @@ void em4x70_info(const em4x70_data_t *etd, bool ledcontrol) { bool success_with_UM2 = false; // Support tags with and without command parity bits - command_parity = etd->parity; + g_command_parity = etd->parity; init_tag(); em4x70_setup_read(); @@ -1472,10 +1472,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; - command_parity = etd->parity; + g_command_parity = etd->parity; // Disable to prevent sending corrupted data to the tag. - if (command_parity) { + if (g_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; @@ -1508,7 +1508,7 @@ void em4x70_unlock(const em4x70_data_t *etd, bool ledcontrol) { int status = PM3_ESOFT; - command_parity = etd->parity; + g_command_parity = etd->parity; init_tag(); em4x70_setup_read(); @@ -1543,10 +1543,10 @@ void em4x70_auth(const em4x70_data_t *etd, bool ledcontrol) { uint8_t response[3] = {0}; - command_parity = etd->parity; + g_command_parity = etd->parity; // Disable to prevent sending corrupted data to the tag. - if (command_parity) { + if (g_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; @@ -1571,10 +1571,10 @@ void em4x70_brute(const em4x70_data_t *etd, bool ledcontrol) { int status = PM3_ESOFT; uint8_t response[2] = {0}; - command_parity = etd->parity; + g_command_parity = etd->parity; // Disable to prevent sending corrupted data to the tag. - if (command_parity) { + if (g_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; @@ -1599,10 +1599,10 @@ void em4x70_write_pin(const em4x70_data_t *etd, bool ledcontrol) { int status = PM3_ESOFT; - command_parity = etd->parity; + g_command_parity = etd->parity; // Disable to prevent sending corrupted data to the tag. - if (command_parity) { + if (g_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; @@ -1648,10 +1648,10 @@ void em4x70_write_key(const em4x70_data_t *etd, bool ledcontrol) { int status = PM3_ESOFT; - command_parity = etd->parity; + g_command_parity = etd->parity; // Disable to prevent sending corrupted data to the tag. - if (command_parity) { + if (g_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;