简体   繁体   English

如何区分不同的ISO 14443-4卡?

[英]How do I distinguish different ISO 14443-4 cards?

There are different smart cards supporting ISO 14443-4. 有不同的智能卡支持ISO 14443-4。 For example, Mifare Plus with its native command set. 例如,Mifare Plus及其本机命令集。 Or other cards with different command sets (ie 7816-4 APDUs). 或其他具有不同命令集的卡(即7816-4 APDU)。

I develop some software for a card reader and I need to identify which commands the card supports (for example, if it supports commands in ISO 7816-4 structure or not). 我为读卡器开发了一些软件,我需要确定卡支持哪些命令(例如,它是否支持ISO 7816-4结构中的命令)。

What is the recommended way to distinguish between them? 建议区分它们的方法是什么? Should I just try some commands from Mifare Plus command set and check if I get correct replies? 我应该从Mifare Plus命令集中尝试一些命令并检查我是否得到正确的回复? Or is there any smarter way to do it? 或者有更聪明的方法吗?

During the connection protocol some parameters are exchanged that you can use to determine the card's capabilities. 在连接协议期间,会交换一些参数,您可以使用这些参数来确定卡的功能。 For example, the SAK byte will inform the reader whether the card is ISO 14443-4, and even if it is MIFARE Plus (there is an NXP document explaining which bits you have to read). 例如,SAK字节将通知读卡器该卡是否为ISO 14443-4,即使它是MIFARE Plus(还有一个NXP文档说明您必须阅读哪些位)。 Then you have ATS (Answer To Select), which contains a lot of useful information about the card. 然后你有ATS(选择答案),它包含很多关于卡的有用信息。 Have a look at ISO 14443-4 and at ISO 7816-4. 看看ISO 14443-4和ISO 7816-4。

Never use ATQ! 永远不要使用ATQ! Use SAK only for non 14443-4 cards(eg Mifare Classic)! 仅将SAK用于非14443-4卡(例如Mifare Classic)! ATS is also bad practice as different card vendor can set it differently. ATS也是不好的做法,因为不同的卡供应商可以设置不同的方式。

Now how to do it: 现在该怎么做:

Only way how to think about card and don't get crazy is imagine it like it is full communication stack(see OSI model). 唯一的方法是如何考虑卡而不要发疯,想象它就像是完整的通信堆栈(参见OSI模型)。

Keep in mind that your goal is to connect two applications, one in the card and one in your computer. 请记住,您的目标是连接两个应用程序,一个在卡中,一个在您的计算机中。 14443-4 provides mechanism for sending messages and don't care about its content. 14443-4提供了发送消息的机制,而不关心其内容。

On top of it there are implemented interfaces of different cards and if both sides: card - carddriver are compatible they will communicate. 最重要的是它实现了不同卡的接口,如果双方:卡 - 卡驱动器兼容,他们将进行通信。 If not, there will be errors on that level. 如果没有,那么该级别就会出现错误。 So you know you will need to use different card driver. 所以你知道你需要使用不同的卡驱动程序。

Complete communication stack will look like this: 完整的通信堆栈将如下所示:

  Your Application 
  |  CardProtocol/7816-4 
  |  |  14443-4 
  |  |  |  14443 
  |  |  |  |  radio waves 
  |  |  |  14443 (in card) 
  |  |  14443-4 (in card) 
  |  CardProtocol/7816-4 (in card) 
  Application/Appdata (in card)

Of course between every layer has to be some interface. 当然每个层之间必须有一些接口。

If you have two applications which wants to communicate try one and then try second. 如果你有两个想要通信的应用程序尝试一个,然后尝试第二个。

error on application level => there is no compatible application on card 应用程序级错误=>卡上没有兼容的应用程序

error on CardProtocol level => there is not compatible card CardProtocol级别错误=>没有兼容的卡

Point is your communication has to succed on all levels so don't worry to try to communicate with card by not compatible protocol - if you (by some miracle) will not get error on CardProtocol level you will definitely get one on your application level and result will be same. 点是您的通信必须在所有级别上取得成功所以不要担心尝试通过不兼容的协议与卡通信 - 如果您(通过一些奇迹)不会在CardProtocol级别上获得错误,您肯定会在您的应用程序级别获得一个结果会一样。 Good Luck! 祝好运!

PS There are some more complex situations like "one app over two protocols/types of cards" but they can be handled easily too. PS有一些更复杂的情况,如“一个应用程序超过两个协议/类型的卡”,但它们也可以轻松处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM