Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
iceman1001 committed Dec 31, 2024
1 parent 7843de1 commit 17338e2
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 134 deletions.
4 changes: 2 additions & 2 deletions armsrc/lfops.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ void setT55xxConfig(uint8_t arg0, const t55xx_configurations_t *c) {
return;
}

if (SPIFFS_OK == rdv40_spiffs_write(T55XX_CONFIG_FILE, (uint8_t*)&T55xx_Timing, T55XX_CONFIG_LEN, RDV40_SPIFFS_SAFETY_SAFE)) {
if (SPIFFS_OK == rdv40_spiffs_write(T55XX_CONFIG_FILE, (uint8_t *)&T55xx_Timing, T55XX_CONFIG_LEN, RDV40_SPIFFS_SAFETY_SAFE)) {
DbpString("T55XX Config save " _GREEN_("success"));
}

Expand Down Expand Up @@ -2133,7 +2133,7 @@ void T55xx_ChkPwds(uint8_t flags, bool ledcontrol) {

BigBuf_Clear_EM();
uint32_t size = 0;

if (exists_in_spiffs(T55XX_KEYS_FILE)) {
size = size_in_spiffs(T55XX_KEYS_FILE);
}
Expand Down
6 changes: 3 additions & 3 deletions client/src/cmdhf15.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,10 +907,10 @@ static int StCheckSig(uint8_t *uid) {
// add UID (scan, uid)
memcpy(packet->raw + packet->rawlen, uid, HF15_UID_LENGTH);
packet->rawlen += HF15_UID_LENGTH;
packet->flags = (ISO15_CONNECT| ISO15_READ_RESPONSE | ISO15_NO_DISCONNECT);
packet->flags = (ISO15_CONNECT | ISO15_READ_RESPONSE | ISO15_NO_DISCONNECT);
uint16_t blkoff = packet->rawlen;
char signature_hex[65] = {0};
for (int j=0; j<17; j++) {
for (int j = 0; j < 17; j++) {
packet->rawlen = blkoff;
// block no
packet->raw[packet->rawlen++] = 0x3F + j;
Expand All @@ -929,7 +929,7 @@ static int StCheckSig(uint8_t *uid) {
ISO15_ERROR_HANDLING_RESPONSE
uint8_t *d = resp.data.asBytes;
ISO15_ERROR_HANDLING_CARD_RESPONSE(d, resp.length)
if (j==0) {
if (j == 0) {
if (memcmp(d + 1, "K04S", 4) != 0) {
// No signature
free(packet);
Expand Down
38 changes: 19 additions & 19 deletions client/src/cmdhficlass.c
Original file line number Diff line number Diff line change
Expand Up @@ -3015,12 +3015,12 @@ static int CmdHFiClass_TearBlock(const char *Cmd) {
int tearoff_start = arg_get_int_def(ctx, 12, 100);
int tearoff_end = arg_get_int_def(ctx, 13, 200);

if(tearoff_end <= tearoff_start){
if (tearoff_end <= tearoff_start) {
PrintAndLogEx(ERR, "Tearoff end delay must be bigger than the start delay.");
return PM3_EINVARG;
}

if(tearoff_start < 0 || tearoff_end <= 0){
if (tearoff_start < 0 || tearoff_end <= 0) {
PrintAndLogEx(ERR, "Tearoff start/end delays should be bigger than 0.");
return PM3_EINVARG;
}
Expand All @@ -3041,22 +3041,22 @@ static int CmdHFiClass_TearBlock(const char *Cmd) {
int isok = 0;
tearoff_params_t params;
bool read_ok = false;
while(tearoff_start < tearoff_end && !read_ok){
while (tearoff_start < tearoff_end && !read_ok) {
//perform read here, repeat if failed or 00s

uint8_t data_read_orig[8] = {0};
bool first_read = false;
bool reread = false;
while(!first_read){
while (!first_read) {
int res_orig = iclass_read_block_ex(key, blockno, 0x88, elite, rawkey, use_replay, verbose, auth, shallow_mod, data_read_orig, false);
if (res_orig == PM3_SUCCESS && !reread){
if (memcmp(data_read_orig, zeros, 8) == 0){
if (res_orig == PM3_SUCCESS && !reread) {
if (memcmp(data_read_orig, zeros, 8) == 0) {
reread = true;
}else{
} else {
first_read = true;
reread = false;
}
} else if (res_orig == PM3_SUCCESS && reread){
} else if (res_orig == PM3_SUCCESS && reread) {
first_read = true;
reread = false;
}
Expand All @@ -3082,36 +3082,36 @@ static int CmdHFiClass_TearBlock(const char *Cmd) {
first_read = false;
reread = false;
bool decrease = false;
while(!first_read){
while (!first_read) {
int res = iclass_read_block_ex(key, blockno, 0x88, elite, rawkey, use_replay, verbose, auth, shallow_mod, data_read, false);
if (res == PM3_SUCCESS && !reread){
if (memcmp(data_read, zeros, 8) == 0){
if (res == PM3_SUCCESS && !reread) {
if (memcmp(data_read, zeros, 8) == 0) {
reread = true;
}else{
} else {
first_read = true;
reread = false;
}
} else if (res == PM3_SUCCESS && reread){
} else if (res == PM3_SUCCESS && reread) {
first_read = true;
reread = false;
} else if (res != PM3_SUCCESS){
} else if (res != PM3_SUCCESS) {
decrease = true;
}
}
if (decrease && tearoff_start > 0){ //if there was an error reading repeat the tearoff with the same delay
if (decrease && tearoff_start > 0) { //if there was an error reading repeat the tearoff with the same delay
tearoff_start--;
}
bool tear_success = true;
for (int i=0; i<PICOPASS_BLOCK_SIZE; i++){
if(data[i] != data_read[i]){
for (int i = 0; i < PICOPASS_BLOCK_SIZE; i++) {
if (data[i] != data_read[i]) {
tear_success = false;
}
}
if(tear_success){ //tearoff succeeded
if (tear_success) { //tearoff succeeded
read_ok = true;
PrintAndLogEx(SUCCESS, _GREEN_("Tear-off Success!"));
PrintAndLogEx(INFO, "Read: %s", sprint_hex(data_read, sizeof(data_read)));
}else{ //tearoff did not succeed
} else { //tearoff did not succeed
PrintAndLogEx(FAILED, _RED_("Tear-off Failed!"));
tearoff_start++;
}
Expand Down
36 changes: 18 additions & 18 deletions client/src/cmdhflist.c
Original file line number Diff line number Diff line change
Expand Up @@ -2440,9 +2440,9 @@ void annotateFMCOS20(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
snprintf(exp, size, "APP UNBLOCK");
break;
case FMCOS20_CMD_APP_BLOCK:
if (cmd[pos+1] == 0)
if (cmd[pos + 1] == 0)
snprintf(exp, size, "APP BLOCK (TEMP)");
else if(cmd[pos+1] == 1)
else if (cmd[pos + 1] == 1)
snprintf(exp, size, "APP BLOCK (PERM)");
else
snprintf(exp, size, "APP BLOCK");
Expand All @@ -2451,34 +2451,34 @@ void annotateFMCOS20(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
snprintf(exp, size, "PIN UNBLOCK");
break;
case FMCOS20_CMD_CHANGE_PIN:
if (cmd[pos+1] == 0)
if (cmd[pos + 1] == 0)
snprintf(exp, size, "RESET PIN");
else if (cmd[pos+1] == 1)
else if (cmd[pos + 1] == 1)
snprintf(exp, size, "CHANGE PIN");
break;
case FMCOS20_CMD_INITIALIZE_TRANSACTION:
if (cmd[pos+1] == 0)
if (cmd[pos + 1] == 0)
snprintf(exp, size, "INIT. TRANSACTION (CREDIT)");
else if (cmd[pos+1] == 1)
else if (cmd[pos + 1] == 1)
snprintf(exp, size, "INIT. TRANSACTION (PURCHASE)");
else if (cmd[pos+1] == 2)
else if (cmd[pos + 1] == 2)
snprintf(exp, size, "INIT. TRANSACTION (CASH WITHDRAW)");
else if (cmd[pos+1] == 3)
else if (cmd[pos + 1] == 3)
snprintf(exp, size, "INIT. TRANSACTION (CAPP PURCHASE)");
else if (cmd[pos+1] == 4)
else if (cmd[pos + 1] == 4)
snprintf(exp, size, "INIT. TRANSACTION (OVERDRAFT)");
else if (cmd[pos+1] == 5)
else if (cmd[pos + 1] == 5)
snprintf(exp, size, "INIT. TRANSACTION (WITHDRAW)");
break;
case FMCOS20_CMD_CREDIT_LOAD:
snprintf(exp, size, "CREDIT LOAD");
break;
case FMCOS20_CMD_PURCHASE:
if(cmd[pos+1] == 0)
if (cmd[pos + 1] == 0)
snprintf(exp, size, "PURCHASE");
else if (cmd[pos+1] == 1)
else if (cmd[pos + 1] == 1)
snprintf(exp, size, "CAPP PURCHASE / CASH WITHDRAW");
else if (cmd[pos+1] == 3)
else if (cmd[pos + 1] == 3)
snprintf(exp, size, "WITHDRAW");
break;
case FMCOS20_CMD_UPDATE_OVERDRAW_LIMIT:
Expand All @@ -2491,15 +2491,15 @@ void annotateFMCOS20(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
snprintf(exp, size, "GET BALANCE");
break;
case FMCOS20_CMD_INITIALIZE_GREY_LOCK_UNLOCK:
if (cmd[pos+1] == 8)
if (cmd[pos + 1] == 8)
snprintf(exp, size, "INIT. GRAY LOCK");
else if (cmd[pos+1] == 9)
else if (cmd[pos + 1] == 9)
snprintf(exp, size, "INIT. GRAY UNLOCK");
break;
case FMCOS20_CMD_GREY_LOCK_UNLOCK:
if (cmd[pos+1] == 8)
if (cmd[pos + 1] == 8)
snprintf(exp, size, "GRAY LOCK");
else if (cmd[pos+1] == 9)
else if (cmd[pos + 1] == 9)
snprintf(exp, size, "GRAY UNLOCK");
break;
case FMCOS20_CMD_DEBIT_UNLOCK:
Expand Down Expand Up @@ -2536,4 +2536,4 @@ void annotateFMCOS20(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
//snprintf(exp, size, "?");
break;
}
}
}
6 changes: 3 additions & 3 deletions client/src/cmdhfmfu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2032,9 +2032,9 @@ uint64_t GetHF14AMfU_Type(void) {
} else {
// data[3] == KID == 0x05 Key ID
// data[2] == REV == 0x13 Product version
if ((data[1]==0x90) && (data[0]==0x90)) {
if ((data[1] == 0x90) && (data[0] == 0x90)) {
tagtype = MFU_TT_ST25TN01K;
} else if ((data[1]==0x90) && (data[0]==0x91)) {
} else if ((data[1] == 0x90) && (data[0] == 0x91)) {
tagtype = MFU_TT_ST25TN512;
}
}
Expand Down Expand Up @@ -2431,7 +2431,7 @@ static int CmdHF14AMfUInfo(const char *Cmd) {
PrintAndLogEx(INFO, " Product Version: %02x", data[2]);
PrintAndLogEx(INFO, " Product Code: %02x%02x", data[1], data[0]);
uint8_t signature[32] = {0};
for (int blkoff=0; blkoff<8; blkoff++) {
for (int blkoff = 0; blkoff < 8; blkoff++) {
status = ul_read(0x34 + blkoff, signature + (blkoff * 4), 4);
if (status <= 1) {
PrintAndLogEx(ERR, "Error: tag didn't answer to READ SYSBLOCK");
Expand Down
Loading

0 comments on commit 17338e2

Please sign in to comment.