From 49a475899acd1fdba06f04eb3f8c1fe99053615f Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Tue, 21 Feb 2023 04:40:48 +0100 Subject: [PATCH] time is 64b better to accept the same size input timestamps --- tools/mfd_aes_brute/brute_key.c | 5 ++++- tools/mfd_aes_brute/mfd_aes_brute.c | 3 ++- tools/mfd_aes_brute/mfd_multi_brute.c | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/mfd_aes_brute/brute_key.c b/tools/mfd_aes_brute/brute_key.c index 41c91f3c7..654fed6c6 100644 --- a/tools/mfd_aes_brute/brute_key.c +++ b/tools/mfd_aes_brute/brute_key.c @@ -111,7 +111,8 @@ int main(int argc, char *argv[]) { uint8_t tag_challenge[16] = {0x00}; uint8_t lock_challenge[32] = {0x00}; - uint64_t timestamp = atoi(argv[1]); + uint64_t timestamp = 0; + sscanf(argv[1], "%lu", ×tamp); if (argc != 4) { printf("\nusage: %s <16 byte tag challenge> <32 byte lock challenge>\n\n", argv[0]); @@ -124,8 +125,10 @@ int main(int argc, char *argv[]) { if (hexstr_to_byte_array(argv[3], lock_challenge, sizeof(lock_challenge))) return 3; + // current time uint64_t start_time = time(NULL); + // from a time before up until current time. for (; timestamp < start_time; timestamp++) { make_key(timestamp, key); diff --git a/tools/mfd_aes_brute/mfd_aes_brute.c b/tools/mfd_aes_brute/mfd_aes_brute.c index d4bca2bb8..4eba06051 100644 --- a/tools/mfd_aes_brute/mfd_aes_brute.c +++ b/tools/mfd_aes_brute/mfd_aes_brute.c @@ -233,7 +233,8 @@ int main(int argc, char *argv[]) { if (argc != 4) return usage(argv[0]); - uint64_t start_time = atoi(argv[1]); + uint64_t start_time = 0; + sscanf(argv[1], "%lu", &start_time); uint8_t tag_challenge[16] = {0x00}; if (hexstr_to_byte_array(argv[2], tag_challenge, sizeof(tag_challenge))) diff --git a/tools/mfd_aes_brute/mfd_multi_brute.c b/tools/mfd_aes_brute/mfd_multi_brute.c index 704796255..bbd213a35 100644 --- a/tools/mfd_aes_brute/mfd_multi_brute.c +++ b/tools/mfd_aes_brute/mfd_multi_brute.c @@ -172,7 +172,7 @@ static void print_time(uint64_t at) { char res[32]; strftime(res, sizeof(res), "%Y-%m-%d %H:%M:%S", <); - printf("%u ( '%s' )\n", (unsigned)t, res); + printf("%"PRIu64" ( '%s' )\n", t, res); } static void *brute_thread(void *arguments) { @@ -378,7 +378,8 @@ int main(int argc, char *argv[]) { return 1; } - uint64_t start_time = atoi(argv[3]); + uint64_t start_time = 0; + sscanf(argv[3], "%lu", &start_time); printf("Crypto algo............ " _GREEN_("%s") "\n", algostr); printf("LCR Random generator... " _GREEN_("%s") "\n", generators[g_idx].Name);