mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
fix some potential empty responses and too much inline calls
This commit is contained in:
parent
a2ea5e3a24
commit
24a138eeb1
5 changed files with 32 additions and 8 deletions
|
@ -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) {
|
for (uint32_t tests = 0; tests < nonces_to_bruteforce; ++tests) {
|
||||||
// common bits with preceding test nonce
|
// 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;
|
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
|
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 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
|
bitslice_value_t ks_bits = ksb[common_bits]; // dito for first keystream bits
|
||||||
|
|
|
@ -96,7 +96,7 @@ static uint32_t keys_found = 0;
|
||||||
static uint64_t num_keys_tested;
|
static uint64_t num_keys_tested;
|
||||||
static uint64_t found_bs_key = 0;
|
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] = {
|
static const uint8_t trailing_zeros_LUT[256] = {
|
||||||
8, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
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,
|
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
|
||||||
|
|
|
@ -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);
|
SendCommandNG(CMD_LF_MOD_THEN_ACQ_RAW_ADC, (uint8_t *)&payload, PAYLOAD_HEADER_SIZE + cmd_len);
|
||||||
|
|
||||||
PacketResponseNG resp;
|
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;
|
i = 10;
|
||||||
// 20sec wait loop
|
// 20sec wait loop
|
||||||
|
|
|
@ -1230,9 +1230,22 @@ int CmdEM4x50Sim(const char *Cmd) {
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandNG(CMD_LF_EM4X50_SIM, (uint8_t *)&password, sizeof(password));
|
SendCommandNG(CMD_LF_EM4X50_SIM, (uint8_t *)&password, sizeof(password));
|
||||||
PacketResponseNG resp;
|
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "Press " _GREEN_("<Enter>") " or pm3-button to abort simulation");
|
PrintAndLogEx(INFO, "Press " _GREEN_("<Enter>") " 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;
|
bool keypress;
|
||||||
do {
|
do {
|
||||||
keypress = kbd_enter_pressed();
|
keypress = kbd_enter_pressed();
|
||||||
|
|
|
@ -742,10 +742,6 @@ static size_t communication_delay(void) {
|
||||||
bool WaitForResponseTimeoutW(uint32_t cmd, PacketResponseNG *response, size_t ms_timeout, bool show_warning) {
|
bool WaitForResponseTimeoutW(uint32_t cmd, PacketResponseNG *response, size_t ms_timeout, bool show_warning) {
|
||||||
|
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
if (response == NULL) {
|
|
||||||
response = &resp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// init to ZERO
|
// init to ZERO
|
||||||
resp.cmd = 0,
|
resp.cmd = 0,
|
||||||
resp.length = 0,
|
resp.length = 0,
|
||||||
|
@ -758,6 +754,10 @@ bool WaitForResponseTimeoutW(uint32_t cmd, PacketResponseNG *response, size_t ms
|
||||||
resp.oldarg[2] = 0;
|
resp.oldarg[2] = 0;
|
||||||
memset(resp.data.asBytes, 0, PM3_CMD_DATA_SIZE);
|
memset(resp.data.asBytes, 0, PM3_CMD_DATA_SIZE);
|
||||||
|
|
||||||
|
if (response == NULL) {
|
||||||
|
response = &resp;
|
||||||
|
}
|
||||||
|
|
||||||
// Add delay depending on the communication channel & speed
|
// Add delay depending on the communication channel & speed
|
||||||
if (ms_timeout != (size_t) - 1)
|
if (ms_timeout != (size_t) - 1)
|
||||||
ms_timeout += communication_delay();
|
ms_timeout += communication_delay();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue