CHG: Syntax suger

This commit is contained in:
iceman1001 2016-01-25 20:19:15 +01:00
parent da198be4b5
commit 65c2d21d05
3 changed files with 15 additions and 20 deletions

View file

@ -276,10 +276,10 @@ static void frame_receive_rwd(struct legic_frame * const f, int bits, int crypt)
static void frame_append_bit(struct legic_frame * const f, int bit)
{
if(f->bits >= 31)
if (f->bits >= 31)
return; /* Overflow, won't happen */
f->data |= (bit<<f->bits);
f->data |= (bit << f->bits);
f->bits++;
}
@ -354,9 +354,11 @@ int legic_read_byte(int byte_index, int cmd_sz) {
frame_receive_rwd(&current_frame, 12, 1);
byte = current_frame.data & 0xff;
if( LegicCRC(byte_index, byte, cmd_sz) != (current_frame.data >> 8) ) {
Dbprintf("!!! crc mismatch: expected %x but got %x !!!",
LegicCRC(byte_index, current_frame.data & 0xff, cmd_sz), current_frame.data >> 8);
LegicCRC(byte_index, current_frame.data & 0xff, cmd_sz),
current_frame.data >> 8);
return -1;
}
@ -372,9 +374,8 @@ int legic_read_byte(int byte_index, int cmd_sz) {
*/
int legic_write_byte(int byte, int addr, int addr_sz) {
//do not write UID, CRC, DCF
if(addr <= 0x06) {
if(addr <= 0x06)
return 0;
}
//== send write command ==============================
crc_clear(&legic_crc);

View file

@ -996,32 +996,26 @@ void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
set_tracing(TRUE);
for (i = 0; i < keyCount; i++) {
if(mifare_classic_halt(pcs, cuid)) {
for (i = 0; i < keyCount; ++i) {
if (mifare_classic_halt(pcs, cuid))
if (MF_DBGLEVEL >= 1) Dbprintf("ChkKeys: Halt error");
}
if(!iso14443a_select_card(uid, NULL, &cuid, true, 0)) {
if (!iso14443a_select_card(uid, NULL, &cuid, true, 0)) {
if (OLD_MF_DBGLEVEL >= 1) Dbprintf("ChkKeys: Can't select card");
break;
};
}
ui64Key = bytes_to_num(datain + i * 6, 6);
if(mifare_classic_auth(pcs, cuid, blockNo, keyType, ui64Key, AUTH_FIRST)) {
if (mifare_classic_auth(pcs, cuid, blockNo, keyType, ui64Key, AUTH_FIRST))
continue;
};
isOK = 1;
break;
}
// ----------------------------- crypto1 destroy
crypto1_destroy(pcs);
LED_B_ON();
cmd_send(CMD_ACK,isOK,0,0,datain + i * 6,6);
LED_B_OFF();
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
LEDsoff();
set_tracing(FALSE);

View file

@ -13,11 +13,11 @@
static int sniffState = SNF_INIT;
static uint8_t sniffUIDType;
static uint8_t sniffUID[8] = {0x00};
static uint8_t sniffATQA[2] = {0x00};
static uint8_t sniffUID[8];
static uint8_t sniffATQA[2];
static uint8_t sniffSAK;
static uint8_t sniffBuf[16] = {0x00};
static uint32_t timerData = 0;
static uint8_t sniffBuf[16];
static uint32_t timerData;
bool MfSniffInit(void){