]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/mifaredesfire.c
FIX: @tony pointed out that there was a method name lost... its been reinstated :)
[proxmark3-svn] / armsrc / mifaredesfire.c
index 5737615106c9a0cddd2d8a92d3763807c97d6b01..b1e035f9a7ca2ea2fea1153682b2e3524c46e632 100644 (file)
@@ -1,5 +1,6 @@
 #include "mifaredesfire.h"
 #include "des.h"
 #include "mifaredesfire.h"
 #include "des.h"
+#include "BigBuf.h"
 
 #define MAX_APPLICATION_COUNT 28
 #define MAX_FILE_COUNT 16
 
 #define MAX_APPLICATION_COUNT 28
 #define MAX_FILE_COUNT 16
@@ -18,13 +19,12 @@ static  uint8_t deselect_cmd[] = {0xc2,0xe0,0xb4};
 //static uint8_t __res[MAX_FRAME_SIZE];
 
 bool InitDesfireCard(){
 //static uint8_t __res[MAX_FRAME_SIZE];
 
 bool InitDesfireCard(){
-       
-       byte_t cardbuf[USB_CMD_DATA_SIZE] = {0x00};
 
 
-       iso14a_card_select_t *card = (iso14a_card_select_t*)cardbuf;
-       
-       iso14a_set_tracing(TRUE);
        iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
        iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
+       set_tracing(TRUE);
+
+       byte_t cardbuf[USB_CMD_DATA_SIZE] = {0x00};
+       iso14a_card_select_t *card = (iso14a_card_select_t*)cardbuf;
        
        int len = iso14443a_select_card(NULL,card,NULL);
 
        
        int len = iso14443a_select_card(NULL,card,NULL);
 
@@ -65,7 +65,7 @@ void MifareSendCommand(uint8_t arg0, uint8_t arg1, uint8_t *datain){
        }
        
        if ( flags & CLEARTRACE ){
        }
        
        if ( flags & CLEARTRACE ){
-               iso14a_clear_trace();
+               clear_trace();
        }
        
        if ( flags & INIT ){
        }
        
        if ( flags & INIT ){
@@ -109,8 +109,8 @@ void MifareDesfireGetInformation(){
                PCB == 0x0A because sending CID byte.
                CID == 0x00 first card?         
        */
                PCB == 0x0A because sending CID byte.
                CID == 0x00 first card?         
        */
-       iso14a_clear_trace();
-       iso14a_set_tracing(TRUE);
+       clear_trace();
+       set_tracing(TRUE);
        iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
 
        // card select - information
        iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
 
        // card select - information
@@ -432,10 +432,10 @@ int DesfireAPDU(uint8_t *cmd, size_t cmd_len, uint8_t *dataout){
 
        size_t len = 0;
        size_t wrappedLen = 0;
 
        size_t len = 0;
        size_t wrappedLen = 0;
-       uint8_t wCmd[USB_CMD_DATA_SIZE] = {0};
+       uint8_t wCmd[USB_CMD_DATA_SIZE] = {0x00};
        
        
-       uint8_t *resp = ((uint8_t *)BigBuf) + RECV_RESP_OFFSET;
-    uint8_t *resp_par = ((uint8_t *)BigBuf) + RECV_RESP_PAR_OFFSET;
+       uint8_t resp[MAX_FRAME_SIZE];
+    uint8_t par[MAX_PARITY_SIZE];
        
        wrappedLen = CreateAPDU( cmd, cmd_len, wCmd);
        
        
        wrappedLen = CreateAPDU( cmd, cmd_len, wCmd);
        
@@ -444,12 +444,10 @@ int DesfireAPDU(uint8_t *cmd, size_t cmd_len, uint8_t *dataout){
        }
        ReaderTransmit( wCmd, wrappedLen, NULL);
 
        }
        ReaderTransmit( wCmd, wrappedLen, NULL);
 
-       len = ReaderReceive(resp, resp_par);
+       len = ReaderReceive(resp, par);
        
        if( len == 0x00 ){
        
        if( len == 0x00 ){
-               if (MF_DBGLEVEL >= 4) {
-                       Dbprintf("fukked");
-               }
+               if (MF_DBGLEVEL >= 4) Dbprintf("fukked");
                return FALSE; //DATA LINK ERROR
        }
        // if we received an I- or R(ACK)-Block with a block number equal to the
                return FALSE; //DATA LINK ERROR
        }
        // if we received an I- or R(ACK)-Block with a block number equal to the
@@ -496,12 +494,15 @@ void OnSuccess(){
        ReaderTransmit(deselect_cmd, 3 , NULL);
        FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
        LEDsoff();
        ReaderTransmit(deselect_cmd, 3 , NULL);
        FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
        LEDsoff();
+       set_tracing(FALSE);     
 }
 
 void OnError(uint8_t reason){
        pcb_blocknum = 0;
        ReaderTransmit(deselect_cmd, 3 , NULL);
 }
 
 void OnError(uint8_t reason){
        pcb_blocknum = 0;
        ReaderTransmit(deselect_cmd, 3 , NULL);
+       
        FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
        cmd_send(CMD_ACK,0,reason,0,0,0);
        LEDsoff();
        FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
        cmd_send(CMD_ACK,0,reason,0,0,0);
        LEDsoff();
+       set_tracing(FALSE);     
 }
 }
Impressum, Datenschutz