Skip to content

Commit

Permalink
make style
Browse files Browse the repository at this point in the history
  • Loading branch information
doegox committed Aug 30, 2019
1 parent 99159b3 commit 2022df1
Show file tree
Hide file tree
Showing 12 changed files with 202 additions and 201 deletions.
2 changes: 1 addition & 1 deletion armsrc/appmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ static void PacketReceived(PacketCommandNG *packet) {
break;
}
case CMD_HF_MIFARE_EML_LOAD: {
mfc_eload_t *payload = (mfc_eload_t *) packet->data.asBytes;
mfc_eload_t *payload = (mfc_eload_t *) packet->data.asBytes;
MifareECardLoadExt(payload->sectorcnt, payload->keytype);
break;
}
Expand Down
18 changes: 9 additions & 9 deletions armsrc/iclass.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static int g_wait = 300;
static int timeout = 2900;
static uint32_t time_rdr = 0;
static uint32_t time_delta = 0;
static uint32_t time_delta_wait = 0;
static uint32_t time_delta_wait = 0;
static uint32_t time_response = 0;

static int SendIClassAnswer(uint8_t *resp, int respLen, uint16_t delay);
Expand Down Expand Up @@ -1875,15 +1875,15 @@ static int GetIClassAnswer(uint8_t *receivedResponse, int maxLen, int *samples,
}

// keep tx buffer in a defined state anyway.
/*
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
AT91C_BASE_SSC->SSC_THR = 0x00;
}
*/
/*
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
AT91C_BASE_SSC->SSC_THR = 0x00;
}
*/
// Wait for byte be become available in rx holding register
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {

if ( GetCountSspClk() - foo > timeout) return false;
if (GetCountSspClk() - foo > timeout) return false;
// if (c >= timeout) return false;

c++;
Expand All @@ -1896,7 +1896,7 @@ static int GetIClassAnswer(uint8_t *receivedResponse, int maxLen, int *samples,
if (ManchesterDecoding_iclass(b & 0x0f)) {
if (samples)
*samples = c << 3;

time_response = GetCountSspClk() - foo;
return true;
}
Expand Down Expand Up @@ -1959,7 +1959,7 @@ bool sendCmdGetResponseWithRetries(uint8_t *command, size_t cmdsize, uint8_t *re
// since its called with fixed sized arrays

// update/write commadn takes 4ms to 15ms before responding
if ( command[0] == ICLASS_CMD_UPDATE )
if (command[0] == ICLASS_CMD_UPDATE)
g_wait = 15000;

uint8_t got_n = ReaderReceiveIClass(resp);
Expand Down
80 changes: 40 additions & 40 deletions armsrc/mifarecmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1523,33 +1523,33 @@ void MifareChkKeys_fast(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *da
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
BigBuf_free();
BigBuf_Clear_ext(false);
// special trick ecfill
if (use_flashmem && foundkeys == allkeys) {
uint8_t block[16] = {0};
for (int i = 0; i < sectorcnt; i++) {
uint8_t blockno;
if (i < 32) {
blockno = (i * 4) ^ 0x3;
} else {
blockno = (32 * 4 + (i - 32) * 16) ^ 0xF;
}
// get ST
emlGetMem(block, blockno, 1);

memcpy(block, k_sector[i].keyA, 6);
memcpy(block + 10, k_sector[i].keyB, 6);
emlSetMem_xt(block, blockno, 1, sizeof(block));
}
int oldbg = DBGLEVEL;
DBGLEVEL = DBG_NONE;
MifareECardLoad(sectorcnt, 0);
MifareECardLoad(sectorcnt, 1);
DBGLEVEL = oldbg;
}

// special trick ecfill
if (use_flashmem && foundkeys == allkeys) {

uint8_t block[16] = {0};
for (int i = 0; i < sectorcnt; i++) {

uint8_t blockno;
if (i < 32) {
blockno = (i * 4) ^ 0x3;
} else {
blockno = (32 * 4 + (i - 32) * 16) ^ 0xF;
}
// get ST
emlGetMem(block, blockno, 1);

memcpy(block, k_sector[i].keyA, 6);
memcpy(block + 10, k_sector[i].keyB, 6);

emlSetMem_xt(block, blockno, 1, sizeof(block));
}
int oldbg = DBGLEVEL;
DBGLEVEL = DBG_NONE;
MifareECardLoad(sectorcnt, 0);
MifareECardLoad(sectorcnt, 1);
DBGLEVEL = oldbg;
}
} else {
// partial/none keys found
reply_mix(CMD_ACK, foundkeys, 0, 0, 0, 0);
Expand Down Expand Up @@ -1695,9 +1695,9 @@ void MifareEMemGet(uint8_t blockno, uint8_t blockcnt) {
//
//-----------------------------------------------------------------------------
int MifareECardLoadExt(uint8_t numSectors, uint8_t keyType) {
int retval = MifareECardLoad(numSectors, keyType);
reply_ng(CMD_HF_MIFARE_EML_LOAD, retval, NULL, 0);
return retval;
int retval = MifareECardLoad(numSectors, keyType);
reply_ng(CMD_HF_MIFARE_EML_LOAD, retval, NULL, 0);
return retval;
}

int MifareECardLoad(uint8_t numSectors, uint8_t keyType) {
Expand All @@ -1723,7 +1723,7 @@ int MifareECardLoad(uint8_t numSectors, uint8_t keyType) {
if (!iso14443a_select_card(uid, NULL, &cuid, true, 0, true)) {
retval = PM3_ESOFT;
if (DBGLEVEL > DBG_ERROR) Dbprintf("Can't select card");
goto out;
goto out;
}

for (uint8_t sectorNo = 0; sectorNo < numSectors; sectorNo++) {
Expand All @@ -1747,22 +1747,22 @@ int MifareECardLoad(uint8_t numSectors, uint8_t keyType) {
if (DBGLEVEL > DBG_ERROR) Dbprintf("Error reading sector %2d block %2d", sectorNo, blockNo);
break;
}
if (blockNo < NumBlocksPerSector(sectorNo) - 1) {
emlSetMem(dataoutbuf, FirstBlockOfSector(sectorNo) + blockNo, 1);
} else { // sector trailer, keep the keys, set only the AC
emlGetMem(dataoutbuf2, FirstBlockOfSector(sectorNo) + blockNo, 1);
memcpy(&dataoutbuf2[6], &dataoutbuf[6], 4);
emlSetMem(dataoutbuf2, FirstBlockOfSector(sectorNo) + blockNo, 1);
}
if (blockNo < NumBlocksPerSector(sectorNo) - 1) {
emlSetMem(dataoutbuf, FirstBlockOfSector(sectorNo) + blockNo, 1);
} else { // sector trailer, keep the keys, set only the AC
emlGetMem(dataoutbuf2, FirstBlockOfSector(sectorNo) + blockNo, 1);
memcpy(&dataoutbuf2[6], &dataoutbuf[6], 4);
emlSetMem(dataoutbuf2, FirstBlockOfSector(sectorNo) + blockNo, 1);
}
}
}

if (mifare_classic_halt(pcs, cuid)) {
if (DBGLEVEL > DBG_ERROR)
Dbprintf("Halt error");
}
}

if (DBGLEVEL >= DBG_INFO) DbpString("Emulator fill sectors finished");
if (DBGLEVEL >= DBG_INFO) DbpString("Emulator fill sectors finished");

out:
crypto1_destroy(pcs);
Expand Down
Loading

0 comments on commit 2022df1

Please sign in to comment.