X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/9c7c222c035156c33766daec6c635113414eab41..8d0a3e87d7d2350f4a05698a42f57625e460e5d6:/armsrc/mifarecmd.c diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index b84d0484..fc480a38 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -1145,3 +1145,78 @@ void MifareCIdent(){ cmd_send(CMD_ACK,isOK,0,0,0,0); } + // +// DESFIRE +// + +void Mifare_DES_Auth1(uint8_t arg0, uint8_t *datain){ + // variables + byte_t isOK = 0; + byte_t dataoutbuf[16]; + uint8_t uid[10]; + uint32_t cuid; + + // clear trace + iso14a_clear_trace(); + iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN); + + LED_A_ON(); + LED_B_OFF(); + LED_C_OFF(); + + + if(!iso14443a_select_card(uid, NULL, &cuid)) { + if (MF_DBGLEVEL >= 1) Dbprintf("Can't select card, something went wrong before auth"); + }; + + if(mifare_desfire_des_auth1(cuid, dataoutbuf)){ + if (MF_DBGLEVEL >= 1) Dbprintf("Authentication part1: Fail."); + } + + isOK=1; + if (MF_DBGLEVEL >= 2) DbpString("AUTH 1 FINISHED"); + + LED_B_ON(); + cmd_send(CMD_ACK,isOK,cuid,0,dataoutbuf,11); + LED_B_OFF(); + + // Thats it... + //FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); + LEDsoff(); +} + +void Mifare_DES_Auth2(uint32_t arg0, uint8_t *datain){ + // params + uint32_t cuid = arg0; + uint8_t key[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + // variables + byte_t isOK = 0; + byte_t dataoutbuf[16]; + + memcpy(key, datain, 16); + // clear trace + //iso14a_clear_trace(); + //iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN); + + LED_A_ON(); + LED_B_OFF(); + LED_C_OFF(); + +// Dbprintf("Sending %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", +// key[0],key[1],key[2],key[3],key[4],key[5],key[6],key[7],key[8], +// key[9],key[10],key[11],key[12],key[13],key[14],key[15]); + + if(mifare_desfire_des_auth2(cuid, key, dataoutbuf)){ + if (MF_DBGLEVEL >= 1) Dbprintf("Authentication part2: Fail..."); + } + isOK=1; + if (MF_DBGLEVEL >= 2) DbpString("AUTH 2 FINISHED"); + + LED_B_ON(); + cmd_send(CMD_ACK,isOK,0,0,dataoutbuf,12); + LED_B_OFF(); + + // Thats it... + FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); + LEDsoff(); +} \ No newline at end of file