make style

This commit is contained in:
Philippe Teuwen 2019-06-07 21:40:33 +02:00
commit a55e597e36
37 changed files with 193 additions and 193 deletions

View file

@ -776,7 +776,7 @@ readysim:
LED_C_ON(); LED_C_ON();
uint16_t flags; uint16_t flags;
switch (p_card.uidlen){ switch (p_card.uidlen) {
case 10: case 10:
flags = FLAG_10B_UID_IN_DATA; flags = FLAG_10B_UID_IN_DATA;
break; break;

View file

@ -388,7 +388,7 @@ void RunMod() {
LED_B_ON(); // green LED_B_ON(); // green
// assuming arg0==0, use hardcoded uid 0xdeadbeaf // assuming arg0==0, use hardcoded uid 0xdeadbeaf
uint16_t flags; uint16_t flags;
switch (p_card.uidlen){ switch (p_card.uidlen) {
case 10: case 10:
flags = FLAG_10B_UID_IN_DATA; flags = FLAG_10B_UID_IN_DATA;
break; break;

View file

@ -677,40 +677,40 @@ static int hitagS_handle_tag_auth(hitag_function htf, uint64_t key, uint64_t NrA
break; break;
} }
uint8_t uid1 = (uid[0] << 7) uint8_t uid1 = (uid[0] << 7)
| (uid[1] << 6) | (uid[1] << 6)
| (uid[2] << 5) | (uid[2] << 5)
| (uid[3] << 4) | (uid[3] << 4)
| (uid[4] << 3) | (uid[4] << 3)
| (uid[5] << 2) | (uid[5] << 2)
| (uid[6] << 1) | (uid[6] << 1)
| uid[7]; | uid[7];
uint8_t uid2 = (uid[8] << 7) uint8_t uid2 = (uid[8] << 7)
| (uid[9] << 6) | (uid[9] << 6)
| (uid[10] << 5) | (uid[10] << 5)
| (uid[11] << 4) | (uid[11] << 4)
| (uid[12] << 3) | (uid[12] << 3)
| (uid[13] << 2) | (uid[13] << 2)
| (uid[14] << 1) | (uid[14] << 1)
| uid[15]; | uid[15];
uint8_t uid3 = (uid[16] << 7) uint8_t uid3 = (uid[16] << 7)
| (uid[17] << 6) | (uid[17] << 6)
| (uid[18] << 5) | (uid[18] << 5)
| (uid[19] << 4) | (uid[19] << 4)
| (uid[20] << 3) | (uid[20] << 3)
| (uid[21] << 2) | (uid[21] << 2)
| (uid[22] << 1) | (uid[22] << 1)
| uid[23]; | uid[23];
uint8_t uid4 = (uid[24] << 7) uint8_t uid4 = (uid[24] << 7)
| (uid[25] << 6) | (uid[25] << 6)
| (uid[26] << 5) | (uid[26] << 5)
| (uid[27] << 4) | (uid[27] << 4)
| (uid[28] << 3) | (uid[28] << 3)
| (uid[29] << 2) | (uid[29] << 2)
| (uid[30] << 1) | (uid[30] << 1)
| uid[31]; | uid[31];
if (DEBUG) if (DEBUG)
Dbprintf("UID: %02X %02X %02X %02X", uid1, uid2, uid3, uid4); Dbprintf("UID: %02X %02X %02X %02X", uid1, uid2, uid3, uid4);

View file

@ -761,8 +761,8 @@ static bool GetIso14443aCommandFromReader(uint8_t *received, uint8_t *par, int *
uint16_t check = 0; uint16_t check = 0;
for (;;) { for (;;) {
if ( check == 1000 ) { if (check == 1000) {
if ( BUTTON_PRESS() || data_available() ) if (BUTTON_PRESS() || data_available())
return false; return false;
check = 0; check = 0;
} }
@ -1191,7 +1191,7 @@ void SimulateIso14443aTag(uint8_t tagType, uint8_t flags, uint8_t *data) {
ar_nr_nonces[index].state = SECOND; ar_nr_nonces[index].state = SECOND;
// send to client (one struct nonces_t) // send to client (one struct nonces_t)
reply_ng(CMD_SIMULATE_MIFARE_CARD, PM3_SUCCESS, (uint8_t*)&ar_nr_nonces[index], sizeof(nonces_t) ); reply_ng(CMD_SIMULATE_MIFARE_CARD, PM3_SUCCESS, (uint8_t *)&ar_nr_nonces[index], sizeof(nonces_t));
ar_nr_nonces[index].state = EMPTY; ar_nr_nonces[index].state = EMPTY;
ar_nr_nonces[index].sector = 0; ar_nr_nonces[index].sector = 0;
@ -1716,10 +1716,10 @@ int EmGetCmd(uint8_t *received, uint16_t *len, uint8_t *par) {
for (;;) { for (;;) {
WDT_HIT(); WDT_HIT();
if ( check == 1000 ) { if (check == 1000) {
if (BUTTON_PRESS() || data_available()) if (BUTTON_PRESS() || data_available())
return 1; return 1;
check = 0; check = 0;
} }
++check; ++check;

View file

@ -606,7 +606,7 @@ void SimulateTagLowFrequencyEx(int period, int gap, bool ledcontrol, int numcycl
// used as a simple detection of a reader field? // used as a simple detection of a reader field?
while (!(AT91C_BASE_PIOA->PIO_PDSR & GPIO_SSC_CLK)) { while (!(AT91C_BASE_PIOA->PIO_PDSR & GPIO_SSC_CLK)) {
WDT_HIT(); WDT_HIT();
if ( check == 1000) { if (check == 1000) {
if (data_available() || BUTTON_PRESS()) if (data_available() || BUTTON_PRESS())
goto OUT; goto OUT;
check = 0; check = 0;

View file

@ -1633,7 +1633,7 @@ void MifareEMemGet(uint8_t blockno, uint8_t blockcnt) {
// //
size_t size = blockcnt * 16; size_t size = blockcnt * 16;
if ( size > PM3_CMD_DATA_SIZE) { if (size > PM3_CMD_DATA_SIZE) {
reply_ng(CMD_MIFARE_EML_MEMGET, PM3_EMALLOC, NULL, 0); reply_ng(CMD_MIFARE_EML_MEMGET, PM3_EMALLOC, NULL, 0);
return; return;
} }

View file

@ -345,8 +345,8 @@ void BootROM(void) {
common_area.flags.bootrom_present = 1; common_area.flags.bootrom_present = 1;
if ((common_area.command == COMMON_AREA_COMMAND_ENTER_FLASH_MODE) || if ((common_area.command == COMMON_AREA_COMMAND_ENTER_FLASH_MODE) ||
(!common_area.flags.button_pressed && BUTTON_PRESS()) || (!common_area.flags.button_pressed && BUTTON_PRESS()) ||
(_osimage_entry == 0xffffffffU)) { (_osimage_entry == 0xffffffffU)) {
flash_mode(); flash_mode();
} else { } else {
// clear button status, even if button still pressed // clear button status, even if button still pressed

View file

@ -448,7 +448,7 @@ int CmdGetBitStream(const char *Cmd) {
} }
int CmdConvertBitStream(const char *Cmd) { int CmdConvertBitStream(const char *Cmd) {
if ( isGraphBitstream() ) { if (isGraphBitstream()) {
convertGraphFromBitstream(); convertGraphFromBitstream();
} else { } else {
// get high, low // get high, low
@ -716,7 +716,7 @@ int ASKbiphaseDemod(const char *Cmd, bool verbose) {
setDemodBuff(BitStream, size, 0); setDemodBuff(BitStream, size, 0);
setClockGrid(clk, startIdx + clk * offset / 2); setClockGrid(clk, startIdx + clk * offset / 2);
if (g_debugMode || verbose) { if (g_debugMode || verbose) {
PrintAndLogEx(NORMAL, "Biphase Decoded using offset %d | clock %d | #errors %d | start index %d\ndata\n", offset, clk, errCnt, (startIdx + clk * offset / 2) ); PrintAndLogEx(NORMAL, "Biphase Decoded using offset %d | clock %d | #errors %d | start index %d\ndata\n", offset, clk, errCnt, (startIdx + clk * offset / 2));
printDemodBuff(); printDemodBuff();
} }
return PM3_SUCCESS; return PM3_SUCCESS;

View file

@ -474,9 +474,9 @@ int CmdHF14ASim(const char *Cmd) {
flags |= FLAG_UID_IN_EMUL; flags |= FLAG_UID_IN_EMUL;
struct { struct {
uint8_t tagtype; uint8_t tagtype;
uint8_t flags; uint8_t flags;
uint8_t uid[10]; uint8_t uid[10];
} PACKED payload; } PACKED payload;
payload.tagtype = tagtype; payload.tagtype = tagtype;
@ -495,10 +495,10 @@ int CmdHF14ASim(const char *Cmd) {
if ((flags & FLAG_NR_AR_ATTACK) != FLAG_NR_AR_ATTACK) break; if ((flags & FLAG_NR_AR_ATTACK) != FLAG_NR_AR_ATTACK) break;
nonces_t *data = (nonces_t*)resp.data.asBytes; nonces_t *data = (nonces_t *)resp.data.asBytes;
readerAttack(data[0], setEmulatorMem, verbose); readerAttack(data[0], setEmulatorMem, verbose);
} }
if (resp.status == PM3_EOPABORTED && ((flags & FLAG_NR_AR_ATTACK) == FLAG_NR_AR_ATTACK) ) if (resp.status == PM3_EOPABORTED && ((flags & FLAG_NR_AR_ATTACK) == FLAG_NR_AR_ATTACK))
showSectorTable(); showSectorTable();
PrintAndLogEx(INFO, "Done"); PrintAndLogEx(INFO, "Done");

View file

@ -559,7 +559,7 @@ static int CmdHF14AMfRdBl(const char *Cmd) {
memcpy(payload.key, key, sizeof(payload.key)); memcpy(payload.key, key, sizeof(payload.key));
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_MIFARE_READBL, (uint8_t*)&payload, sizeof(mf_readblock_t)); SendCommandNG(CMD_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t));
PacketResponseNG resp; PacketResponseNG resp;
if (WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500)) { if (WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500)) {
@ -797,7 +797,7 @@ static int CmdHF14AMfDump(const char *Cmd) {
memcpy(payload.key, keyA[sectorNo], sizeof(payload.key)); memcpy(payload.key, keyA[sectorNo], sizeof(payload.key));
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_MIFARE_READBL, (uint8_t*)&payload, sizeof(mf_readblock_t)); SendCommandNG(CMD_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t));
if (WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500)) { if (WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500)) {
@ -836,7 +836,7 @@ static int CmdHF14AMfDump(const char *Cmd) {
memcpy(payload.key, keyA[sectorNo], sizeof(payload.key)); memcpy(payload.key, keyA[sectorNo], sizeof(payload.key));
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_MIFARE_READBL, (uint8_t*)&payload, sizeof(mf_readblock_t)); SendCommandNG(CMD_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t));
received = WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500); received = WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500);
} else { // data block. Check if it can be read with key A or key B } else { // data block. Check if it can be read with key A or key B
uint8_t data_area = (sectorNo < 32) ? blockNo : blockNo / 5; uint8_t data_area = (sectorNo < 32) ? blockNo : blockNo / 5;
@ -847,7 +847,7 @@ static int CmdHF14AMfDump(const char *Cmd) {
memcpy(payload.key, keyB[sectorNo], sizeof(payload.key)); memcpy(payload.key, keyB[sectorNo], sizeof(payload.key));
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_MIFARE_READBL, (uint8_t*)&payload, sizeof(mf_readblock_t)); SendCommandNG(CMD_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t));
received = WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500); received = WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500);
} else if (rights[sectorNo][data_area] == 0x07) { // no key would work } else if (rights[sectorNo][data_area] == 0x07) { // no key would work
PrintAndLogEx(WARNING, "access rights do not allow reading of sector %2d block %3d", sectorNo, blockNo); PrintAndLogEx(WARNING, "access rights do not allow reading of sector %2d block %3d", sectorNo, blockNo);
@ -860,7 +860,7 @@ static int CmdHF14AMfDump(const char *Cmd) {
memcpy(payload.key, keyA[sectorNo], sizeof(payload.key)); memcpy(payload.key, keyA[sectorNo], sizeof(payload.key));
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_MIFARE_READBL, (uint8_t*)&payload, sizeof(mf_readblock_t)); SendCommandNG(CMD_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t));
received = WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500); received = WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500);
} }
} }
@ -1250,7 +1250,7 @@ static int CmdHF14AMfNested(const char *Cmd) {
num_to_bytes(e_sector[i].Key[0], 6, payload.key); // KEY A num_to_bytes(e_sector[i].Key[0], 6, payload.key); // KEY A
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t) ); SendCommandNG(CMD_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t));
PacketResponseNG resp; PacketResponseNG resp;
if (!WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500)) continue; if (!WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500)) continue;
@ -2014,7 +2014,7 @@ static int CmdHF14AMfChk(const char *Cmd) {
num_to_bytes(e_sector[i].Key[0], 6, payload.key); // KEY A num_to_bytes(e_sector[i].Key[0], 6, payload.key); // KEY A
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t) ); SendCommandNG(CMD_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t));
PacketResponseNG resp; PacketResponseNG resp;
if (!WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500)) continue; if (!WaitForResponseTimeout(CMD_MIFARE_READBL, &resp, 1500)) continue;
@ -2265,9 +2265,9 @@ static int CmdHF14AMfSim(const char *Cmd) {
, flags); , flags);
struct { struct {
uint16_t flags; uint16_t flags;
uint8_t exitAfter; uint8_t exitAfter;
uint8_t uid[10]; uint8_t uid[10];
} PACKED payload; } PACKED payload;
payload.flags = flags; payload.flags = flags;
@ -3215,7 +3215,7 @@ static int CmdHf14AMfSetMod(const char *Cmd) {
uint8_t data[7]; uint8_t data[7];
data[0] = mod; data[0] = mod;
memcpy(data+1, key, 6); memcpy(data + 1, key, 6);
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_MIFARE_SETMOD, data, sizeof(data)); SendCommandNG(CMD_MIFARE_SETMOD, data, sizeof(data));

View file

@ -201,18 +201,18 @@ int CmdLFCommandRead(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Sending"); PrintAndLogEx(SUCCESS, "Sending");
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K, (uint8_t*)&payload, 8 + datalen ); SendCommandNG(CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K, (uint8_t *)&payload, 8 + datalen);
printf("\n"); printf("\n");
uint8_t i = 10; uint8_t i = 10;
while ( !WaitForResponseTimeout(CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K, NULL, 2000 ) && i != 0) { while (!WaitForResponseTimeout(CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K, NULL, 2000) && i != 0) {
printf("."); printf(".");
fflush(stdout); fflush(stdout);
i--; i--;
} }
printf("\n"); printf("\n");
if ( i ) { if (i) {
PrintAndLogEx(SUCCESS, "Downloading response signal data"); PrintAndLogEx(SUCCESS, "Downloading response signal data");
getSamples(0, true); getSamples(0, true);
return PM3_SUCCESS; return PM3_SUCCESS;
@ -391,7 +391,7 @@ int lf_read(bool silent, uint32_t samples) {
} }
// resp.oldarg[0] is bits read not bytes read. // resp.oldarg[0] is bits read not bytes read.
uint32_t bits = (resp.data.asDwords[0] / 8 ); uint32_t bits = (resp.data.asDwords[0] / 8);
getSamples(bits, silent); getSamples(bits, silent);
return PM3_SUCCESS; return PM3_SUCCESS;
@ -449,7 +449,7 @@ static void ChkBitstream() {
for (int i = 0; i < (int)(GraphTraceLen / 2); i++) { for (int i = 0; i < (int)(GraphTraceLen / 2); i++) {
if (GraphBuffer[i] > 1 || GraphBuffer[i] < 0) { if (GraphBuffer[i] > 1 || GraphBuffer[i] < 0) {
CmdGetBitStream(""); CmdGetBitStream("");
PrintAndLogEx(INFO, "Converted to bitstream"); PrintAndLogEx(INFO, "Converted to bitstream");
break; break;
} }
} }
@ -461,7 +461,7 @@ int CmdLFSim(const char *Cmd) {
if (!session.pm3_present) return PM3_ENOTTY; if (!session.pm3_present) return PM3_ENOTTY;
// sanity check // sanity check
if ( GraphTraceLen < 20 ) { if (GraphTraceLen < 20) {
PrintAndLogEx(ERR, "No data in Graphbuffer"); PrintAndLogEx(ERR, "No data in Graphbuffer");
return PM3_ENODATA; return PM3_ENODATA;
} }
@ -497,8 +497,8 @@ int CmdLFSim(const char *Cmd) {
clearCommandBuffer(); clearCommandBuffer();
payload_up.offset = i; payload_up.offset = i;
for(uint16_t j = 0; j < len; j++) for (uint16_t j = 0; j < len; j++)
payload_up.data[j] = GraphBuffer[i+j]; payload_up.data[j] = GraphBuffer[i + j];
SendCommandNG(CMD_UPLOAD_SIM_SAMPLES_125K, (uint8_t *)&payload_up, sizeof(struct pupload)); SendCommandNG(CMD_UPLOAD_SIM_SAMPLES_125K, (uint8_t *)&payload_up, sizeof(struct pupload));

View file

@ -332,7 +332,7 @@ static int CmdAWIDSim(const char *Cmd) {
verify_values(&fmtlen, &fc, &cn); verify_values(&fmtlen, &fc, &cn);
if ( getAWIDBits(fmtlen, fc, cn, bs) != PM3_SUCCESS ) { if (getAWIDBits(fmtlen, fc, cn, bs) != PM3_SUCCESS) {
PrintAndLogEx(WARNING, "Error with tag bitstream generation."); PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
return PM3_ESOFT; return PM3_ESOFT;
} }
@ -387,7 +387,7 @@ static int CmdAWIDClone(const char *Cmd) {
verify_values(&fmtlen, &fc, &cn); verify_values(&fmtlen, &fc, &cn);
if ( getAWIDBits(fmtlen, fc, cn, bs) != PM3_SUCCESS ) { if (getAWIDBits(fmtlen, fc, cn, bs) != PM3_SUCCESS) {
PrintAndLogEx(WARNING, "Error with tag bitstream generation."); PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
return PM3_ESOFT; return PM3_ESOFT;
} }
@ -512,12 +512,12 @@ static int CmdAWIDBrute(const char *Cmd) {
// Do one up // Do one up
if (up < 0xFFFF) if (up < 0xFFFF)
if ( sendTry(fmtlen, fc, up++, delay, bits, size, verbose) != PM3_SUCCESS) return PM3_ESOFT; if (sendTry(fmtlen, fc, up++, delay, bits, size, verbose) != PM3_SUCCESS) return PM3_ESOFT;
// Do one down (if cardnumber is given) // Do one down (if cardnumber is given)
if (cn > 1) if (cn > 1)
if (down > 1) if (down > 1)
if ( sendTry(fmtlen, fc, --down, delay, bits, size, verbose) != PM3_SUCCESS) return PM3_ESOFT; if (sendTry(fmtlen, fc, --down, delay, bits, size, verbose) != PM3_SUCCESS) return PM3_ESOFT;
} }
return PM3_SUCCESS; return PM3_SUCCESS;
} }

View file

@ -36,7 +36,7 @@ static int CmdCOTAGDemod(const char *Cmd) {
uint8_t alignPos = 0; uint8_t alignPos = 0;
uint16_t err = manrawdecode(bits, &bitlen, 1, &alignPos); uint16_t err = manrawdecode(bits, &bitlen, 1, &alignPos);
if (err > 50 ) { if (err > 50) {
PrintAndLogEx(DEBUG, "DEBUG: Error - COTAG too many errors: %d", err); PrintAndLogEx(DEBUG, "DEBUG: Error - COTAG too many errors: %d", err);
return PM3_ESOFT; return PM3_ESOFT;
} }

View file

@ -195,7 +195,7 @@ static void ConstructEM410xEmulGraph(const char *uid, const uint8_t clock) {
/* clear our graph */ /* clear our graph */
ClearGraph(true); ClearGraph(true);
/* write 16 zero bit sledge */ /* write 16 zero bit sledge */
for (i = 0; i < 20; i++) for (i = 0; i < 20; i++)
AppendGraph(false, clock, 0); AppendGraph(false, clock, 0);
@ -387,12 +387,12 @@ int AskEm410xDemod(const char *Cmd, uint32_t *hi, uint64_t *lo, bool verbose) {
bool st = true; bool st = true;
// em410x simulation etc uses 0/1 as signal data. This must be converted in order to demod it back again // em410x simulation etc uses 0/1 as signal data. This must be converted in order to demod it back again
if ( isGraphBitstream() ) { if (isGraphBitstream()) {
convertGraphFromBitstream(); convertGraphFromBitstream();
} }
if (ASKDemod_ext(Cmd, false, false, 1, &st) != PM3_SUCCESS) if (ASKDemod_ext(Cmd, false, false, 1, &st) != PM3_SUCCESS)
return PM3_ESOFT; return PM3_ESOFT;
return AskEm410xDecode(verbose, hi, lo); return AskEm410xDecode(verbose, hi, lo);
} }
/* /*
@ -417,7 +417,7 @@ static int CmdEM410xDemod(const char *Cmd) {
uint64_t lo = 0; uint64_t lo = 0;
if (AskEm410xDemod(Cmd, &hi, &lo, true) != PM3_SUCCESS) if (AskEm410xDemod(Cmd, &hi, &lo, true) != PM3_SUCCESS)
return PM3_ESOFT; return PM3_ESOFT;
g_em410xid = lo; g_em410xid = lo;
return PM3_SUCCESS; return PM3_SUCCESS;
@ -1140,7 +1140,7 @@ static int demodEM4x05resp(uint32_t *word) {
//////////////// 4205 / 4305 commands //////////////// 4205 / 4305 commands
static int EM4x05ReadWord_ext(uint8_t addr, uint32_t pwd, bool usePwd, uint32_t *word) { static int EM4x05ReadWord_ext(uint8_t addr, uint32_t pwd, bool usePwd, uint32_t *word) {
struct { struct {
uint32_t password; uint32_t password;
uint8_t address; uint8_t address;
uint8_t usepwd; uint8_t usepwd;
@ -1250,7 +1250,7 @@ static int CmdEM4x05Write(const char *Cmd) {
PrintAndLogEx(NORMAL, "Writing address %d data %08X using password %08X", addr, data, pwd); PrintAndLogEx(NORMAL, "Writing address %d data %08X using password %08X", addr, data, pwd);
} }
struct { struct {
uint32_t password; uint32_t password;
uint32_t data; uint32_t data;
uint8_t address; uint8_t address;
@ -1263,7 +1263,7 @@ static int CmdEM4x05Write(const char *Cmd) {
payload.usepwd = usePwd; payload.usepwd = usePwd;
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_EM4X_WRITE_WORD, (uint8_t*)&payload, sizeof(payload)); SendCommandNG(CMD_EM4X_WRITE_WORD, (uint8_t *)&payload, sizeof(payload));
PacketResponseNG resp; PacketResponseNG resp;
if (!WaitForResponseTimeout(CMD_EM4X_WRITE_WORD, &resp, 2000)) { if (!WaitForResponseTimeout(CMD_EM4X_WRITE_WORD, &resp, 2000)) {
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation."); PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");

View file

@ -124,7 +124,7 @@ static int CmdHIDDemod(const char *Cmd) {
(void)Cmd; // Cmd is not used so far (void)Cmd; // Cmd is not used so far
// HID simulation etc uses 0/1 as signal data. This must be converted in order to demod it back again // HID simulation etc uses 0/1 as signal data. This must be converted in order to demod it back again
if ( isGraphBitstream() ) { if (isGraphBitstream()) {
convertGraphFromBitstream(); convertGraphFromBitstream();
} }
@ -593,7 +593,7 @@ static int CmdHIDBrute(const char *Cmd) {
// Do one up // Do one up
if (up < 0xFFFF) if (up < 0xFFFF)
if ( sendTry(fmtlen, fc, up++, delay, bits, verbose) != PM3_SUCCESS) return PM3_ESOFT; if (sendTry(fmtlen, fc, up++, delay, bits, verbose) != PM3_SUCCESS) return PM3_ESOFT;
// Do one down (if cardnumber is given) // Do one down (if cardnumber is given)
if (cn > 1) if (cn > 1)

View file

@ -331,7 +331,8 @@ int getPyramidBits(uint32_t fc, uint32_t cn, uint8_t *pyramidBits) {
// Get 26 wiegand from FacilityCode, CardNumber // Get 26 wiegand from FacilityCode, CardNumber
uint8_t wiegand[24]; uint8_t wiegand[24];
memset(wiegand, 0x00, sizeof(wiegand)); memset(wiegand, 0x00, sizeof(wiegand));
num_to_bytebits(fc, 8, wiegand); num_to_bytebits(cn, 16, wiegand + 8); num_to_bytebits(fc, 8, wiegand);
num_to_bytebits(cn, 16, wiegand + 8);
// add wiegand parity bits (dest, source, len) // add wiegand parity bits (dest, source, len)
wiegand_add_parity(pre + 80, wiegand, 24); wiegand_add_parity(pre + 80, wiegand, 24);

View file

@ -564,7 +564,7 @@ bool tryDetectModulation(void) {
ans = fskClocks(&fc1, &fc2, (uint8_t *)&clk, &firstClockEdge); ans = fskClocks(&fc1, &fc2, (uint8_t *)&clk, &firstClockEdge);
if (ans && ((fc1 == 10 && fc2 == 8) || (fc1 == 8 && fc2 == 5))) { if (ans && ((fc1 == 10 && fc2 == 8) || (fc1 == 8 && fc2 == 5))) {
if ( (FSKrawDemod("0 0", false) == PM3_SUCCESS) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { if ((FSKrawDemod("0 0", false) == PM3_SUCCESS) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
tests[hits].modulation = DEMOD_FSK; tests[hits].modulation = DEMOD_FSK;
if (fc1 == 8 && fc2 == 5) if (fc1 == 8 && fc2 == 5)
tests[hits].modulation = DEMOD_FSK1a; tests[hits].modulation = DEMOD_FSK1a;
@ -576,7 +576,7 @@ bool tryDetectModulation(void) {
tests[hits].ST = false; tests[hits].ST = false;
++hits; ++hits;
} }
if ( (FSKrawDemod("0 1", false) == PM3_SUCCESS) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { if ((FSKrawDemod("0 1", false) == PM3_SUCCESS) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
tests[hits].modulation = DEMOD_FSK; tests[hits].modulation = DEMOD_FSK;
if (fc1 == 8 && fc2 == 5) if (fc1 == 8 && fc2 == 5)
tests[hits].modulation = DEMOD_FSK1; tests[hits].modulation = DEMOD_FSK1;
@ -661,7 +661,7 @@ bool tryDetectModulation(void) {
save_restoreGB(GRAPH_SAVE); save_restoreGB(GRAPH_SAVE);
// skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise) // skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise)
CmdLtrim("160"); CmdLtrim("160");
if ( (PSKDemod("0 0 6", false) == PM3_SUCCESS) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) { if ((PSKDemod("0 0 6", false) == PM3_SUCCESS) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {
tests[hits].modulation = DEMOD_PSK1; tests[hits].modulation = DEMOD_PSK1;
tests[hits].bitrate = bitRate; tests[hits].bitrate = bitRate;
tests[hits].inverted = false; tests[hits].inverted = false;
@ -1538,7 +1538,7 @@ bool AquireData(uint8_t page, uint8_t block, bool pwdmode, uint32_t password) {
payload.pwdmode = pwdmode; payload.pwdmode = pwdmode;
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_T55XX_READ_BLOCK, (uint8_t*)&payload, sizeof(payload)); SendCommandNG(CMD_T55XX_READ_BLOCK, (uint8_t *)&payload, sizeof(payload));
if (!WaitForResponseTimeout(CMD_T55XX_READ_BLOCK, NULL, 2500)) { if (!WaitForResponseTimeout(CMD_T55XX_READ_BLOCK, NULL, 2500)) {
PrintAndLogEx(WARNING, "command execution time out"); PrintAndLogEx(WARNING, "command execution time out");
return false; return false;

View file

@ -312,7 +312,7 @@ static int CmdUsartBtFactory(const char *Cmd) {
PrintAndLogEx(WARNING, _RED_("WARNING: process only if strictly needed!")); PrintAndLogEx(WARNING, _RED_("WARNING: process only if strictly needed!"));
PrintAndLogEx(WARNING, "This requires BT turned ON and NOT connected!"); PrintAndLogEx(WARNING, "This requires BT turned ON and NOT connected!");
PrintAndLogEx(WARNING, "Is the add-on blue light blinking? (Say 'n' if you want to abort) [y/n]"); PrintAndLogEx(WARNING, "Is the add-on blue light blinking? (Say 'n' if you want to abort) [y/n]");
while(!ukbhit()) { while (!ukbhit()) {
msleep(200); msleep(200);
} }
@ -450,7 +450,7 @@ static int CmdUsartBtFactory(const char *Cmd) {
if ((baudrate != USART_BAUD_RATE) || (parity != USART_PARITY)) { if ((baudrate != USART_BAUD_RATE) || (parity != USART_PARITY)) {
PrintAndLogEx(WARNING, "Add-on uart settings changed, please turn BT add-on OFF and ON again, then press any key."); PrintAndLogEx(WARNING, "Add-on uart settings changed, please turn BT add-on OFF and ON again, then press any key.");
while(!ukbhit()) { while (!ukbhit()) {
msleep(200); msleep(200);
} }
int gc = getchar(); int gc = getchar();

View file

@ -111,7 +111,7 @@ void convertGraphFromBitstreamEx(int hi, int low) {
for (int i = 0; i < GraphTraceLen; i++) { for (int i = 0; i < GraphTraceLen; i++) {
if (GraphBuffer[i] == hi) if (GraphBuffer[i] == hi)
GraphBuffer[i] = 127; GraphBuffer[i] = 127;
else if ( GraphBuffer[i] == low ) else if (GraphBuffer[i] == low)
GraphBuffer[i] = -127; GraphBuffer[i] = -127;
else else
GraphBuffer[i] = 0; GraphBuffer[i] = 0;

View file

@ -460,7 +460,7 @@ int mfEmlGetMem(uint8_t *data, int blockNum, int blocksCount) {
payload.blockcnt = blocksCount; payload.blockcnt = blocksCount;
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_MIFARE_EML_MEMGET, (uint8_t*)&payload, sizeof(payload)); SendCommandNG(CMD_MIFARE_EML_MEMGET, (uint8_t *)&payload, sizeof(payload));
PacketResponseNG resp; PacketResponseNG resp;
if (WaitForResponseTimeout(CMD_MIFARE_EML_MEMGET, &resp, 1500) == 0) { if (WaitForResponseTimeout(CMD_MIFARE_EML_MEMGET, &resp, 1500) == 0) {
@ -499,7 +499,7 @@ int mfEmlSetMem_xt(uint8_t *data, int blockNum, int blocksCount, int blockBtWidt
memcpy(payload->data, data, size); memcpy(payload->data, data, size);
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_MIFARE_EML_MEMSET, (uint8_t*)payload, sizeof(payload) + size ); SendCommandNG(CMD_MIFARE_EML_MEMSET, (uint8_t *)payload, sizeof(payload) + size);
return PM3_SUCCESS; return PM3_SUCCESS;
} }
@ -963,7 +963,7 @@ int detect_classic_nackbug(bool verbose) {
if (WaitForResponseTimeout(CMD_MIFARE_NACK_DETECT, &resp, 500)) { if (WaitForResponseTimeout(CMD_MIFARE_NACK_DETECT, &resp, 500)) {
if ( resp.status == PM3_EOPABORTED ) { if (resp.status == PM3_EOPABORTED) {
PrintAndLogEx(WARNING, "button pressed. Aborted."); PrintAndLogEx(WARNING, "button pressed. Aborted.");
return PM3_EOPABORTED; return PM3_EOPABORTED;
} }
@ -1018,7 +1018,7 @@ void detect_classic_magic(void) {
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_MIFARE_CIDENT, NULL, 0); SendCommandNG(CMD_MIFARE_CIDENT, NULL, 0);
if (WaitForResponseTimeout(CMD_MIFARE_CIDENT, &resp, 1500)) { if (WaitForResponseTimeout(CMD_MIFARE_CIDENT, &resp, 1500)) {
if ( resp.status == PM3_SUCCESS ) if (resp.status == PM3_SUCCESS)
isGeneration = resp.data.asBytes[0]; isGeneration = resp.data.asBytes[0];
} }

View file

@ -160,12 +160,11 @@ main_loop(char *script_cmds_file, char *script_cmd) {
} else { } else {
rl_event_hook = check_comm; rl_event_hook = check_comm;
if (session.pm3_present) { if (session.pm3_present) {
if ( conn.send_via_fpc_usart == false ) if (conn.send_via_fpc_usart == false)
cmd = readline(PROXPROMPT_USB); cmd = readline(PROXPROMPT_USB);
else else
cmd = readline(PROXPROMPT_FPC); cmd = readline(PROXPROMPT_FPC);
} } else
else
cmd = readline(PROXPROMPT_OFFLINE); cmd = readline(PROXPROMPT_OFFLINE);
fflush(NULL); fflush(NULL);

View file

@ -1467,7 +1467,7 @@ static uint16_t cleanAskRawDemod(uint8_t *bits, size_t *size, int clk, int inver
} else if (bits[i] <= low && !waveHigh) { } else if (bits[i] <= low && !waveHigh) {
smplCnt++; smplCnt++;
} else { } else {
//transition //transition
if ((bits[i] >= high && !waveHigh) || (bits[i] <= low && waveHigh)) { if ((bits[i] >= high && !waveHigh) || (bits[i] <= low && waveHigh)) {
// 8 :: 8-2-1 = 5 8+2+1 = 11 // 8 :: 8-2-1 = 5 8+2+1 = 11
@ -1490,7 +1490,7 @@ static uint16_t cleanAskRawDemod(uint8_t *bits, size_t *size, int clk, int inver
} }
if (*startIdx == 0) { if (*startIdx == 0) {
*startIdx = i - clk; *startIdx = i - clk;
prnt("DEBUG ASK: cleanAskRawDemod minus clock [%d]", *startIdx); prnt("DEBUG ASK: cleanAskRawDemod minus clock [%d]", *startIdx);
} }
waveHigh = !waveHigh; waveHigh = !waveHigh;
smplCnt = 0; smplCnt = 0;
@ -1511,7 +1511,7 @@ static uint16_t cleanAskRawDemod(uint8_t *bits, size_t *size, int clk, int inver
} }
if (*startIdx == 0) { if (*startIdx == 0) {
*startIdx = i - cl_2; *startIdx = i - cl_2;
prnt("DEBUG ASK: cleanAskRawDemod minus half clock [%d]", *startIdx); prnt("DEBUG ASK: cleanAskRawDemod minus half clock [%d]", *startIdx);
} }
waveHigh = !waveHigh; waveHigh = !waveHigh;
smplCnt = 0; smplCnt = 0;
@ -1527,10 +1527,10 @@ static uint16_t cleanAskRawDemod(uint8_t *bits, size_t *size, int clk, int inver
*size = bitCnt; *size = bitCnt;
/* /*
if (*startIdx < 0) if (*startIdx < 0)
*startIdx = 0; *startIdx = 0;
*/ */
if (g_debugMode == 2) prnt("DEBUG ASK: cleanAskRawDemod Startidx %d", *startIdx); if (g_debugMode == 2) prnt("DEBUG ASK: cleanAskRawDemod Startidx %d", *startIdx);

View file

@ -199,7 +199,7 @@ void usart_init(uint32_t baudrate, uint8_t parity) {
AT91C_US_NBSTOP_1_BIT | // 1 stop bit AT91C_US_NBSTOP_1_BIT | // 1 stop bit
AT91C_US_CHMODE_NORMAL; // channel mode: normal AT91C_US_CHMODE_NORMAL; // channel mode: normal
switch(usart_parity) { switch (usart_parity) {
case 'N': case 'N':
mode |= AT91C_US_PAR_NONE; // parity: none mode |= AT91C_US_PAR_NONE; // parity: none
break; break;
@ -231,9 +231,9 @@ void usart_init(uint32_t baudrate, uint8_t parity) {
// //
uint32_t brgr = 48000000 / (usart_baudrate << 3); uint32_t brgr = 48000000 / (usart_baudrate << 3);
// doing fp = round((mck / (usart_baudrate << 3) - brgr) * 8) with integers: // doing fp = round((mck / (usart_baudrate << 3) - brgr) * 8) with integers:
uint32_t fp = ((16 * 48000000 / (usart_baudrate << 3) - 16 * brgr)+1)/2; uint32_t fp = ((16 * 48000000 / (usart_baudrate << 3) - 16 * brgr) + 1) / 2;
pUS1->US_BRGR = (fp << 16) | brgr; pUS1->US_BRGR = (fp << 16) | brgr;
// Write the Timeguard Register // Write the Timeguard Register
pUS1->US_TTGR = 0; pUS1->US_TTGR = 0;

View file

@ -204,9 +204,9 @@ typedef struct {
} PACKED lf_psksim_t; } PACKED lf_psksim_t;
typedef struct { typedef struct {
uint8_t blockno; uint8_t blockno;
uint8_t keytype; uint8_t keytype;
uint8_t key[6]; uint8_t key[6];
} PACKED mf_readblock_t; } PACKED mf_readblock_t;

View file

@ -112,7 +112,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
struct addrinfo info; struct addrinfo info;
memset (&info, 0, sizeof(info)); memset(&info, 0, sizeof(info));
info.ai_socktype = SOCK_STREAM; info.ai_socktype = SOCK_STREAM;
@ -249,7 +249,7 @@ int uart_receive(const serial_port sp, uint8_t *pbtRx, uint32_t pszMaxRxLen, uin
fd_set rfds; fd_set rfds;
struct timeval tv; struct timeval tv;
if ( newtimeout_pending ) { if (newtimeout_pending) {
timeout.tv_usec = newtimeout_value * 1000; timeout.tv_usec = newtimeout_value * 1000;
newtimeout_pending = false; newtimeout_pending = false;
} }

View file

@ -58,7 +58,7 @@ int uart_reconfigure_timeouts(uint32_t value) {
} }
static int uart_reconfigure_timeouts_polling(serial_port sp) { static int uart_reconfigure_timeouts_polling(serial_port sp) {
if ( newtimeout_pending == false ) if (newtimeout_pending == false)
return PM3_SUCCESS; return PM3_SUCCESS;
newtimeout_pending = false; newtimeout_pending = false;