mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
make style
This commit is contained in:
parent
7bc3067fa4
commit
8d4acbe3a6
13 changed files with 78 additions and 79 deletions
|
@ -158,13 +158,13 @@ static void download_instructions(uint8_t t) {
|
|||
|
||||
// Save to flash if file doesn't exist.
|
||||
// Write over file if size of flash file is less than new datalen
|
||||
static void save_to_flash(uint8_t *data, uint16_t datalen, char * filename) {
|
||||
static void save_to_flash(uint8_t *data, uint16_t datalen, char *filename) {
|
||||
|
||||
rdv40_spiffs_lazy_mount();
|
||||
|
||||
char fn[SPIFFS_OBJ_NAME_LEN];
|
||||
|
||||
if (filename == NULL){
|
||||
if (filename == NULL) {
|
||||
sprintf(fn, "iclass-%02X%02X%02X%02X%02X%02X%02X%02X.bin",
|
||||
data[0], data[1], data[2], data[3],
|
||||
data[4], data[5], data[6], data[7]
|
||||
|
@ -558,7 +558,7 @@ static int dump_sim_mode(void) {
|
|||
}
|
||||
}
|
||||
switch_off();
|
||||
char * temp_file = HF_ICALSSS_READSIM_TEMP_BIN;
|
||||
char *temp_file = HF_ICALSSS_READSIM_TEMP_BIN;
|
||||
save_to_flash(card_data, (start_block + dumped) * 8, temp_file);
|
||||
Dbprintf("%u bytes saved", (start_block + dumped) * 8);
|
||||
|
||||
|
|
|
@ -190,9 +190,9 @@ static uint32_t get_rising_pulse_length(void) {
|
|||
|
||||
static uint32_t get_pulse_length(edge_detection_t edge) {
|
||||
|
||||
if(edge == RISING_EDGE)
|
||||
if (edge == RISING_EDGE)
|
||||
return get_rising_pulse_length();
|
||||
else if(edge == FALLING_EDGE)
|
||||
else if (edge == FALLING_EDGE)
|
||||
return get_falling_pulse_length();
|
||||
|
||||
return 0;
|
||||
|
@ -426,10 +426,10 @@ static bool find_listen_window(bool command) {
|
|||
96 ( 64 + 32 )
|
||||
64 ( 32 + 16 +16 )*/
|
||||
|
||||
if (check_pulse_length(get_pulse_length(RISING_EDGE), (2*EM4X70_T_TAG_FULL_PERIOD) + EM4X70_T_TAG_HALF_PERIOD) &&
|
||||
check_pulse_length(get_pulse_length(RISING_EDGE), (2*EM4X70_T_TAG_FULL_PERIOD) + EM4X70_T_TAG_HALF_PERIOD) &&
|
||||
check_pulse_length(get_pulse_length(FALLING_EDGE), (2*EM4X70_T_TAG_FULL_PERIOD) + EM4X70_T_TAG_FULL_PERIOD) &&
|
||||
check_pulse_length(get_pulse_length(FALLING_EDGE), EM4X70_T_TAG_FULL_PERIOD + (2*EM4X70_T_TAG_HALF_PERIOD))) {
|
||||
if (check_pulse_length(get_pulse_length(RISING_EDGE), (2 * EM4X70_T_TAG_FULL_PERIOD) + EM4X70_T_TAG_HALF_PERIOD) &&
|
||||
check_pulse_length(get_pulse_length(RISING_EDGE), (2 * EM4X70_T_TAG_FULL_PERIOD) + EM4X70_T_TAG_HALF_PERIOD) &&
|
||||
check_pulse_length(get_pulse_length(FALLING_EDGE), (2 * EM4X70_T_TAG_FULL_PERIOD) + EM4X70_T_TAG_FULL_PERIOD) &&
|
||||
check_pulse_length(get_pulse_length(FALLING_EDGE), EM4X70_T_TAG_FULL_PERIOD + (2 * EM4X70_T_TAG_HALF_PERIOD))) {
|
||||
|
||||
if (command) {
|
||||
/* Here we are after the 64 duration edge.
|
||||
|
@ -438,7 +438,7 @@ static bool find_listen_window(bool command) {
|
|||
*
|
||||
* I've found between 4-5 quarter periods (32-40) works best
|
||||
*/
|
||||
WaitTicks( 4 * EM4X70_T_TAG_QUARTER_PERIOD );
|
||||
WaitTicks(4 * EM4X70_T_TAG_QUARTER_PERIOD);
|
||||
// Send RM Command
|
||||
em4x70_send_bit(0);
|
||||
em4x70_send_bit(0);
|
||||
|
@ -559,7 +559,7 @@ static int em4x70_receive(uint8_t *bits, size_t length) {
|
|||
WaitTicks(6 * EM4X70_T_TAG_FULL_PERIOD);
|
||||
|
||||
// wait until we get the transition from 1's to 0's which is 1.5 full windows
|
||||
for(int i = 0; i < EM4X70_T_READ_HEADER_LEN; i++) {
|
||||
for (int i = 0; i < EM4X70_T_READ_HEADER_LEN; i++) {
|
||||
pl = get_pulse_length(edge);
|
||||
if (check_pulse_length(pl, 3 * EM4X70_T_TAG_HALF_PERIOD)) {
|
||||
foundheader = true;
|
||||
|
@ -575,7 +575,7 @@ static int em4x70_receive(uint8_t *bits, size_t length) {
|
|||
// Skip next 3 0's, header check consumes the first 0
|
||||
for (int i = 0; i < 3; i++) {
|
||||
// If pulse length is not 1 bit, then abort early
|
||||
if(!check_pulse_length(get_pulse_length(edge), EM4X70_T_TAG_FULL_PERIOD)) {
|
||||
if (!check_pulse_length(get_pulse_length(edge), EM4X70_T_TAG_FULL_PERIOD)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -745,7 +745,7 @@ void em4x70_write_pin(em4x70_data_t *etd) {
|
|||
if (em4x70_read_id()) {
|
||||
|
||||
// Write new PIN
|
||||
if( (write( etd->pin & 0xFFFF, EM4X70_PIN_WORD_UPPER) == PM3_SUCCESS) &&
|
||||
if ((write(etd->pin & 0xFFFF, EM4X70_PIN_WORD_UPPER) == PM3_SUCCESS) &&
|
||||
(write((etd->pin >> 16) & 0xFFFF, EM4X70_PIN_WORD_LOWER) == PM3_SUCCESS)) {
|
||||
|
||||
// Now Try to authenticate using the new PIN
|
||||
|
@ -786,11 +786,11 @@ void em4x70_write_key(em4x70_data_t *etd) {
|
|||
status = 1;
|
||||
|
||||
// Write each crypto block
|
||||
for(int i = 0; i < 6; i++) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
|
||||
uint16_t key_word = (etd->crypt_key[(i*2)+1] << 8) + etd->crypt_key[i*2];
|
||||
uint16_t key_word = (etd->crypt_key[(i * 2) + 1] << 8) + etd->crypt_key[i * 2];
|
||||
// Write each word, abort if any failure occurs
|
||||
if (write(key_word, 9-i) != PM3_SUCCESS) {
|
||||
if (write(key_word, 9 - i) != PM3_SUCCESS) {
|
||||
status = 0;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ typedef struct {
|
|||
typedef enum {
|
||||
RISING_EDGE,
|
||||
FALLING_EDGE
|
||||
}edge_detection_t;
|
||||
} edge_detection_t;
|
||||
|
||||
void em4x70_info(em4x70_data_t *etd);
|
||||
void em4x70_write(em4x70_data_t *etd);
|
||||
|
|
|
@ -244,7 +244,7 @@ int CmdHFTune(const char *Cmd) {
|
|||
max = (volt * 1.03);
|
||||
first = false;
|
||||
}
|
||||
if ( volt > max) {
|
||||
if (volt > max) {
|
||||
max = (volt * 1.03);
|
||||
}
|
||||
print_progress(volt, max, style);
|
||||
|
|
|
@ -61,7 +61,7 @@ static int emrtd_print_ef_dg12_info(uint8_t *data, size_t datalen);
|
|||
static int emrtd_print_ef_sod_info(uint8_t *data, size_t datalen);
|
||||
|
||||
typedef enum { // list must match dg_table
|
||||
EF_COM=0,
|
||||
EF_COM = 0,
|
||||
EF_DG1,
|
||||
EF_DG2,
|
||||
EF_DG3,
|
||||
|
@ -109,7 +109,7 @@ static emrtd_dg_t dg_table[] = {
|
|||
};
|
||||
|
||||
static emrtd_dg_t *emrtd_tag_to_dg(uint8_t tag) {
|
||||
for (int dgi=0; dg_table[dgi].filename != NULL; dgi++) {
|
||||
for (int dgi = 0; dg_table[dgi].filename != NULL; dgi++) {
|
||||
if (dg_table[dgi].tag == tag) {
|
||||
return &dg_table[dgi];
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ static emrtd_dg_t *emrtd_tag_to_dg(uint8_t tag) {
|
|||
return NULL;
|
||||
}
|
||||
static emrtd_dg_t *emrtd_fileid_to_dg(const char *file_id) {
|
||||
for (int dgi=0; dg_table[dgi].filename != NULL; dgi++) {
|
||||
for (int dgi = 0; dg_table[dgi].filename != NULL; dgi++) {
|
||||
if (strcmp(dg_table[dgi].fileid, file_id) == 0) {
|
||||
return &dg_table[dgi];
|
||||
}
|
||||
|
@ -766,7 +766,7 @@ static bool emrtd_dump_file(uint8_t *ks_enc, uint8_t *ks_mac, uint8_t *ssc, cons
|
|||
PrintAndLogEx(INFO, "Read %s, len: %i.", name, resplen);
|
||||
PrintAndLogEx(DEBUG, "Contents (may be incomplete over 2k chars): %s", sprint_hex_inrow(response, resplen));
|
||||
saveFile(name, ".BIN", response, resplen);
|
||||
emrtd_dg_t * dg = emrtd_fileid_to_dg(file);
|
||||
emrtd_dg_t *dg = emrtd_fileid_to_dg(file);
|
||||
if ((dg != NULL) && (dg->dumper != NULL)) {
|
||||
dg->dumper(response, resplen);
|
||||
}
|
||||
|
@ -1006,7 +1006,7 @@ int dumpHF_EMRTD(char *documentnumber, char *dob, char *expiry, bool BAC_availab
|
|||
filelist[filelistlen++] = 0x77;
|
||||
// Dump all files in the file list
|
||||
for (int i = 0; i < filelistlen; i++) {
|
||||
emrtd_dg_t * dg = emrtd_tag_to_dg(filelist[i]);
|
||||
emrtd_dg_t *dg = emrtd_tag_to_dg(filelist[i]);
|
||||
if (dg == NULL) {
|
||||
PrintAndLogEx(INFO, "File tag not found, skipping: %02X", filelist[i]);
|
||||
continue;
|
||||
|
@ -1231,7 +1231,7 @@ static int emrtd_print_ef_com_info(uint8_t *data, size_t datalen) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "-------------------- " _CYAN_("EF_COM") " --------------------");
|
||||
for (int i = 0; i < filelistlen; i++) {
|
||||
emrtd_dg_t * dg = emrtd_tag_to_dg(filelist[i]);
|
||||
emrtd_dg_t *dg = emrtd_tag_to_dg(filelist[i]);
|
||||
if (dg == NULL) {
|
||||
PrintAndLogEx(INFO, "File tag not found, skipping: %02X", filelist[i]);
|
||||
continue;
|
||||
|
@ -1513,7 +1513,7 @@ int infoHF_EMRTD(char *documentnumber, char *dob, char *expiry, bool BAC_availab
|
|||
}
|
||||
|
||||
int res = emrtd_print_ef_com_info(response, resplen);
|
||||
if ( res != PM3_SUCCESS) {
|
||||
if (res != PM3_SUCCESS) {
|
||||
DropField();
|
||||
return res;
|
||||
}
|
||||
|
@ -1530,7 +1530,7 @@ int infoHF_EMRTD(char *documentnumber, char *dob, char *expiry, bool BAC_availab
|
|||
filelist[filelistlen++] = 0x77;
|
||||
// Dump all files in the file list
|
||||
for (int i = 0; i < filelistlen; i++) {
|
||||
emrtd_dg_t * dg = emrtd_tag_to_dg(filelist[i]);
|
||||
emrtd_dg_t *dg = emrtd_tag_to_dg(filelist[i]);
|
||||
if (dg == NULL) {
|
||||
PrintAndLogEx(INFO, "File tag not found, skipping: %02X", filelist[i]);
|
||||
continue;
|
||||
|
@ -1563,7 +1563,7 @@ int infoHF_EMRTD_offline(const char *path) {
|
|||
}
|
||||
|
||||
int res = emrtd_print_ef_com_info(data, datalen);
|
||||
if ( res != PM3_SUCCESS) {
|
||||
if (res != PM3_SUCCESS) {
|
||||
free(data);
|
||||
free(filepath);
|
||||
return res;
|
||||
|
@ -1583,7 +1583,7 @@ int infoHF_EMRTD_offline(const char *path) {
|
|||
filelist[filelistlen++] = 0x77;
|
||||
// Read files in the file list
|
||||
for (int i = 0; i < filelistlen; i++) {
|
||||
emrtd_dg_t * dg = emrtd_tag_to_dg(filelist[i]);
|
||||
emrtd_dg_t *dg = emrtd_tag_to_dg(filelist[i]);
|
||||
if (dg == NULL) {
|
||||
PrintAndLogEx(INFO, "File tag not found, skipping: %02X", filelist[i]);
|
||||
continue;
|
||||
|
@ -1592,8 +1592,7 @@ int infoHF_EMRTD_offline(const char *path) {
|
|||
strcpy(filepath, path);
|
||||
strncat(filepath, PATHSEP, 2);
|
||||
strcat(filepath, dg->filename);
|
||||
if (loadFile_safeEx(filepath, ".BIN", (void **)&data, (size_t *)&datalen, false) == PM3_SUCCESS)
|
||||
{
|
||||
if (loadFile_safeEx(filepath, ".BIN", (void **)&data, (size_t *)&datalen, false) == PM3_SUCCESS) {
|
||||
// we won't halt on parsing errors
|
||||
if (dg->parser != NULL)
|
||||
dg->parser(data, datalen);
|
||||
|
|
|
@ -331,7 +331,7 @@ static int CmdLFTune(const char *Cmd) {
|
|||
max = (volt * 1.03);
|
||||
first = false;
|
||||
}
|
||||
if ( volt > max) {
|
||||
if (volt > max) {
|
||||
max = (volt * 1.03);
|
||||
}
|
||||
print_progress(volt, max, style);
|
||||
|
|
|
@ -175,7 +175,7 @@ int CmdRem(const char *Cmd) {
|
|||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
|
||||
struct arg_str* foo = arg_get_str(ctx, 1);
|
||||
struct arg_str *foo = arg_get_str(ctx, 1);
|
||||
size_t count = 0;
|
||||
size_t len = 0;
|
||||
do {
|
||||
|
|
|
@ -632,7 +632,7 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
|||
static int prev_cols = 0;
|
||||
int rows;
|
||||
rl_reset_screen_size(); // refresh Readline idea of the actual screen width
|
||||
rl_get_screen_size (&rows, &cols);
|
||||
rl_get_screen_size(&rows, &cols);
|
||||
(void) rows;
|
||||
if (prev_cols > cols) {
|
||||
PrintAndLogEx(NORMAL, _CLEAR_ _TOP_ "");
|
||||
|
@ -640,9 +640,9 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
|||
prev_cols = cols;
|
||||
#endif
|
||||
int width = cols - 35;
|
||||
#define PERCENTAGE(V, T) ((V * width) / T)
|
||||
#define PERCENTAGE(V, T) ((V * width) / T)
|
||||
// x/8 fractional part of the percentage
|
||||
#define PERCENTAGEFRAC(V, T) ((int)(((((float)V * width) / T) - ((V * width) / T)) * 8))
|
||||
#define PERCENTAGEFRAC(V, T) ((int)(((((float)V * width) / T) - ((V * width) / T)) * 8))
|
||||
|
||||
const char *smoothtable[] = {
|
||||
"\xe2\x80\x80",
|
||||
|
@ -662,13 +662,13 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
|||
const char *space[] = {" ", "\xe2\x80\x80"};
|
||||
uint8_t unit = strlen(block[mode]);
|
||||
// +1 for \0
|
||||
char *bar = calloc(unit*width + 1, sizeof(uint8_t));
|
||||
char *bar = calloc(unit * width + 1, sizeof(uint8_t));
|
||||
|
||||
uint8_t value = PERCENTAGE(count, max);
|
||||
|
||||
int i = 0;
|
||||
// prefix is added already.
|
||||
for (; i < unit*value; i+=unit) {
|
||||
for (; i < unit * value; i += unit) {
|
||||
memcpy(bar + i, block[mode], unit);
|
||||
}
|
||||
// add last block
|
||||
|
@ -679,7 +679,7 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
|||
}
|
||||
i += unit;
|
||||
// add spaces
|
||||
for (; i < unit*width; i+=unit) {
|
||||
for (; i < unit * width; i += unit) {
|
||||
memcpy(bar + i, space[mode], unit);
|
||||
}
|
||||
// color buffer
|
||||
|
@ -687,16 +687,16 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
|||
char *cbar = calloc(collen, sizeof(uint8_t));
|
||||
|
||||
// Add colors
|
||||
int p60 = unit*(width*60/100);
|
||||
int p20 = unit*(width*20/100);
|
||||
int p60 = unit * (width * 60 / 100);
|
||||
int p20 = unit * (width * 20 / 100);
|
||||
snprintf(cbar, collen, _GREEN_("%.*s"), p60, bar);
|
||||
snprintf(cbar + strlen(cbar), collen - strlen(cbar), _CYAN_("%.*s"), p20, bar + p60);
|
||||
snprintf(cbar + strlen(cbar), collen - strlen(cbar), _YELLOW_("%.*s"), unit*width - p60 - p20, bar + p60 + p20);
|
||||
snprintf(cbar + strlen(cbar), collen - strlen(cbar), _YELLOW_("%.*s"), unit * width - p60 - p20, bar + p60 + p20);
|
||||
|
||||
size_t len = strlen(cbar) + 32;
|
||||
char *buffer = calloc(len, sizeof(uint8_t));
|
||||
|
||||
switch(style) {
|
||||
switch (style) {
|
||||
case STYLE_BAR: {
|
||||
sprintf(buffer, "%s", cbar);
|
||||
printf("\b%c[2K\r[" _YELLOW_("=")"] %s", 27, buffer);
|
||||
|
|
|
@ -198,8 +198,8 @@ Check column "offline" for their availability.
|
|||
|command |offline |description
|
||||
|------- |------- |-----------
|
||||
|`hf epa help `|Y |`This help`
|
||||
|`hf epa cnonces `|N |`Acquire encrypted PACE nonces of specific size`
|
||||
|`hf epa preplay `|N |`Perform PACE protocol by replaying given APDUs`
|
||||
|`hf epa cnonces `|N |`<m> <n> <d> Acquire n>0 encrypted PACE nonces of size m>0 with d sec pauses`
|
||||
|`hf epa preplay `|N |`<mse> <get> <map> <pka> <ma> Perform PACE protocol by replaying given APDUs`
|
||||
|
||||
|
||||
### hf emrtd
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue