mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-30 03:29:01 -07:00
cppchecker
This commit is contained in:
parent
4ab382065a
commit
72ff81c80f
2 changed files with 22 additions and 33 deletions
|
@ -186,16 +186,13 @@ static lookup_entry lookup_right[0x8000];
|
||||||
static uint8_t left_addition[0x100000];
|
static uint8_t left_addition[0x100000];
|
||||||
|
|
||||||
static inline void init_lookup_left() {
|
static inline void init_lookup_left() {
|
||||||
uint8_t b3, b6, temp;
|
for (int i = 0; i < 0x400; i++) {
|
||||||
int i, index;
|
int b6 = i & 0x1f;
|
||||||
|
int b3 = (i >> 5) & 0x1f;
|
||||||
for (i = 0; i < 0x400; i++) {
|
int index = (b3 << 15) | b6;
|
||||||
b6 = i & 0x1f;
|
|
||||||
b3 = (i >> 5) & 0x1f;
|
|
||||||
index = (b3 << 15) | b6;
|
|
||||||
b6 = bit_rotate_l(b6, 5);
|
b6 = bit_rotate_l(b6, 5);
|
||||||
|
|
||||||
temp = mod(b3 + b6, 0x1f);
|
int temp = mod(b3 + b6, 0x1f);
|
||||||
left_addition[index] = temp;
|
left_addition[index] = temp;
|
||||||
lookup_left[index].addition = temp;
|
lookup_left[index].addition = temp;
|
||||||
lookup_left[index].out = ((temp ^ b3) & 0x0f);
|
lookup_left[index].out = ((temp ^ b3) & 0x0f);
|
||||||
|
@ -203,15 +200,12 @@ static inline void init_lookup_left() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void init_lookup_right() {
|
static inline void init_lookup_right() {
|
||||||
uint8_t b16, b18, temp;
|
for (int i = 0; i < 0x400; i++) {
|
||||||
int i, index;
|
int b18 = i & 0x1f;
|
||||||
|
int b16 = (i >> 5) & 0x1f;
|
||||||
|
int index = (b16 << 10) | b18;
|
||||||
|
|
||||||
for (i = 0; i < 0x400; i++) {
|
int temp = mod(b18 + b16, 0x1f);
|
||||||
b18 = i & 0x1f;
|
|
||||||
b16 = (i >> 5) & 0x1f;
|
|
||||||
index = (b16 << 10) | b18;
|
|
||||||
|
|
||||||
temp = mod(b18 + b16, 0x1f);
|
|
||||||
lookup_right[index].addition = temp;
|
lookup_right[index].addition = temp;
|
||||||
lookup_right[index].out = ((temp ^ b16) & 0x0f);
|
lookup_right[index].out = ((temp ^ b16) & 0x0f);
|
||||||
}
|
}
|
||||||
|
@ -422,7 +416,7 @@ static inline void previous_all_input(vector<cs_t> *pcstates, uint32_t gc_byte_i
|
||||||
uint8_t btGc, in;
|
uint8_t btGc, in;
|
||||||
vector<cs_t> ncstates;
|
vector<cs_t> ncstates;
|
||||||
vector<cs_t> prev_ncstates;
|
vector<cs_t> prev_ncstates;
|
||||||
vector<cs_t>::iterator it, itnew;
|
vector<cs_t>::iterator itnew;
|
||||||
|
|
||||||
// Loop through the complete entryphy of 5 bits for each candidate
|
// Loop through the complete entryphy of 5 bits for each candidate
|
||||||
// We ignore zero (xor 0x00) to avoid duplicates
|
// We ignore zero (xor 0x00) to avoid duplicates
|
||||||
|
@ -707,13 +701,11 @@ void combine_valid_left_right_states(vector<cs_t> *plcstates, vector<cs_t> *prcs
|
||||||
int main(int argc, const char *argv[]) {
|
int main(int argc, const char *argv[]) {
|
||||||
size_t pos;
|
size_t pos;
|
||||||
crypto_state_t ostate;
|
crypto_state_t ostate;
|
||||||
uint64_t rstate_before_gc, rstate_after_gc;
|
uint64_t rstate_before_gc, lstate_before_gc;
|
||||||
uint64_t lstate_before_gc;
|
vector<uint64_t> rstates, pgc_candidates;
|
||||||
vector<uint64_t> rstates, lstates_after_gc, pgc_candidates;
|
|
||||||
vector<uint64_t>::iterator itrstates, itgc;
|
vector<uint64_t>::iterator itrstates, itgc;
|
||||||
vector<cs_t> crstates;
|
vector<cs_t> crstates;
|
||||||
vector<cs_t> clcandidates, clstates;
|
vector<cs_t> clstates;
|
||||||
vector<cs_t>::iterator it;
|
|
||||||
uint32_t rbits;
|
uint32_t rbits;
|
||||||
|
|
||||||
// uint8_t Gc[ 8] = {0x4f,0x79,0x4a,0x46,0x3f,0xf8,0x1d,0x81};
|
// uint8_t Gc[ 8] = {0x4f,0x79,0x4a,0x46,0x3f,0xf8,0x1d,0x81};
|
||||||
|
@ -822,7 +814,7 @@ int main(int argc, const char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (itrstates = rstates.begin(); itrstates != rstates.end(); ++itrstates) {
|
for (itrstates = rstates.begin(); itrstates != rstates.end(); ++itrstates) {
|
||||||
rstate_after_gc = *itrstates;
|
uint64_t rstate_after_gc = *itrstates;
|
||||||
sm_left_mask(ks, mask, rstate_after_gc);
|
sm_left_mask(ks, mask, rstate_after_gc);
|
||||||
printf("Using the state from the top-right bin: " _YELLOW_("0x%07" PRIx64)"\n", rstate_after_gc);
|
printf("Using the state from the top-right bin: " _YELLOW_("0x%07" PRIx64)"\n", rstate_after_gc);
|
||||||
|
|
||||||
|
|
|
@ -660,7 +660,7 @@ static inline void previous_all_input(vector<cs_t> *pcstates, uint32_t gc_byte_i
|
||||||
uint8_t btGc, in;
|
uint8_t btGc, in;
|
||||||
vector<cs_t> ncstates;
|
vector<cs_t> ncstates;
|
||||||
vector<cs_t> prev_ncstates;
|
vector<cs_t> prev_ncstates;
|
||||||
vector<cs_t>::iterator it, itnew;
|
vector<cs_t>::iterator itnew;
|
||||||
|
|
||||||
// Loop through the complete entryphy of 5 bits for each candidate
|
// Loop through the complete entryphy of 5 bits for each candidate
|
||||||
// We ignore zero (xor 0x00) to avoid duplicates
|
// We ignore zero (xor 0x00) to avoid duplicates
|
||||||
|
@ -967,13 +967,10 @@ static void ice_compare(
|
||||||
int main(int argc, const char *argv[]) {
|
int main(int argc, const char *argv[]) {
|
||||||
size_t pos;
|
size_t pos;
|
||||||
crypto_state_t ostate;
|
crypto_state_t ostate;
|
||||||
uint64_t rstate_before_gc, rstate_after_gc;
|
uint64_t rstate_before_gc, lstate_before_gc;
|
||||||
uint64_t lstate_before_gc;
|
vector<uint64_t> rstates, pgc_candidates;
|
||||||
vector<uint64_t> rstates, lstates_after_gc, pgc_candidates;
|
vector<uint64_t>::iterator itrstates;
|
||||||
vector<uint64_t>::iterator itrstates, itgc;
|
vector<cs_t> crstates, clstates;
|
||||||
vector<cs_t> crstates;
|
|
||||||
vector<cs_t> clcandidates, clstates;
|
|
||||||
vector<cs_t>::iterator it;
|
|
||||||
uint32_t rbits;
|
uint32_t rbits;
|
||||||
|
|
||||||
// uint8_t Gc[ 8] = {0x4f,0x79,0x4a,0x46,0x3f,0xf8,0x1d,0x81};
|
// uint8_t Gc[ 8] = {0x4f,0x79,0x4a,0x46,0x3f,0xf8,0x1d,0x81};
|
||||||
|
@ -1081,14 +1078,14 @@ int main(int argc, const char *argv[]) {
|
||||||
rbits = ice_sm_right(ks, mask, &rstates);
|
rbits = ice_sm_right(ks, mask, &rstates);
|
||||||
|
|
||||||
printf("Top-bin for the right state contains " _GREEN_("%u")" correct bits\n", rbits);
|
printf("Top-bin for the right state contains " _GREEN_("%u")" correct bits\n", rbits);
|
||||||
printf("Total count of right bins: " _YELLOW_("%zu") "\n", (unsigned long)rstates.size());
|
printf("Total count of right bins: " _YELLOW_("%zu") "\n", rstates.size());
|
||||||
|
|
||||||
if (rbits < 96) {
|
if (rbits < 96) {
|
||||||
printf(_RED_("\n WARNING!!! Better find another trace, the right top-bin is < 96 bits\n\n"));
|
printf(_RED_("\n WARNING!!! Better find another trace, the right top-bin is < 96 bits\n\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (itrstates = rstates.begin(); itrstates != rstates.end(); ++itrstates) {
|
for (itrstates = rstates.begin(); itrstates != rstates.end(); ++itrstates) {
|
||||||
rstate_after_gc = *itrstates;
|
uint64_t rstate_after_gc = *itrstates;
|
||||||
sm_left_mask(ks, mask, rstate_after_gc);
|
sm_left_mask(ks, mask, rstate_after_gc);
|
||||||
printf("Using the state from the top-right bin: " _YELLOW_("0x%07" PRIx64)"\n", rstate_after_gc);
|
printf("Using the state from the top-right bin: " _YELLOW_("0x%07" PRIx64)"\n", rstate_after_gc);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue