首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Mifare认证

Mifare认证
EN

Stack Overflow用户
提问于 2013-09-16 09:42:33
回答 2查看 15.4K关注 0票数 4

说我想要认证米法瑞经典。

我怎么知道要发送到卡片上的APDU的确切类型?

示例.

此代码:

代码语言:javascript
复制
bcla = 0xFF;
bins = 0x86;
bp1 =  0x0;
bp2 =  0x0; // currentBlock
len =  0x5;

sendBuffer[0] = bcla;
sendBuffer[1] = bins;
sendBuffer[2] = bp1;
sendBuffer[3] = bp2;
sendBuffer[4] = len;
sendBuffer[5] = 0x1;                // Version
sendBuffer[6] = 0x0;                // Address MSB
sendBuffer[7] = currentBlock;
if(keyradioButton->Checked==true)   // Address LSB
     sendBuffer[8] = 0x60;              // Key Type A
else if(keynumberradioButton->Checked ==true)
    sendBuffer[8] = 0x61;               // Key Type B
sendBuffer[9] = keynumber;          // Key Number

sendbufferlen = 0xA;
receivebufferlen = 255;

//Invoke the Transmit command
retval = SCardTransmit(hCard,  // A reference value returned from the SCardConnect function.
                                 &sioreq, 
                              sendBuffer,  // Send buffer
                           sendbufferlen,  // Send buffer length
                                 &rioreq, 
                           receiveBuffer,  // Receive butter
                      &receivebufferlen);  // Length of received buffer

是一个试图验证Mifare经典的示例程序。我的问题基本上是,我怎么知道怎样发送什么样的APDU到卡?我如何知道在sendBuffer中应该是什么

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-09-16 11:47:27

阅读此文章.Here,您将发现APDU结构与Mifare卡通信.

票数 3
EN

Stack Overflow用户

发布于 2015-01-31 19:45:11

在Mifare经典1K标记中,有16个扇区,每个扇区包含4个块,每个扇区包含16个字节。

  1. 0区包含区块(0、1、2、3)
  2. 第1区为区块(4、5、6、7)
  3. 第2区为区块(8、9、10、11)
  4. 第3区为区块(12、13、14、15)。

在读取或写入块之前,您必须使用该扇区的键A或键B验证其相应的扇区。当身份验证完成后,您就可以读写了。使用此命令,您可以使用键A(60)验证扇区0。

代码语言:javascript
复制
byte[] authenticationByte = new byte[10];  

authenticationByte = new byte[] { (byte) 0xFF, (byte) 0x86, (byte) 0x00,
 (byte) 0x00, (byte) 0x05, (byte) 0x00,(byte) 0x00, (byte) 0x04, 
                                    (byte) 0x60,(byte) 0x00 };

当身份验证成功时,您将得到9000。这就是成功的信息。否则响应为63 00,这意味着身份验证失败。当身份验证完成后,您可以读取块(0、1、2、3),因为扇区0包含4个块,而这些块是块(0、1、2、3)。

有关更多细节,您可以阅读这个答案。抱歉英语不太好

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18824879

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档