]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/i2c.c
fido fix (#775)
[proxmark3-svn] / armsrc / i2c.c
index bd22e19aa4540b1da70b485caf23e4306530c8f2..7ef0c9c035ce767bfe8cd39b7f4e6a2cec021d5e 100644 (file)
@@ -656,28 +656,6 @@ static bool GetATR(smart_card_atr_t *card_ptr) {
        if ( !sc_rx_bytes(card_ptr->atr, &len) )                
                return false;
 
-       uint8_t pos_td = 1;
-       if ( (card_ptr->atr[1] & 0x10) == 0x10) pos_td++;
-       if ( (card_ptr->atr[1] & 0x20) == 0x20) pos_td++;
-       if ( (card_ptr->atr[1] & 0x40) == 0x40) pos_td++;
-       
-       // T0 indicate presence T=0 vs T=1.  T=1 has checksum TCK
-       if ( (card_ptr->atr[1] & 0x80) == 0x80) {
-               
-               pos_td++;
-       
-               // 1 == T1 ,  presence of checksum TCK
-               if ( (card_ptr->atr[pos_td] & 0x01) == 0x01) {
-                       uint8_t chksum = 0;
-                       // xor property.  will be zero when xored with chksum.
-                       for (uint8_t i = 1; i < len; ++i)
-                               chksum ^= card_ptr->atr[i];
-                       if ( chksum ) {
-                               if ( MF_DBGLEVEL > 2) DbpString("Wrong ATR checksum");
-                       }
-               }
-       }
-
        card_ptr->atr_len = len;
        LogTrace(card_ptr->atr, card_ptr->atr_len, 0, 0, NULL, false);
 
@@ -713,7 +691,7 @@ void SmartCardRaw( uint64_t arg0, uint64_t arg1, uint8_t *data ) {
 
                I2C_Reset_EnterMainProgram();
 
-               if (flags & SC_SELECT) {
+               if ((flags & SC_SELECT)) {
                        smart_card_atr_t card;
                        bool gotATR = GetATR( &card );
                        //cmd_send(CMD_ACK, gotATR, sizeof(smart_card_atr_t), 0, &card, sizeof(smart_card_atr_t));
@@ -722,14 +700,14 @@ void SmartCardRaw( uint64_t arg0, uint64_t arg1, uint8_t *data ) {
                }
        }
 
-       if ((flags & SC_RAW)) {
+       if ((flags & SC_RAW) || (flags & SC_RAW_T0)) {
 
                LogTrace(data, arg1, 0, 0, NULL, true);
 
                // Send raw bytes
                // asBytes = A0 A4 00 00 02
                // arg1 = len 5
-               bool res = I2C_BufferWrite(data, arg1, I2C_DEVICE_CMD_SEND, I2C_DEVICE_ADDRESS_MAIN);
+               bool res = I2C_BufferWrite(data, arg1, ((flags & SC_RAW_T0) ? I2C_DEVICE_CMD_SEND_T0 : I2C_DEVICE_CMD_SEND), I2C_DEVICE_ADDRESS_MAIN);
                if ( !res && MF_DBGLEVEL > 3 ) DbpString(I2C_ERROR);
 
                // read bytes from module
Impressum, Datenschutz