diff --git a/tools/hitag2crack/crack3/ht2crack3.c b/tools/hitag2crack/crack3/ht2crack3.c index 555c6d82a..917747820 100644 --- a/tools/hitag2crack/crack3/ht2crack3.c +++ b/tools/hitag2crack/crack3/ht2crack3.c @@ -325,7 +325,7 @@ int main(int argc, char *argv[]) { // set klowerstart (for debugging) if (argc > 3) { - klowerstart = strtol(argv[3], NULL, 0); + klowerstart = strtoull(argv[3], NULL, 0); } else { klowerstart = 0; } diff --git a/tools/hitag2crack/crack3/ht2crack3test.c b/tools/hitag2crack/crack3/ht2crack3test.c index ebf7b481d..17a1904e2 100644 --- a/tools/hitag2crack/crack3/ht2crack3test.c +++ b/tools/hitag2crack/crack3/ht2crack3test.c @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) { } hitag2_init(&hstate, rev64(hexreversetouint64(key)), rev32(hexreversetouint32(uid)), rev32(hexreversetouint32(nr))); - arval = strtol(ar, NULL, 16); + arval = strtoul(ar, NULL, 16); ks = hitag2_nstep(&hstate, 32); diff --git a/tools/hitag2crack/crack4/ht2crack4.c b/tools/hitag2crack/crack4/ht2crack4.c index 83d2c92e7..eabb15227 100644 --- a/tools/hitag2crack/crack4/ht2crack4.c +++ b/tools/hitag2crack/crack4/ht2crack4.c @@ -325,7 +325,7 @@ static double bit_score(uint64_t s, uint64_t size, uint64_t b) { // chop away any bits beyond size - chopped = s & ((1l << size) - 1); + chopped = s & ((UINT64_C(1) << size) - 1); // and pack the remaining bits packed = packstate(chopped); @@ -514,7 +514,7 @@ static void score_all_traces(unsigned int size) { // start the threads for (i = 0; i < NUM_THREADS; i++) { - if (pthread_create(&(threads[i]), NULL, score_some_traces, (void *)(tdata + i))) { + if (pthread_create(&(threads[i]), NULL, score_some_traces, (void *)(uintptr_t)(tdata + i))) { printf("cannot start thread %u\n", i); exit(1); } @@ -555,7 +555,7 @@ static void expand_guesses(unsigned int halfsize, unsigned int size) { unsigned int i, j; for (i = 0; i < halfsize; i++) { - guesses[i + halfsize].key = guesses[i].key | (1l << size); + guesses[i + halfsize].key = guesses[i].key | (UINT64_C(1) << size); guesses[i + halfsize].score = guesses[i].score; for (j = 0; j < num_nRaR; j++) { guesses[i + halfsize].b0to31[j] = guesses[i].b0to31[j]; @@ -570,7 +570,7 @@ static void check_supplied_testkey(unsigned int size) { uint64_t partkey; unsigned int i; - partkey = supplied_testkey & ((1l << size) - 1); + partkey = supplied_testkey & ((UINT64_C(1) << size) - 1); for (i = 0; i < num_guesses; i++) { if (guesses[i].key == partkey) { @@ -620,7 +620,12 @@ static void crack(void) { // print some metrics uint64_t revkey = rev64(guesses[0].key); - uint64_t foundkey = ((revkey >> 40) & 0xff) | ((revkey >> 24) & 0xff00) | ((revkey >> 8) & 0xff0000) | ((revkey << 8) & 0xff000000) | ((revkey << 24) & 0xff00000000) | ((revkey << 40) & 0xff0000000000); + uint64_t foundkey = ((revkey >> 40) & UINT64_C(0xff)) | + ((revkey >> 24) & UINT64_C(0xff00)) | + ((revkey >> 8) & UINT64_C(0xff0000)) | + ((revkey << 8) & UINT64_C(0xff000000)) | + ((revkey << 24) & UINT64_C(0xff00000000)) | + ((revkey << 40) & UINT64_C(0xff0000000000)); fprintf(stderr, " guess=%012" PRIx64 ", num_guesses = %u, top score=%1.10f, min score=%1.10f\n", foundkey, num_guesses, guesses[0].score, guesses[num_guesses - 1].score); } } @@ -828,7 +833,12 @@ int main(int argc, char *argv[]) { check_key(guesses[i].key, nonces[1].enc_nR, nonces[1].ks)) { printf("WIN!!! :)\n"); revkey = rev64(guesses[i].key); - foundkey = ((revkey >> 40) & 0xff) | ((revkey >> 24) & 0xff00) | ((revkey >> 8) & 0xff0000) | ((revkey << 8) & 0xff000000) | ((revkey << 24) & 0xff00000000) | ((revkey << 40) & 0xff0000000000); + foundkey = ((revkey >> 40) & UINT64_C(0xff)) | + ((revkey >> 24) & UINT64_C(0xff00)) | + ((revkey >> 8) & UINT64_C(0xff0000)) | + ((revkey << 8) & UINT64_C(0xff000000)) | + ((revkey << 24) & UINT64_C(0xff00000000)) | + ((revkey << 40) & UINT64_C(0xff0000000000)); printf("key = %012" PRIX64 "\n", foundkey); exit(0); } diff --git a/tools/hitag2crack/crack5/ht2crack5.c b/tools/hitag2crack/crack5/ht2crack5.c index adec84ef2..39c59ac82 100644 --- a/tools/hitag2crack/crack5/ht2crack5.c +++ b/tools/hitag2crack/crack5/ht2crack5.c @@ -149,7 +149,7 @@ int main(int argc, char *argv[]) { nR1 = rev32(hexreversetouint32(argv[2])); } - aR1 = strtol(argv[3], NULL, 16); + aR1 = strtoul(argv[3], NULL, 16); if (!strncmp(argv[4], "0x", 2) || !strncmp(argv[4], "0X", 2)) { nR2 = rev32(hexreversetouint32(argv[4] + 2)); @@ -157,7 +157,7 @@ int main(int argc, char *argv[]) { nR2 = rev32(hexreversetouint32(argv[4])); } - aR2 = strtol(argv[5], NULL, 16); + aR2 = strtoul(argv[5], NULL, 16); target = ~aR1; // bitslice inverse target bits diff --git a/tools/hitag2crack/crack5gpu_disabled/ht2crack5gpu.c b/tools/hitag2crack/crack5gpu_disabled/ht2crack5gpu.c index e038e055e..fa80cd2c3 100644 --- a/tools/hitag2crack/crack5gpu_disabled/ht2crack5gpu.c +++ b/tools/hitag2crack/crack5gpu_disabled/ht2crack5gpu.c @@ -201,7 +201,7 @@ int main(int argc, char *argv[]) { nR1 = rev32(hexreversetouint32(argv[2])); } - aR1 = strtol(argv[3], NULL, 16); + aR1 = strtoul(argv[3], NULL, 16); if (!strncmp(argv[4], "0x", 2) || !strncmp(argv[4], "0X", 2)) { nR2 = rev32(hexreversetouint32(argv[4] + 2)); @@ -209,7 +209,7 @@ int main(int argc, char *argv[]) { nR2 = rev32(hexreversetouint32(argv[4])); } - aR2 = strtol(argv[5], NULL, 16); + aR2 = strtoul(argv[5], NULL, 16); target = ~aR1; // bitslice inverse target bits