make style

This commit is contained in:
merlokk 2022-02-05 13:32:50 +02:00
commit 3ae9070dd8
15 changed files with 126 additions and 121 deletions

View file

@ -63,19 +63,19 @@ static int decrypt(uint8_t ciphertext[], int ciphertext_len, uint8_t key[], uint
int len;
int plaintext_len;
if(!(ctx = EVP_CIPHER_CTX_new()))
if (!(ctx = EVP_CIPHER_CTX_new()))
handleErrors();
if(1 != EVP_DecryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, key, iv))
if (1 != EVP_DecryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, key, iv))
handleErrors();
EVP_CIPHER_CTX_set_padding(ctx, 0);
if(1 != EVP_DecryptUpdate(ctx, plaintext, &len, ciphertext, ciphertext_len))
if (1 != EVP_DecryptUpdate(ctx, plaintext, &len, ciphertext, ciphertext_len))
handleErrors();
plaintext_len = len;
if(1 != EVP_DecryptFinal_ex(ctx, plaintext + len, &len))
if (1 != EVP_DecryptFinal_ex(ctx, plaintext + len, &len))
handleErrors();
plaintext_len += len;
@ -89,7 +89,7 @@ static int hexstr_to_byte_array(char hexstr[], uint8_t bytes[], size_t byte_len)
if (hexstr_len % 16) {
return 1;
}
if (byte_len < hexstr_len/2) {
if (byte_len < hexstr_len / 2) {
return 2;
}
char *pos = &hexstr[0];
@ -100,7 +100,7 @@ static int hexstr_to_byte_array(char hexstr[], uint8_t bytes[], size_t byte_len)
return 0;
}
int main (int argc, char* argv[]) {
int main(int argc, char *argv[]) {
uint8_t iv[16] = {0x00};
uint8_t key[16] = {0x00};
@ -116,10 +116,10 @@ int main (int argc, char* argv[]) {
return 1;
}
if(hexstr_to_byte_array(argv[2], tag_challenge, sizeof(tag_challenge)))
if (hexstr_to_byte_array(argv[2], tag_challenge, sizeof(tag_challenge)))
return 2;
if(hexstr_to_byte_array(argv[3], lock_challenge, sizeof(lock_challenge)))
if (hexstr_to_byte_array(argv[3], lock_challenge, sizeof(lock_challenge)))
return 3;
uint64_t start_time = time(NULL);

View file

@ -19,7 +19,7 @@
#define __STDC_FORMAT_MACROS
#if !defined(_WIN32) && !defined(__APPLE__)
#define _POSIX_C_SOURCE 200112L // need localtime_r()
#define _POSIX_C_SOURCE 200112L // need localtime_r()
#endif
#include <stdio.h>
@ -53,7 +53,7 @@ typedef struct thread_args {
uint64_t starttime;
uint64_t stoptime;
uint8_t tag[16];
uint8_t rdr[32];
uint8_t rdr[32];
} targs;
static void make_key(uint32_t seed, uint8_t key[]) {
@ -134,9 +134,9 @@ static void print_time(uint64_t at) {
struct tm lt;
#if defined(_WIN32)
(void)localtime_s(&lt, &t);
(void)localtime_s(&lt, &t);
#else
(void)localtime_r(&t, &lt);
(void)localtime_r(&t, &lt);
#endif
char res[32];
@ -151,9 +151,9 @@ static void *brute_thread(void *arguments) {
uint64_t starttime = args->starttime;
uint64_t stoptime = args->stoptime;
uint64_t stoptime = args->stoptime;
uint8_t local_tag[16];
uint8_t local_rdr[32];
uint8_t local_rdr[32];
memcpy(local_tag, args->tag, 16);
memcpy(local_rdr, args->rdr, 32);
@ -213,7 +213,7 @@ static void *brute_thread(void *arguments) {
return NULL;
}
static int usage(const char* s) {
static int usage(const char *s) {
printf(_YELLOW_("syntax:") "\n");
printf(" %s <unix timestamp> <16 byte tag challenge> <32 byte reader response challenge>\n", s);
printf("\n");
@ -223,7 +223,7 @@ static int usage(const char* s) {
return 1;
}
int main (int argc, char* argv[]) {
int main(int argc, char *argv[]) {
printf("\n");
printf(_CYAN_("Telenot access MIFARE DESFire AES key recovery tool") "\n");
@ -252,7 +252,7 @@ int main (int argc, char* argv[]) {
printf("Rdr Resp & Challenge... ");
print_hex(rdr_resp_challenge, sizeof(rdr_resp_challenge));
uint64_t t1 = msclock();
#if !defined(_WIN32) || !defined(__WIN32__)
@ -269,7 +269,7 @@ int main (int argc, char* argv[]) {
pthread_mutex_init(&print_lock, NULL);
// threads
uint64_t stop_time = time(NULL);
uint64_t stop_time = time(NULL);
for (int i = 0; i < thread_count; ++i) {
struct thread_args *a = calloc(1, sizeof(struct thread_args));
a->thread = i;