0

我正在尝试验证 MIFARE 经典卡的任何扇区。我正在使用 twinlinx mymax 贴纸(几乎可以启用任何蓝牙设备 NFC)。它将命令发送到连接的 NFC 标签。我已经使用 Ultralight C 标签建立了连接并发送和接收了数据,但到目前为止,我还没有成功访问 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]

有任何想法吗?该标签似乎没有响应...尝试访问其他经典标签但也没有成功。谢谢!

4

1 回答 1

0

使用不公开的 SDK 很难说你做错了什么。但是,API 看起来很熟悉,所以无论如何我都会尝试一下。我可以想到一些你可以尝试的事情(按可能性降序排列):

  1. UID 字节的顺序可能有误,因此请尝试颠倒它们。
  2. 也许Answer不仅包含 UID,还包含其他字节(例如 SAK),并且您从中复制了错误的字节。
  3. 您拥有的 MIFARE Classic 标签可能有一个 7 字节的 UID,而您没有使用正确的 4 个字节。
  4. 可能TR.SendCommandPropAndWaitResponse()是使用错误的方法。或许 MIFARE Classic 有专门的方法。
  5. MyMax 贴纸可能不支持 MIFARE Classic。我没有在他们的网站上看到他们这样做的明确确认。但是,有迹象表明他们的解决方案基于 NXP 硬件,该硬件始终支持 MIFARE Classic。
于 2012-05-02T21:46:46.153 回答