在Mifare Ultralight C上限制写入时读取

时间:2014-09-23 12:06:29

标签: android authentication nfc rfid mifare

我刚收到Mifare Ultralight C.我可以使用Android手机(Galaxy Ace 3)轻松读取它的值。

0 hex: 04 9a 6f 79
1 hex: 52 02 3a 80
2 hex: ea 48 00 00
3 hex: 00 00 00 00
4 hex: 02 00 00 10
5 hex: 00 06 01 10
6 hex: 11 ff 00 00
7 hex: 00 00 00 00
8 hex: 00 00 00 00
9 hex: 00 00 00 00
10 hex: 00 00 00 00
11 hex: 00 00 00 00
12 hex: 00 00 00 00
13 hex: 00 00 00 00
14 hex: 00 00 00 00
15 hex: 00 00 00 00
16 hex: 00 00 00 00
17 hex: 00 00 00 00
18 hex: 00 00 00 00
19 hex: 00 00 00 00
20 hex: 00 00 00 00
21 hex: 00 00 00 00
22 hex: 00 00 00 00
23 hex: 00 00 00 00
24 hex: 00 00 00 00
25 hex: 00 00 00 00
26 hex: 00 00 00 00
27 hex: 00 00 00 00
28 hex: 00 00 00 00
29 hex: 00 00 00 00
30 hex: 00 00 00 00
31 hex: 00 00 00 00
32 hex: 00 00 00 00
33 hex: 00 00 00 00
34 hex: 00 00 00 00
35 hex: 00 00 00 00
36 hex: 00 00 00 00
37 hex: 00 00 00 00
38 hex: 00 00 00 00
39 hex: 00 00 00 00
40 hex: 00 00 00 00
41 hex: 00 00 00 00
42 hex: 30 00 00 00
43 hex: 00 00 00 00

然后我将第43页的值更改为0x80,将第42页的值更改为0x2A。现在,当我以这种方式阅读价值观时:

Log.e(LOG, "read");
for(int j = 0; j <= 40; j += 4){
byte[] resp = mifare.readPages(j);
logResponse(j, resp);


private void logResponse(int j, byte[] resp){
     for(int i = 0; i < resp.length; i += 4){
            Log.e(LOG, String.valueOf(j + i / 4) + " hex: " 
                    + String.format("%02x ", resp[i])
                    + String.format("%02x ", resp[i + 1]) 
                    + String.format("%02x ", resp[i + 2]) 
                    + String.format("%02x", resp[i + 3]));
      }
}

我从第0页和第1页获取值而不是第42页和第43页 接下来就是当我发送消息0x1A00以进行身份​​验证时,我收到了transceive failed
有没有办法检查它是否真的是Mifare Ultralight C或其他标签?或者我错了第43页的值0x80仅限制写访问权限?

1 个答案:

答案 0 :(得分:1)

您从标签中读取的内容看起来好像可能是MIFARE Ultralight C标签(特别是您能够阅读第42和43页)。

  • 将AUTH0设置为42(0x2A)后看到的翻转是预期的行为。即当您从第X页开始保护标签存储器时,READ命令将在第X-1页后翻转。

  • 将AUTH1设置为0x80将无法达到预期效果。只有AUTH1中的最低位是相关的,所以通常将AUTH1设置为0x00(限制读取和写入)或0x01(仅限制写入)。

  • 我不太清楚为什么认证命令会失败。

    byte[] cmd = { (byte)0x1A, (byte)0x00 };
    byte[] result = mifare.transceive(cmd);
    

    通常情况下,如果此命令返回其他任何0xAF(或抛出异常),则表明标签 MIFARE Ultralight C。