2012-05-02 79 views
0

我正在嘗試驗證MIFARE經典卡的任何部分。我正在使用twinlinx mymax貼紙(這使得幾乎所有的藍牙設備NFC都可以使用)。它將命令發送到連接的NFC標籤。我已經建立了連接,並使用Ultralight C標籤發送和接收數據,但到目前爲止,我沒有成功訪問過Mifare Classic。以下是我的驗證碼:MIFARE CLASSIC沒有迴應

private boolean authenticate(int sector, byte[] key, boolean keyA) { 

    byte[] cmd = new byte[12]; 

    // First byte is the command 
    if (keyA) { 
     cmd[0] = 0x60; // phHal_eMifareAuthentA 
    } else { 
     cmd[0] = 0x61; // phHal_eMifareAuthentB 
    } 

    // Second byte is block address 
    cmd[1] = (byte) 0x03; 

    // Next 6 bytes are the key 
    System.arraycopy(key, 0, cmd, 2, 6); 

    // Next 4 bytes is the UID 
    System.arraycopy(Answer, 3, cmd, 8,4); 

    byte[] test = null; 

    //this makes a connection to the NFC tag (and this works) 
    TR.ConnectToExternalCard(AUTH, (byte)0x00); 

    //checking if the tag is still connected 
    if (TR.isCardPresent() == true){ 

    //sending command to authenticate 
    test = TR.SendCommandPropAndWaitResponse(cmd, (byte) 0x00); 
    } 

    try { 
     if (test != null) { 

      return true; 
     } 
    } 

我使用的是標準MIFARE Classic鍵,標籤是從工廠新鮮出來的。完整的命令(以字節爲單位),其被髮送到標籤是:

[0x60的,0x3,0xff的,0xff的,0xff的,0xff的,0xff的,0xff的,0xf3,0xF4中,0xa9,0xFB的才能]

任何想法?該標籤似乎沒有響應...嘗試訪問其他經典標籤,但也沒有成功。謝謝!

回答

0

使用未公開提供的SDK很難說出錯。但是,API看起來很熟悉,所以我會試一試。我可以考慮一些你可能嘗試的事情(按照可能性的降序排列):

  1. UID字節可能是錯誤的順序,所以請嘗試反轉它們。
  2. 或許Answer不僅包含UID,還包含其他字節(例如SAK),並且您正在從中複製錯誤的字節。
  3. 您擁有的MIFARE Classic標籤可能有一個7字節的UID,並且您沒有使用正確的4字節。可能是TR.SendCommandPropAndWaitResponse()是錯誤的使用方法。也許MIFARE Classic有專門的方法。
  4. MyMax貼紙可能不支持MIFARE Classic。我沒有在他們的網站上看到他們明確的確認。然而,跡象表明,他們的解決方案基於恩智浦的硬件,它始終支持MIFARE Classic。