简体   繁体   English

使用 pyscard 发送 APDU 命令时出现问题

[英]Problem sending an APDU command with pyscard

I am developing a simple application involving an ACR1251 smart card reader.我正在开发一个涉及 ACR1251 智能卡读卡器的简单应用程序。 Currently I don't have it with me, but it's a time-sensitive project, so I'm using vsmartcard to emulate a reader and a ISO 7816 card.目前我没有它,但它是一个时间敏感的项目,所以我正在使用vsmartcard来模拟读卡器和 ISO 7816 卡。

The code I'm having problems with is:我遇到问题的代码是:

from smartcard.System import readers

reader = readers()[0]
conn = reader.createConnection()
conn.connect()
response, sw1, sw2 = conn.transmit([0xFF, 0xCA, 0x00, 0x00, 0x00]) # Get Data UID

The response codes are 0x69 0x88, that mean "Incorrect secure messaging (SM) data object".响应代码为 0x69 0x88,表示“不正确的安全消息 (SM) 数据对象”。 I haven't found anything mentioning SM in pyscard's documentation, and googling wasn't successful either.我在 pyscard 的文档中没有发现任何提及 SM 的内容,谷歌搜索也不成功。

Am I missing something in my code?我的代码中遗漏了什么吗? This is definitely possible, as I am trying to do this in the simplest way possible and pyscard is quite low level, and the documentation is not really aimed at doing simple things.这绝对是可能的,因为我试图以最简单的方式做到这一点,而 pyscard 的级别很低,而且文档并不是真正旨在做简单的事情。

Also it could be a problem with the emulator, in that case I guess I'd just have to wait for customs to process the reader.也可能是模拟器的问题,那样的话我想我只需要等待海关处理读者。

For a card compatible with the ISO 7816-standard family (parts 4, 8 and 9 are essential), your specified class byte of 0xFF in fact indicates secure messaging, which is in contradiction with the remaining bytes (too short for a MAC)对于与 ISO 7816 标准系列兼容的卡(第 4、8 和 9 部分是必不可少的),您指定的 class 字节的 0xFF 实际上表示安全消息传递,这与其余字节相矛盾(对于 MAC 来说太短)

The APDU you give looks more like the pseudo-APDU to address non-processor card as eg MIFARE or to sent a command to the reader (as opposed to the card);您提供的 APDU 看起来更像是伪 APDU,用于寻址非处理器卡,例如 MIFARE 或向读卡器(而不是卡)发送命令; there is considerable overlap of this possibilities.这种可能性有相当大的重叠。

As a first step you could try other class byte values, 0x00 (pure ISO) and 0xA0 (GSM-heritage) being the the most promising.作为第一步,您可以尝试其他 class 字节值,0x00(纯 ISO)和 0xA0(GSM-heritage)是最有希望的。 The structure of the class byte is explained in 7816, part 4. class 字节的结构在 7816 第 4 部分中有解释。

The supported commands should be in the card user's manual, and even if you manage to get the Get Data to succeed,you will need it urgently later for more complex functionality.支持的命令应该在卡的用户手册中,即使你设法让获取数据成功,你以后也会迫切需要它来实现更复杂的功能。 (Should you think, that ISO 7816 cards are generic or seriously compatible among each others: wrong and there is is no "generic 7816" card in the real world.) (您是否认为 ISO 7816 卡是通用的或彼此之间严重兼容:错误,现实世界中没有“通用 7816”卡。)

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

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