mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
remove some cppcheck warnings
This commit is contained in:
parent
dd9005719a
commit
1ebfa897c8
24 changed files with 145 additions and 146 deletions
|
@ -387,19 +387,19 @@ void RunMod() {
|
|||
|
||||
LED_B_ON(); // green
|
||||
// assuming arg0==0, use hardcoded uid 0xdeadbeaf
|
||||
uint16_t flags;
|
||||
uint16_t simflags;
|
||||
switch (p_card.uidlen) {
|
||||
case 10:
|
||||
flags = FLAG_10B_UID_IN_DATA;
|
||||
simflags = FLAG_10B_UID_IN_DATA;
|
||||
break;
|
||||
case 7:
|
||||
flags = FLAG_7B_UID_IN_DATA;
|
||||
simflags = FLAG_7B_UID_IN_DATA;
|
||||
break;
|
||||
default:
|
||||
flags = FLAG_4B_UID_IN_DATA;
|
||||
simflags = FLAG_4B_UID_IN_DATA;
|
||||
break;
|
||||
}
|
||||
Mifare1ksim(flags | FLAG_MF_1K, 0, uid);
|
||||
Mifare1ksim(simflags | FLAG_MF_1K, 0, uid);
|
||||
LED_B_OFF();
|
||||
|
||||
/*
|
||||
|
|
|
@ -89,6 +89,8 @@ void cmac(const desfirekey_t key, uint8_t *ivect, const uint8_t *data, size_t le
|
|||
}
|
||||
|
||||
size_t key_block_size(const desfirekey_t key) {
|
||||
if (key == NULL)
|
||||
return 0;
|
||||
size_t block_size = 8;
|
||||
switch (key->type) {
|
||||
case T_DES:
|
||||
|
|
|
@ -685,7 +685,7 @@ void SniffHitag(void) {
|
|||
|
||||
StopTicks();
|
||||
|
||||
int frame_count;
|
||||
// int frame_count;
|
||||
int response;
|
||||
int overflow;
|
||||
bool rising_edge;
|
||||
|
@ -743,7 +743,7 @@ void SniffHitag(void) {
|
|||
|
||||
// Reset the received frame, frame count and timing info
|
||||
memset(rx, 0x00, sizeof(rx));
|
||||
frame_count = 0;
|
||||
// frame_count = 0;
|
||||
response = 0;
|
||||
overflow = 0;
|
||||
reader_frame = false;
|
||||
|
@ -850,7 +850,7 @@ void SniffHitag(void) {
|
|||
|
||||
// Check if frame was captured
|
||||
if (rxlen > 0) {
|
||||
frame_count++;
|
||||
// frame_count++;
|
||||
LogTrace(rx, nbytes(rxlen), response, 0, NULL, reader_frame);
|
||||
|
||||
// Check if we recognize a valid authentication attempt
|
||||
|
@ -901,7 +901,8 @@ void SimulateHitagTag(bool tag_mem_supplied, uint8_t *data) {
|
|||
|
||||
StopTicks();
|
||||
|
||||
int frame_count = 0, response = 0, overflow = 0;
|
||||
// int frame_count = 0;
|
||||
int response = 0, overflow = 0;
|
||||
uint8_t rx[HITAG_FRAME_LEN];
|
||||
size_t rxlen = 0;
|
||||
uint8_t tx[HITAG_FRAME_LEN];
|
||||
|
@ -915,7 +916,7 @@ void SimulateHitagTag(bool tag_mem_supplied, uint8_t *data) {
|
|||
|
||||
auth_table_len = 0;
|
||||
auth_table_pos = 0;
|
||||
uint8_t *auth_table = BigBuf_malloc(AUTH_TABLE_LENGTH);
|
||||
auth_table = BigBuf_malloc(AUTH_TABLE_LENGTH);
|
||||
memset(auth_table, 0x00, AUTH_TABLE_LENGTH);
|
||||
|
||||
// Reset the received frame, frame count and timing info
|
||||
|
@ -1018,7 +1019,7 @@ void SimulateHitagTag(bool tag_mem_supplied, uint8_t *data) {
|
|||
|
||||
// Check if frame was captured
|
||||
if (rxlen > 4) {
|
||||
frame_count++;
|
||||
// frame_count++;
|
||||
LogTrace(rx, nbytes(rxlen), response, response, NULL, true);
|
||||
|
||||
// Disable timer 1 with external trigger to avoid triggers during our own modulation
|
||||
|
@ -1074,7 +1075,7 @@ void ReaderHitag(hitag_function htf, hitag_data *htd) {
|
|||
|
||||
StopTicks();
|
||||
|
||||
int frame_count = 0;
|
||||
// int frame_count = 0;
|
||||
int response = 0;
|
||||
uint8_t rx[HITAG_FRAME_LEN];
|
||||
size_t rxlen = 0;
|
||||
|
@ -1209,7 +1210,7 @@ void ReaderHitag(hitag_function htf, hitag_data *htd) {
|
|||
|
||||
// Check if frame was captured and store it
|
||||
if (rxlen > 0) {
|
||||
frame_count++;
|
||||
// frame_count++;
|
||||
LogTrace(rx, nbytes(rxlen), response, response, NULL, false);
|
||||
}
|
||||
|
||||
|
@ -1265,7 +1266,7 @@ void ReaderHitag(hitag_function htf, hitag_data *htd) {
|
|||
|
||||
// Add transmitted frame to total count
|
||||
if (txlen > 0) {
|
||||
frame_count++;
|
||||
// frame_count++;
|
||||
LogTrace(tx, nbytes(txlen), HITAG_T_WAIT_2, HITAG_T_WAIT_2, NULL, true);
|
||||
}
|
||||
|
||||
|
@ -1359,7 +1360,8 @@ void WriterHitag(hitag_function htf, hitag_data *htd, int page) {
|
|||
|
||||
StopTicks();
|
||||
|
||||
int frame_count = 0, response = 0;
|
||||
// int frame_count = 0;
|
||||
int response = 0;
|
||||
uint8_t rx[HITAG_FRAME_LEN];
|
||||
size_t rxlen = 0;
|
||||
uint8_t txbuf[HITAG_FRAME_LEN];
|
||||
|
@ -1468,7 +1470,7 @@ void WriterHitag(hitag_function htf, hitag_data *htd, int page) {
|
|||
|
||||
// Check if frame was captured and store it
|
||||
if (rxlen > 0) {
|
||||
frame_count++;
|
||||
// frame_count++;
|
||||
LogTrace(rx, nbytes(rxlen), response, response, NULL, false);
|
||||
}
|
||||
|
||||
|
@ -1505,7 +1507,7 @@ void WriterHitag(hitag_function htf, hitag_data *htd, int page) {
|
|||
|
||||
// Add transmitted frame to total count
|
||||
if (txlen > 0) {
|
||||
frame_count++;
|
||||
// frame_count++;
|
||||
LogTrace(tx, nbytes(txlen), HITAG_T_WAIT_2, HITAG_T_WAIT_2, NULL, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,9 +35,9 @@ static int temp2 = 0;
|
|||
static int sof_bits; // number of start-of-frame bits
|
||||
static uint8_t pwdh0, pwdl0, pwdl1; // password bytes
|
||||
static uint32_t rnd = 0x74124485; // randomnumber
|
||||
static int test = 0;
|
||||
size_t blocknr;
|
||||
bool end = false;
|
||||
//#define SENDBIT_TEST
|
||||
|
||||
#define ht2bs_4a(a,b,c,d) (~(((a|b)&c)^(a|d)^b))
|
||||
#define ht2bs_4b(a,b,c,d) (~(((d|c)&(a^b))^(d|a|b)))
|
||||
|
@ -220,7 +220,7 @@ static void hitag_reader_send_bit(int bit) {
|
|||
|
||||
HIGH(GPIO_SSC_DOUT);
|
||||
|
||||
if (test == 1) {
|
||||
#ifdef SENDBIT_TEST
|
||||
// Wait for 4-10 times the carrier period
|
||||
while (AT91C_BASE_TC0->TC_CV < T0 * 6) {};
|
||||
|
||||
|
@ -233,7 +233,7 @@ static void hitag_reader_send_bit(int bit) {
|
|||
// One bit: |_--|
|
||||
while (AT91C_BASE_TC0->TC_CV < T0 * 14) {};
|
||||
}
|
||||
} else {
|
||||
#else
|
||||
// Wait for 4-10 times the carrier period
|
||||
while (AT91C_BASE_TC0->TC_CV < T0 * 6) {};
|
||||
|
||||
|
@ -246,7 +246,7 @@ static void hitag_reader_send_bit(int bit) {
|
|||
// One bit: |_--|
|
||||
while (AT91C_BASE_TC0->TC_CV < T0 * 28) {};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
LED_A_OFF();
|
||||
}
|
||||
|
@ -275,11 +275,10 @@ static void hitag_reader_send_frame(const uint8_t *frame, size_t frame_len) {
|
|||
*/
|
||||
static int check_select(uint8_t *rx, uint32_t uid) {
|
||||
unsigned char resp[48];
|
||||
int i;
|
||||
uint32_t ans = 0x0;
|
||||
for (i = 0; i < 48; i++)
|
||||
for (int i = 0; i < 48; i++)
|
||||
resp[i] = (rx[i / 8] >> (7 - (i % 8))) & 0x1;
|
||||
for (i = 0; i < 32; i++)
|
||||
for (int i = 0; i < 32; i++)
|
||||
ans += resp[5 + i] << (31 - i);
|
||||
|
||||
temp_uid = ans;
|
||||
|
@ -733,6 +732,7 @@ static int hitagS_handle_tag_auth(hitag_function htf, uint64_t key, uint64_t NrA
|
|||
for (int i = 0; i < 5; i++) {
|
||||
response_bit[i] = 0;
|
||||
}
|
||||
{
|
||||
int i = 5;
|
||||
for (; i < 37; i++) {
|
||||
response_bit[i] = uid[i - 5];
|
||||
|
@ -744,7 +744,7 @@ static int hitagS_handle_tag_auth(hitag_function htf, uint64_t key, uint64_t NrA
|
|||
response_bit[i] = 1;
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
k = 0;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
tx[i] = (response_bit[k] << 7)
|
||||
|
@ -892,7 +892,8 @@ void SimulateHitagSTag(bool tag_mem_supplied, uint8_t *data) {
|
|||
|
||||
StopTicks();
|
||||
|
||||
int frame_count = 0, response = 0, overflow = 0;
|
||||
// int frame_count = 0;
|
||||
int response = 0, overflow = 0;
|
||||
int i, j;
|
||||
uint8_t rx[HITAG_FRAME_LEN];
|
||||
size_t rxlen = 0;
|
||||
|
@ -1058,7 +1059,7 @@ void SimulateHitagSTag(bool tag_mem_supplied, uint8_t *data) {
|
|||
|
||||
// Check if frame was captured
|
||||
if (rxlen > 0) {
|
||||
frame_count++;
|
||||
// frame_count++;
|
||||
LogTrace(rx, nbytes(rxlen), response, 0, NULL, true);
|
||||
|
||||
// Disable timer 1 with external trigger to avoid triggers during our own modulation
|
||||
|
@ -1121,7 +1122,8 @@ void ReadHitagS(hitag_function htf, hitag_data *htd) {
|
|||
StopTicks();
|
||||
|
||||
int i, j, z, k;
|
||||
int frame_count = 0, response = 0;
|
||||
// int frame_count = 0;
|
||||
int response = 0;
|
||||
int response_bit[200];
|
||||
uint8_t rx[HITAG_FRAME_LEN];
|
||||
size_t rxlen = 0;
|
||||
|
@ -1228,7 +1230,7 @@ void ReadHitagS(hitag_function htf, hitag_data *htd) {
|
|||
|
||||
// Check if frame was captured and store it
|
||||
if (rxlen > 0) {
|
||||
frame_count++;
|
||||
// frame_count++;
|
||||
LogTrace(rx, nbytes(rxlen), response, 0, NULL, false);
|
||||
}
|
||||
|
||||
|
@ -1355,7 +1357,7 @@ void ReadHitagS(hitag_function htf, hitag_data *htd) {
|
|||
|
||||
// Add transmitted frame to total count
|
||||
if (txlen > 0) {
|
||||
frame_count++;
|
||||
// frame_count++;
|
||||
LogTrace(tx, nbytes(txlen), HITAG_T_WAIT_2, 0, NULL, true);
|
||||
}
|
||||
|
||||
|
@ -1449,7 +1451,8 @@ void WritePageHitagS(hitag_function htf, hitag_data *htd, int page) {
|
|||
|
||||
StopTicks();
|
||||
|
||||
int frame_count = 0, response = 0;
|
||||
// int frame_count = 0;
|
||||
int response = 0;
|
||||
uint8_t rx[HITAG_FRAME_LEN];
|
||||
size_t rxlen = 0;
|
||||
uint8_t txbuf[HITAG_FRAME_LEN];
|
||||
|
@ -1556,7 +1559,7 @@ void WritePageHitagS(hitag_function htf, hitag_data *htd, int page) {
|
|||
|
||||
// Check if frame was captured and store it
|
||||
if (rxlen > 0) {
|
||||
frame_count++;
|
||||
// frame_count++;
|
||||
LogTrace(rx, nbytes(rxlen), response, 0, NULL, false);
|
||||
}
|
||||
|
||||
|
@ -1643,7 +1646,7 @@ void WritePageHitagS(hitag_function htf, hitag_data *htd, int page) {
|
|||
|
||||
// Add transmitted frame to total count
|
||||
if (txlen > 0) {
|
||||
frame_count++;
|
||||
// frame_count++;
|
||||
LogTrace(tx, nbytes(txlen), HITAG_T_WAIT_2, 0, NULL, true);
|
||||
}
|
||||
|
||||
|
@ -1741,7 +1744,8 @@ void WritePageHitagS(hitag_function htf, hitag_data *htd, int page) {
|
|||
*/
|
||||
void check_challenges(bool file_given, uint8_t *data) {
|
||||
int i, j, z, k;
|
||||
int frame_count = 0, response = 0;
|
||||
// int frame_count = 0;
|
||||
int response = 0;
|
||||
uint8_t uid_byte[4];
|
||||
uint8_t rx[HITAG_FRAME_LEN];
|
||||
uint8_t unlocker[60][8];
|
||||
|
@ -1824,7 +1828,7 @@ void check_challenges(bool file_given, uint8_t *data) {
|
|||
|
||||
// Check if frame was captured and store it
|
||||
if (rxlen > 0) {
|
||||
frame_count++;
|
||||
// frame_count++;
|
||||
LogTrace(rx, nbytes(rxlen), response, 0, NULL, false);
|
||||
}
|
||||
|
||||
|
@ -1951,7 +1955,7 @@ void check_challenges(bool file_given, uint8_t *data) {
|
|||
|
||||
// Add transmitted frame to total count
|
||||
if (txlen > 0) {
|
||||
frame_count++;
|
||||
// frame_count++;
|
||||
LogTrace(tx, nbytes(txlen), HITAG_T_WAIT_2, 0, NULL, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -153,7 +153,6 @@ static void uart_init(uint8_t *data) {
|
|||
static void uart_bit(uint8_t bit) {
|
||||
static uint8_t buf = 0xff;
|
||||
static uint8_t n_buf;
|
||||
static uint8_t msg_byte;
|
||||
static int nmsg_byte;
|
||||
buf <<= 1;
|
||||
buf |= bit ? 1 : 0;
|
||||
|
@ -166,6 +165,7 @@ static void uart_bit(uint8_t bit) {
|
|||
nmsg_byte = 0;
|
||||
}
|
||||
} else {
|
||||
static uint8_t msg_byte;
|
||||
n_buf++;
|
||||
if (n_buf == 8) {
|
||||
msg_byte >>= 2;
|
||||
|
|
|
@ -1400,8 +1400,7 @@ void SimulateIso14443aTag(uint8_t tagType, uint8_t flags, uint8_t *data) {
|
|||
EmSendCmd(cmd, sizeof(cmd));
|
||||
} else {
|
||||
EmSend4bit(CARD_NACK_NA);
|
||||
uint32_t pwd = bytes_to_num(receivedCmd + 1, 4);
|
||||
if (DBGLEVEL >= DBG_DEBUG) Dbprintf("Auth attempt: %08x", pwd);
|
||||
if (DBGLEVEL >= DBG_DEBUG) Dbprintf("Auth attempt: %08x", bytes_to_num(receivedCmd + 1, 4));
|
||||
}
|
||||
p_response = NULL;
|
||||
} else if (receivedCmd[0] == MIFARE_ULEV1_VCSL && len == 23 && tagType == 7) {
|
||||
|
@ -2126,13 +2125,8 @@ static int GetATQA(uint8_t *resp, uint8_t *resp_par) {
|
|||
// requests ATS unless no_rats is true
|
||||
int iso14443a_select_card(uint8_t *uid_ptr, iso14a_card_select_t *p_card, uint32_t *cuid_ptr, bool anticollision, uint8_t num_cascades, bool no_rats) {
|
||||
|
||||
uint8_t sel_all[] = { ISO14443A_CMD_ANTICOLL_OR_SELECT, 0x20 };
|
||||
uint8_t sel_uid[] = { ISO14443A_CMD_ANTICOLL_OR_SELECT, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t rats[] = { ISO14443A_CMD_RATS, 0x80, 0x00, 0x00 }; // FSD=256, FSDI=8, CID=0
|
||||
uint8_t resp[MAX_FRAME_SIZE] = {0}; // theoretically. A usual RATS will be much smaller
|
||||
uint8_t resp_par[MAX_PARITY_SIZE] = {0};
|
||||
uint8_t uid_resp[4] = {0};
|
||||
size_t uid_resp_len = 0;
|
||||
|
||||
uint8_t sak = 0x04; // cascade uid
|
||||
int cascade_level = 0;
|
||||
|
@ -2166,6 +2160,9 @@ int iso14443a_select_card(uint8_t *uid_ptr, iso14a_card_select_t *p_card, uint32
|
|||
// While the UID is not complete, the 3nd bit (from the right) is set in the SAK.
|
||||
for (; sak & 0x04; cascade_level++) {
|
||||
// SELECT_* (L1: 0x93, L2: 0x95, L3: 0x97)
|
||||
uint8_t sel_all[] = { ISO14443A_CMD_ANTICOLL_OR_SELECT, 0x20 };
|
||||
uint8_t sel_uid[] = { ISO14443A_CMD_ANTICOLL_OR_SELECT, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t uid_resp[4] = {0};
|
||||
sel_uid[0] = sel_all[0] = 0x93 + cascade_level * 2;
|
||||
|
||||
if (anticollision) {
|
||||
|
@ -2213,7 +2210,7 @@ int iso14443a_select_card(uint8_t *uid_ptr, iso14a_card_select_t *p_card, uint32
|
|||
memcpy(uid_resp, uid_ptr + cascade_level * 3, 4);
|
||||
}
|
||||
}
|
||||
uid_resp_len = 4;
|
||||
size_t uid_resp_len = 4;
|
||||
|
||||
// calculate crypto UID. Always use last 4 Bytes.
|
||||
if (cuid_ptr)
|
||||
|
@ -2259,7 +2256,7 @@ int iso14443a_select_card(uint8_t *uid_ptr, iso14a_card_select_t *p_card, uint32
|
|||
|
||||
// RATS, Request for answer to select
|
||||
if (!no_rats) {
|
||||
|
||||
uint8_t rats[] = { ISO14443A_CMD_RATS, 0x80, 0x00, 0x00 }; // FSD=256, FSDI=8, CID=0
|
||||
AddCrc14A(rats, 2);
|
||||
ReaderTransmit(rats, sizeof(rats), NULL);
|
||||
int len = ReaderReceive(resp, resp_par);
|
||||
|
@ -2281,8 +2278,6 @@ int iso14443a_select_card(uint8_t *uid_ptr, iso14a_card_select_t *p_card, uint32
|
|||
}
|
||||
|
||||
int iso14443a_fast_select_card(uint8_t *uid_ptr, uint8_t num_cascades) {
|
||||
uint8_t sel_all[] = { ISO14443A_CMD_ANTICOLL_OR_SELECT, 0x20 };
|
||||
uint8_t sel_uid[] = { ISO14443A_CMD_ANTICOLL_OR_SELECT, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t resp[5] = {0}; // theoretically. A usual RATS will be much smaller
|
||||
uint8_t resp_par[1] = {0};
|
||||
uint8_t uid_resp[4] = {0};
|
||||
|
@ -2298,6 +2293,8 @@ int iso14443a_fast_select_card(uint8_t *uid_ptr, uint8_t num_cascades) {
|
|||
// which case we need to make a cascade 2 request and select - this is a long UID
|
||||
// While the UID is not complete, the 3nd bit (from the right) is set in the SAK.
|
||||
for (; sak & 0x04; cascade_level++) {
|
||||
uint8_t sel_all[] = { ISO14443A_CMD_ANTICOLL_OR_SELECT, 0x20 };
|
||||
uint8_t sel_uid[] = { ISO14443A_CMD_ANTICOLL_OR_SELECT, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
// SELECT_* (L1: 0x93, L2: 0x95, L3: 0x97)
|
||||
sel_uid[0] = sel_all[0] = 0x93 + cascade_level * 2;
|
||||
|
||||
|
|
|
@ -1956,10 +1956,10 @@ void MifareCIdent() {
|
|||
if (!ReaderReceive(rec, recpar) || (rec[0] != 0x0a)) {
|
||||
goto TEST2;
|
||||
};
|
||||
isGen = GEN_1B;
|
||||
|
||||
ReaderTransmit(wupC2, sizeof(wupC2), NULL);
|
||||
if (!ReaderReceive(rec, recpar) || (rec[0] != 0x0a)) {
|
||||
isGen = GEN_1B;
|
||||
goto OUT;
|
||||
};
|
||||
isGen = GEN_1A;
|
||||
|
|
|
@ -605,12 +605,12 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain) {
|
|||
// Incoming SELECT CLx for any cascade level
|
||||
if (receivedCmd_len == 9 && receivedCmd[1] == 0x70) {
|
||||
if (memcmp(&receivedCmd[2], responses[uid_index].response, 4) == 0) {
|
||||
bool finished = (uid_len == 4 && uid_index == UIDBCC1) ||
|
||||
bool cl_finished = (uid_len == 4 && uid_index == UIDBCC1) ||
|
||||
(uid_len == 7 && uid_index == UIDBCC2) ||
|
||||
(uid_len == 10 && uid_index == UIDBCC3);
|
||||
EmSendPrecompiledCmd(&responses[finished ? SAK : SAKuid]);
|
||||
EmSendPrecompiledCmd(&responses[cl_finished ? SAK : SAKuid]);
|
||||
if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("SELECT CLx %02x%02x%02x%02x received", receivedCmd[2], receivedCmd[3], receivedCmd[4], receivedCmd[5]);
|
||||
if (finished) {
|
||||
if (cl_finished) {
|
||||
LED_B_ON();
|
||||
cardSTATE = MFEMUL_WORK;
|
||||
if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("[MFEMUL_SELECT] cardSTATE = MFEMUL_WORK");
|
||||
|
|
|
@ -341,26 +341,24 @@ gcd(int a, int b) {
|
|||
static void
|
||||
permute_args(int panonopt_start, int panonopt_end, int opt_end,
|
||||
char *const *nargv) {
|
||||
int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
|
||||
char *swap;
|
||||
|
||||
/*
|
||||
* compute lengths of blocks and number and size of cycles
|
||||
*/
|
||||
nnonopts = panonopt_end - panonopt_start;
|
||||
nopts = opt_end - panonopt_end;
|
||||
ncycle = gcd(nnonopts, nopts);
|
||||
cyclelen = (opt_end - panonopt_start) / ncycle;
|
||||
int nnonopts = panonopt_end - panonopt_start;
|
||||
int nopts = opt_end - panonopt_end;
|
||||
int ncycle = gcd(nnonopts, nopts);
|
||||
int cyclelen = (opt_end - panonopt_start) / ncycle;
|
||||
|
||||
for (i = 0; i < ncycle; i++) {
|
||||
cstart = panonopt_end + i;
|
||||
pos = cstart;
|
||||
for (j = 0; j < cyclelen; j++) {
|
||||
for (int i = 0; i < ncycle; i++) {
|
||||
int cstart = panonopt_end + i;
|
||||
int pos = cstart;
|
||||
for (int j = 0; j < cyclelen; j++) {
|
||||
if (pos >= panonopt_end)
|
||||
pos -= nnonopts;
|
||||
else
|
||||
pos += nopts;
|
||||
swap = nargv[pos];
|
||||
char *swap = nargv[pos];
|
||||
/* LINTED const cast */
|
||||
((char **) nargv)[pos] = nargv[cstart];
|
||||
/* LINTED const cast */
|
||||
|
|
|
@ -222,7 +222,6 @@ static uint16_t calcBSDchecksum4(uint8_t *bytes, uint8_t len, uint32_t mask) {
|
|||
// measuring LFSR maximum length
|
||||
static int CmdAnalyseLfsr(const char *Cmd) {
|
||||
|
||||
uint16_t lfsr; /* Any nonzero start state will work. */
|
||||
uint8_t iv = param_get8ex(Cmd, 0, 0, 16);
|
||||
uint8_t find = param_get8ex(Cmd, 1, 0, 16);
|
||||
|
||||
|
@ -232,7 +231,7 @@ static int CmdAnalyseLfsr(const char *Cmd) {
|
|||
for (uint8_t i = 0x01; i < 0x30; i += 1) {
|
||||
legic_prng_init(iv);
|
||||
legic_prng_forward(i);
|
||||
lfsr = legic_prng_get_bits(12);
|
||||
uint16_t lfsr = legic_prng_get_bits(12); /* Any nonzero start state will work. */
|
||||
PrintAndLogEx(NORMAL, " %02X | %03X | %03X | %03X \n", i, lfsr, 0x40 ^ lfsr, find ^ lfsr);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -935,12 +935,12 @@ static int CmdUndec(const char *Cmd) {
|
|||
//by marshmellow
|
||||
//shift graph zero up or down based on input + or -
|
||||
static int CmdGraphShiftZero(const char *Cmd) {
|
||||
int shift = 0, shiftedVal;
|
||||
int shift = 0;
|
||||
//set options from parameters entered with the command
|
||||
sscanf(Cmd, "%i", &shift);
|
||||
|
||||
for (size_t i = 0; i < GraphTraceLen; i++) {
|
||||
shiftedVal = GraphBuffer[i] + shift;
|
||||
int shiftedVal = GraphBuffer[i] + shift;
|
||||
|
||||
if (shiftedVal > 127)
|
||||
shiftedVal = 127;
|
||||
|
|
|
@ -788,7 +788,8 @@ int ExchangeAPDU14a(uint8_t *datain, int datainlen, bool activateField, bool lea
|
|||
}
|
||||
|
||||
// check R-block ACK
|
||||
if ((*dataoutlen == 0) && (*dataoutlen != 0 || chaining != chainBlockNotLast)) {
|
||||
//TODO check this one...
|
||||
if ((*dataoutlen == 0) && (*dataoutlen != 0 || chaining != chainBlockNotLast)) { // *dataoutlen!=0. 'A && (!A || B)' is equivalent to 'A && B'
|
||||
if (!leaveSignalON)
|
||||
DropField();
|
||||
|
||||
|
|
|
@ -1067,7 +1067,6 @@ void annotateMifare(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, uint8
|
|||
|
||||
bool DecodeMifareData(uint8_t *cmd, uint8_t cmdsize, uint8_t *parity, bool isResponse, uint8_t *mfData, size_t *mfDataLen) {
|
||||
static struct Crypto1State *traceCrypto1;
|
||||
static uint64_t mfLastKey;
|
||||
|
||||
*mfDataLen = 0;
|
||||
|
||||
|
@ -1085,6 +1084,7 @@ bool DecodeMifareData(uint8_t *cmd, uint8_t cmdsize, uint8_t *parity, bool isRes
|
|||
return false;
|
||||
|
||||
if (MifareAuthState == masFirstData) {
|
||||
static uint64_t mfLastKey;
|
||||
if (AuthData.first_auth) {
|
||||
AuthData.ks2 = AuthData.ar_enc ^ prng_successor(AuthData.nt, 64);
|
||||
AuthData.ks3 = AuthData.at_enc ^ prng_successor(AuthData.nt, 96);
|
||||
|
|
|
@ -610,10 +610,10 @@ static int CmdHF14ADesAuth(const char *Cmd) {
|
|||
|
||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
||||
if (isOK) {
|
||||
uint8_t *data = resp.data.asBytes;
|
||||
uint8_t *session = resp.data.asBytes;
|
||||
|
||||
PrintAndLogEx(NORMAL, " Key :%s", sprint_hex(key, keylength));
|
||||
PrintAndLogEx(NORMAL, " SESSION :%s", sprint_hex(data, keylength));
|
||||
PrintAndLogEx(NORMAL, " SESSION :%s", sprint_hex(session, keylength));
|
||||
PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
|
||||
//PrintAndLogEx(NORMAL, " Expected :B5 21 9E E8 1A A7 49 9D 21 96 68 7E 13 97 38 56");
|
||||
} else {
|
||||
|
|
|
@ -825,12 +825,11 @@ static int compare_sum_a8_guess(const void *b1, const void *b2) {
|
|||
|
||||
|
||||
static float check_smallest_bitflip_bitarrays(void) {
|
||||
uint32_t num_odd, num_even;
|
||||
uint64_t smallest = 1LL << 48;
|
||||
// initialize best_first_bytes, do a rough estimation on remaining states
|
||||
for (uint16_t i = 0; i < 256; i++) {
|
||||
num_odd = nonces[i].num_states_bitarray[ODD_STATE];
|
||||
num_even = nonces[i].num_states_bitarray[EVEN_STATE]; // * (float)nonces[i^0x80].num_states_bitarray[EVEN_STATE] / num_all_bitflips_bitarray[EVEN_STATE];
|
||||
uint32_t num_odd = nonces[i].num_states_bitarray[ODD_STATE];
|
||||
uint32_t num_even = nonces[i].num_states_bitarray[EVEN_STATE]; // * (float)nonces[i^0x80].num_states_bitarray[EVEN_STATE] / num_all_bitflips_bitarray[EVEN_STATE];
|
||||
if ((uint64_t)num_odd * num_even < smallest) {
|
||||
smallest = (uint64_t)num_odd * num_even;
|
||||
best_first_byte_smallest_bitarray = i;
|
||||
|
@ -838,8 +837,8 @@ static float check_smallest_bitflip_bitarrays(void) {
|
|||
}
|
||||
|
||||
#if defined (DEBUG_REDUCTION)
|
||||
num_odd = nonces[best_first_byte_smallest_bitarray].num_states_bitarray[ODD_STATE];
|
||||
num_even = nonces[best_first_byte_smallest_bitarray].num_states_bitarray[EVEN_STATE]; // * (float)nonces[best_first_byte_smallest_bitarray^0x80].num_states_bitarray[EVEN_STATE] / num_all_bitflips_bitarray[EVEN_STATE];
|
||||
uint32_t num_odd = nonces[best_first_byte_smallest_bitarray].num_states_bitarray[ODD_STATE];
|
||||
uint32_t num_even = nonces[best_first_byte_smallest_bitarray].num_states_bitarray[EVEN_STATE]; // * (float)nonces[best_first_byte_smallest_bitarray^0x80].num_states_bitarray[EVEN_STATE] / num_all_bitflips_bitarray[EVEN_STATE];
|
||||
PrintAndLogEx(NORMAL, "0x%02x: %8d * %8d = %12" PRIu64 " (2^%1.1f)\n", best_first_byte_smallest_bitarray, num_odd, num_even, (uint64_t)num_odd * num_even, log((uint64_t)num_odd * num_even) / log(2.0));
|
||||
#endif
|
||||
return (float)smallest / 2.0;
|
||||
|
|
|
@ -394,8 +394,8 @@ static int CmdHFMFPRdbl(const char *cmd) {
|
|||
if (verbose)
|
||||
PrintAndLogEx(INFO, "--block:%d sector[%d]:%02x key:%04x", blockn, mfNumBlocksPerSector(sectorNum), sectorNum, uKeyNum);
|
||||
|
||||
mf4Session session;
|
||||
int res = MifareAuth4(&session, keyn, key, true, true, verbose);
|
||||
mf4Session mf4session;
|
||||
int res = MifareAuth4(&mf4session, keyn, key, true, true, verbose);
|
||||
if (res) {
|
||||
PrintAndLogEx(ERR, "Authentication error: %d", res);
|
||||
return res;
|
||||
|
@ -404,7 +404,7 @@ static int CmdHFMFPRdbl(const char *cmd) {
|
|||
uint8_t data[250] = {0};
|
||||
int datalen = 0;
|
||||
uint8_t mac[8] = {0};
|
||||
res = MFPReadBlock(&session, plain, blockn & 0xff, blocksCount, false, false, data, sizeof(data), &datalen, mac);
|
||||
res = MFPReadBlock(&mf4session, plain, blockn & 0xff, blocksCount, false, false, data, sizeof(data), &datalen, mac);
|
||||
if (res) {
|
||||
PrintAndLogEx(ERR, "Read error: %d", res);
|
||||
return res;
|
||||
|
@ -493,8 +493,8 @@ static int CmdHFMFPRdsc(const char *cmd) {
|
|||
if (verbose)
|
||||
PrintAndLogEx(INFO, "--sector[%d]:%02x key:%04x", mfNumBlocksPerSector(sectorNum), sectorNum, uKeyNum);
|
||||
|
||||
mf4Session session;
|
||||
int res = MifareAuth4(&session, keyn, key, true, true, verbose);
|
||||
mf4Session mf4session;
|
||||
int res = MifareAuth4(&mf4session, keyn, key, true, true, verbose);
|
||||
if (res) {
|
||||
PrintAndLogEx(ERR, "Authentication error: %d", res);
|
||||
return res;
|
||||
|
@ -504,7 +504,7 @@ static int CmdHFMFPRdsc(const char *cmd) {
|
|||
int datalen = 0;
|
||||
uint8_t mac[8] = {0};
|
||||
for (int n = mfFirstBlockOfSector(sectorNum); n < mfFirstBlockOfSector(sectorNum) + mfNumBlocksPerSector(sectorNum); n++) {
|
||||
res = MFPReadBlock(&session, plain, n & 0xff, 1, false, true, data, sizeof(data), &datalen, mac);
|
||||
res = MFPReadBlock(&mf4session, plain, n & 0xff, 1, false, true, data, sizeof(data), &datalen, mac);
|
||||
if (res) {
|
||||
PrintAndLogEx(ERR, "Read error: %d", res);
|
||||
DropField();
|
||||
|
@ -597,8 +597,8 @@ static int CmdHFMFPWrbl(const char *cmd) {
|
|||
if (verbose)
|
||||
PrintAndLogEx(INFO, "--block:%d sector[%d]:%02x key:%04x", blockNum & 0xff, mfNumBlocksPerSector(sectorNum), sectorNum, uKeyNum);
|
||||
|
||||
mf4Session session;
|
||||
int res = MifareAuth4(&session, keyn, key, true, true, verbose);
|
||||
mf4Session mf4session;
|
||||
int res = MifareAuth4(&mf4session, keyn, key, true, true, verbose);
|
||||
if (res) {
|
||||
PrintAndLogEx(ERR, "Authentication error: %d", res);
|
||||
return res;
|
||||
|
@ -607,7 +607,7 @@ static int CmdHFMFPWrbl(const char *cmd) {
|
|||
uint8_t data[250] = {0};
|
||||
int datalen = 0;
|
||||
uint8_t mac[8] = {0};
|
||||
res = MFPWriteBlock(&session, blockNum & 0xff, datain, false, false, data, sizeof(data), &datalen, mac);
|
||||
res = MFPWriteBlock(&mf4session, blockNum & 0xff, datain, false, false, data, sizeof(data), &datalen, mac);
|
||||
if (res) {
|
||||
PrintAndLogEx(ERR, "Write error: %d", res);
|
||||
DropField();
|
||||
|
|
|
@ -696,13 +696,13 @@ static int ndef_print_CC(uint8_t *data) {
|
|||
// 00 always, 01 rfu, 10 proprietary, 11 rfu
|
||||
// b1, b0 write
|
||||
// 00 always, 01 rfo, 10 proprietary, 11 never
|
||||
uint8_t write = data[1] & 0x03;
|
||||
uint8_t read = (data[1] & 0x0C) >> 2;
|
||||
uint8_t minor = (data[1] & 0x30) >> 4;
|
||||
uint8_t major = (data[1] & 0xC0) >> 6;
|
||||
uint8_t cc_write = data[1] & 0x03;
|
||||
uint8_t cc_read = (data[1] & 0x0C) >> 2;
|
||||
uint8_t cc_minor = (data[1] & 0x30) >> 4;
|
||||
uint8_t cc_major = (data[1] & 0xC0) >> 6;
|
||||
|
||||
char wStr[50];
|
||||
switch (write) {
|
||||
switch (cc_write) {
|
||||
case 0:
|
||||
sprintf(wStr, "Write access granted without any security");
|
||||
break;
|
||||
|
@ -717,7 +717,7 @@ static int ndef_print_CC(uint8_t *data) {
|
|||
break;
|
||||
}
|
||||
char rStr[46];
|
||||
switch (read) {
|
||||
switch (cc_read) {
|
||||
case 0:
|
||||
sprintf(rStr, "Read access granted without any security");
|
||||
break;
|
||||
|
@ -736,7 +736,7 @@ static int ndef_print_CC(uint8_t *data) {
|
|||
PrintAndLogEx(NORMAL, " %02X : NDEF Magic Number", data[0]);
|
||||
|
||||
// PrintAndLogEx(NORMAL, " %02X : version %d.%d supported by tag", data[1], (data[1] & 0xF0) >> 4, data[1] & 0x0F);
|
||||
PrintAndLogEx(NORMAL, " %02X : version %d.%d supported by tag", data[1], major, minor);
|
||||
PrintAndLogEx(NORMAL, " %02X : version %d.%d supported by tag", data[1], cc_major, cc_minor);
|
||||
PrintAndLogEx(NORMAL, " : %s / %s", rStr, wStr);
|
||||
|
||||
PrintAndLogEx(NORMAL, " %02X : Physical Memory Size: %d bytes", data[2], data[2] * 8);
|
||||
|
|
|
@ -271,7 +271,7 @@ static void topaz_print_control_TLVs(uint8_t *memory) {
|
|||
bytes_locked_per_bit);
|
||||
lock_TLV_present = true;
|
||||
dynamic_lock_area_t *old = topaz_tag.dynamic_lock_areas;
|
||||
dynamic_lock_area_t *new = topaz_tag.dynamic_lock_areas;
|
||||
dynamic_lock_area_t *new;
|
||||
if (old == NULL) {
|
||||
new = topaz_tag.dynamic_lock_areas = (dynamic_lock_area_t *) calloc(sizeof(dynamic_lock_area_t), sizeof(uint8_t));
|
||||
} else {
|
||||
|
|
|
@ -209,13 +209,9 @@ static int CmdHIDDemod(const char *Cmd) {
|
|||
}
|
||||
} else { //if bit 38 is not set then 37 bit format is used
|
||||
fmtLen = 37;
|
||||
fc = 0;
|
||||
cardnum = 0;
|
||||
if (fmtLen == 37) {
|
||||
cardnum = (lo >> 1) & 0x7FFFF;
|
||||
fc = ((hi & 0xF) << 12) | (lo >> 20);
|
||||
}
|
||||
}
|
||||
if (fmtLen == 32 && (lo & 0x40000000)) { //if 32 bit and Kastle bit set
|
||||
PrintAndLogEx(SUCCESS, "HID Prox TAG (Kastle format) ID: %08x (%u) - Format Len: 32bit - CC: %u - FC: %u - Card: %u", lo, (lo >> 1) & 0xFFFF, cc, fc, cardnum);
|
||||
} else {
|
||||
|
|
|
@ -237,7 +237,6 @@ int CmdLFKeri(const char *Cmd) {
|
|||
int detectKeri(uint8_t *dest, size_t *size, bool *invert) {
|
||||
|
||||
uint8_t preamble[] = {1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
|
||||
uint8_t preamble_i[] = {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0};
|
||||
|
||||
// sanity check.
|
||||
if (*size < sizeof(preamble) + 100) return -1;
|
||||
|
@ -247,6 +246,7 @@ int detectKeri(uint8_t *dest, size_t *size, bool *invert) {
|
|||
if (!preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx)) {
|
||||
|
||||
// if didn't find preamble try again inverting
|
||||
uint8_t preamble_i[] = {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0};
|
||||
if (!preambleSearch(DemodBuffer, preamble_i, sizeof(preamble_i), size, &startIdx))
|
||||
return -2;
|
||||
|
||||
|
|
|
@ -95,7 +95,6 @@ int CmdLFNEXWATCH(const char *Cmd) {
|
|||
int detectNexWatch(uint8_t *dest, size_t *size, bool *invert) {
|
||||
|
||||
uint8_t preamble[28] = {0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
uint8_t preamble_i[28] = {1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
// sanity check.
|
||||
if (*size < sizeof(preamble) + 100) return -1;
|
||||
|
||||
|
@ -103,6 +102,7 @@ int detectNexWatch(uint8_t *dest, size_t *size, bool *invert) {
|
|||
|
||||
if (!preambleSearch(DemodBuffer, preamble, sizeof(preamble), size, &startIdx)) {
|
||||
// if didn't find preamble try again inverting
|
||||
uint8_t preamble_i[28] = {1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
if (!preambleSearch(DemodBuffer, preamble_i, sizeof(preamble_i), size, &startIdx)) return -4;
|
||||
*invert ^= 1;
|
||||
}
|
||||
|
|
|
@ -316,8 +316,7 @@ static int CmdUsartBtFactory(const char *Cmd) {
|
|||
msleep(200);
|
||||
}
|
||||
|
||||
int gc = tolower(getchar());
|
||||
if (gc != 'y') {
|
||||
if (tolower(getchar()) != 'y') {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(FAILED, "Aborting.");
|
||||
return PM3_EOPABORTED;
|
||||
|
@ -453,8 +452,7 @@ static int CmdUsartBtFactory(const char *Cmd) {
|
|||
while (!ukbhit()) {
|
||||
msleep(200);
|
||||
}
|
||||
int gc = getchar();
|
||||
(void)gc;
|
||||
getchar();
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "Trying to connect add-on with the new settings.");
|
||||
found = usart_bt_testcomm(USART_BAUD_RATE, USART_PARITY) == PM3_SUCCESS;
|
||||
|
@ -558,12 +556,12 @@ static int CmdUsartTX(const char *Cmd) {
|
|||
size_t i2 = 0;
|
||||
size_t n = strlen(string);
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
if ((string[i] == '\\') && (i < n - 1) && (string[i + 1] == '\\')) {
|
||||
if ((i < n - 1) && (string[i] == '\\') && (string[i + 1] == '\\')) {
|
||||
i++;
|
||||
string2[i2++] = '\\';
|
||||
continue;
|
||||
}
|
||||
if ((string[i] == '\\') && (i < n - 1) && (string[i + 1] == '"')) {
|
||||
if ((i < n - 1) && (string[i] == '\\') && (string[i + 1] == '"')) {
|
||||
i++;
|
||||
string2[i2++] = '"';
|
||||
continue;
|
||||
|
@ -571,12 +569,12 @@ static int CmdUsartTX(const char *Cmd) {
|
|||
if (string[i] == '"') {
|
||||
continue;
|
||||
}
|
||||
if ((string[i] == '\\') && (i < n - 1) && (string[i + 1] == 'r')) {
|
||||
if ((i < n - 1) && (string[i] == '\\') && (string[i + 1] == 'r')) {
|
||||
i++;
|
||||
string2[i2++] = '\r';
|
||||
continue;
|
||||
}
|
||||
if ((string[i] == '\\') && (i < n - 1) && (string[i + 1] == 'n')) {
|
||||
if ((i < n - 1) && (string[i] == '\\') && (string[i + 1] == 'n')) {
|
||||
i++;
|
||||
string2[i2++] = '\n';
|
||||
continue;
|
||||
|
@ -654,12 +652,12 @@ static int CmdUsartTXRX(const char *Cmd) {
|
|||
size_t i2 = 0;
|
||||
size_t n = strlen(string);
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
if ((string[i] == '\\') && (i < n - 1) && (string[i + 1] == '\\')) {
|
||||
if ((i < n - 1) && (string[i] == '\\') && (string[i + 1] == '\\')) {
|
||||
i++;
|
||||
string2[i2++] = '\\';
|
||||
continue;
|
||||
}
|
||||
if ((string[i] == '\\') && (i < n - 1) && (string[i + 1] == '"')) {
|
||||
if ((i < n - 1) && (string[i] == '\\') && (string[i + 1] == '"')) {
|
||||
i++;
|
||||
string2[i2++] = '"';
|
||||
continue;
|
||||
|
@ -667,12 +665,12 @@ static int CmdUsartTXRX(const char *Cmd) {
|
|||
if (string[i] == '"') {
|
||||
continue;
|
||||
}
|
||||
if ((string[i] == '\\') && (i < n - 1) && (string[i + 1] == 'r')) {
|
||||
if ((i < n - 1) && (string[i] == '\\') && (string[i + 1] == 'r')) {
|
||||
i++;
|
||||
string2[i2++] = '\r';
|
||||
continue;
|
||||
}
|
||||
if ((string[i] == '\\') && (i < n - 1) && (string[i + 1] == 'n')) {
|
||||
if ((i < n - 1) && (string[i] == '\\') && (string[i + 1] == 'n')) {
|
||||
i++;
|
||||
string2[i2++] = '\n';
|
||||
continue;
|
||||
|
|
|
@ -119,6 +119,10 @@ static void SendCommandNG_internal(uint16_t cmd, uint8_t *data, size_t len, bool
|
|||
PrintAndLogEx(WARNING, "Sending %d bytes of payload is too much, abort", len);
|
||||
return;
|
||||
}
|
||||
if (data == NULL) {
|
||||
PrintAndLogEx(WARNING, "SendCommandNG_internal NULL pointer, abort");
|
||||
return;
|
||||
}
|
||||
|
||||
PacketCommandNGPostamble *tx_post = (PacketCommandNGPostamble *)((uint8_t *)&txBufferNG + sizeof(PacketCommandNGPreamble) + len);
|
||||
|
||||
|
@ -601,7 +605,6 @@ int TestProxmark(void) {
|
|||
}
|
||||
|
||||
bool error = false;
|
||||
if (len)
|
||||
error = memcmp(data, resp.data.asBytes, len) != 0;
|
||||
|
||||
if (error)
|
||||
|
|
|
@ -108,9 +108,9 @@ static uint8_t _select(bool x, bool y, uint8_t r) {
|
|||
bool r6 = r >> 1 & 0x1;
|
||||
bool r7 = r & 0x1;
|
||||
|
||||
bool z0 = (r0 & r2) ^ (r1 & !r3) ^ (r2 | r4);
|
||||
bool z0 = (r0 & r2) ^ (r1 & (!r3)) ^ (r2 | r4);
|
||||
bool z1 = (r0 | r2) ^ (r5 | r7) ^ r1 ^ r6 ^ x ^ y;
|
||||
bool z2 = (r3 & !r5) ^ (r4 & r6) ^ r7 ^ x;
|
||||
bool z2 = (r3 & (!r5)) ^ (r4 & r6) ^ r7 ^ x;
|
||||
|
||||
// The three bitz z0.. z1 are packed into a uint8_t:
|
||||
// 00000ZZZ
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue