diff --git a/client/deps/hardnested/hardnested_bf_core.c b/client/deps/hardnested/hardnested_bf_core.c index 63eba8eba..a84ce0df9 100644 --- a/client/deps/hardnested/hardnested_bf_core.c +++ b/client/deps/hardnested/hardnested_bf_core.c @@ -371,7 +371,7 @@ uint64_t CRACK_STATES_BITSLICED(uint32_t cuid, uint8_t *best_first_bytes, statel for (uint32_t tests = 0; tests < nonces_to_bruteforce; ++tests) { // common bits with preceding test nonce uint32_t common_bits = next_common_bits; //tests ? trailing_zeros(bf_test_nonce_2nd_byte[tests] ^ bf_test_nonce_2nd_byte[tests-1]) : 0; - next_common_bits = tests < nonces_to_bruteforce - 1 ? trailing_zeros(bf_test_nonce_2nd_byte[tests] ^ bf_test_nonce_2nd_byte[tests + 1]) : 0; + next_common_bits = (tests < nonces_to_bruteforce - 1) ? trailing_zeros(bf_test_nonce_2nd_byte[tests] ^ bf_test_nonce_2nd_byte[tests + 1]) : 0; uint32_t parity_bit_idx = 1; // start checking with the parity of second nonce byte bitslice_value_t fb_bits = fbb[common_bits]; // start with precomputed feedback bits from previous nonce bitslice_value_t ks_bits = ksb[common_bits]; // dito for first keystream bits diff --git a/client/deps/hardnested/hardnested_bruteforce.c b/client/deps/hardnested/hardnested_bruteforce.c index 6bc400d1d..e4b203f4d 100644 --- a/client/deps/hardnested/hardnested_bruteforce.c +++ b/client/deps/hardnested/hardnested_bruteforce.c @@ -96,7 +96,7 @@ static uint32_t keys_found = 0; static uint64_t num_keys_tested; static uint64_t found_bs_key = 0; -inline uint8_t trailing_zeros(uint8_t byte) { +uint8_t trailing_zeros(uint8_t byte) { static const uint8_t trailing_zeros_LUT[256] = { 8, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, diff --git a/client/src/cmdlf.c b/client/src/cmdlf.c index 81ca3a081..87095631b 100644 --- a/client/src/cmdlf.c +++ b/client/src/cmdlf.c @@ -382,6 +382,17 @@ int CmdLFCommandRead(const char *Cmd) { SendCommandNG(CMD_LF_MOD_THEN_ACQ_RAW_ADC, (uint8_t *)&payload, PAYLOAD_HEADER_SIZE + cmd_len); PacketResponseNG resp; + // init to ZERO + resp.cmd = 0, + resp.length = 0, + resp.magic = 0, + resp.status = 0, + resp.crc = 0, + resp.ng = false, + resp.oldarg[0] = 0; + resp.oldarg[1] = 0; + resp.oldarg[2] = 0; + memset(resp.data.asBytes, 0, PM3_CMD_DATA_SIZE); i = 10; // 20sec wait loop diff --git a/client/src/cmdlfem4x50.c b/client/src/cmdlfem4x50.c index 09aeb8e84..c81767c7a 100644 --- a/client/src/cmdlfem4x50.c +++ b/client/src/cmdlfem4x50.c @@ -1230,9 +1230,22 @@ int CmdEM4x50Sim(const char *Cmd) { clearCommandBuffer(); SendCommandNG(CMD_LF_EM4X50_SIM, (uint8_t *)&password, sizeof(password)); - PacketResponseNG resp; - + PrintAndLogEx(INFO, "Press " _GREEN_("") " or pm3-button to abort simulation"); + + PacketResponseNG resp; + // init to ZERO + resp.cmd = 0, + resp.length = 0, + resp.magic = 0, + resp.status = 0, + resp.crc = 0, + resp.ng = false, + resp.oldarg[0] = 0; + resp.oldarg[1] = 0; + resp.oldarg[2] = 0; + memset(resp.data.asBytes, 0, PM3_CMD_DATA_SIZE); + bool keypress; do { keypress = kbd_enter_pressed(); diff --git a/client/src/comms.c b/client/src/comms.c index 68f8f9631..a7ed0fd06 100644 --- a/client/src/comms.c +++ b/client/src/comms.c @@ -742,10 +742,6 @@ static size_t communication_delay(void) { bool WaitForResponseTimeoutW(uint32_t cmd, PacketResponseNG *response, size_t ms_timeout, bool show_warning) { PacketResponseNG resp; - if (response == NULL) { - response = &resp; - } - // init to ZERO resp.cmd = 0, resp.length = 0, @@ -758,6 +754,10 @@ bool WaitForResponseTimeoutW(uint32_t cmd, PacketResponseNG *response, size_t ms resp.oldarg[2] = 0; memset(resp.data.asBytes, 0, PM3_CMD_DATA_SIZE); + if (response == NULL) { + response = &resp; + } + // Add delay depending on the communication channel & speed if (ms_timeout != (size_t) - 1) ms_timeout += communication_delay();