简体   繁体   English

运行某些 APDU 失败,说明无法使用协议 T0 传输。 法尔歇参数

[英]Running certain APDUs fails, stating Failed to transmit with protocol T0. Falscher Parameter

I'm having issues accessing SLE4428 cards under Windows 10 using an ACS ACR38U-I1, Python 3.7 and pyscard.我在使用 ACS ACR38U-I1、Python 3.7 和 pyscard 在 Windows 10 下访问 SLE4428 卡时遇到问题。 I'm using the latest driver the manufacturer currently offers for Windows.我正在使用制造商目前为 Windows 提供的最新驱动程序。

The main problem is that running certain APDUs fails, stating Failed to transmit with protocol T0. Falscher Parameter主要问题是运行某些 APDU 失败,说明Failed to transmit with protocol T0. Falscher Parameter Failed to transmit with protocol T0. Falscher Parameter (= wrong parameter, error code 87). Failed to transmit with protocol T0. Falscher Parameter (= 错误的参数,错误代码 87)。 Running the exact same code with the same reader on a Raspberry Pi works flawlessly however.然而,在 Raspberry Pi 上使用相同的阅读器运行完全相同的代码可以完美运行。 I have not installed any specific drivers on the Pi.我没有在 Pi 上安装任何特定的驱动程序。

I'm using this code for running APDUs:我正在使用此代码运行 APDU:

    from smartcard.CardType import AnyCardType
    from smartcard.CardConnection import CardConnection
    from smartcard.CardRequest import CardRequest
    
    cardtype = AnyCardType()
    cardrequest = CardRequest(timeout=1, cardType=cardtype)
    cardservice = cardrequest.waitforcard()
    cardservice.connection.connect(CardConnection.T0_protocol)
    apdu = [0xff, 0xb0, 0x00, 0x00, 0xff] #READ_MEMORY_CARD
    response, sw1, sw2 = cardservice.connection.transmit(apdu, CardConnection.T0_protocol)
    print('response: ', response, ' status words: ', "%x %x" % (sw1, sw2))

This code works fine on both platforms.此代码在两个平台上都可以正常工作。 Trying to authenticate using [0xff, 0x20, 0x00, 0x01, 0x03, 0xff, 0xff] however results in the crash described on Windows .尝试使用[0xff, 0x20, 0x00, 0x01, 0x03, 0xff, 0xff]进行身份验证会导致Windows 上描述的崩溃。 I've tried the stock Windows driver as well as playing around with different protocols, no success.我已经尝试了股票的 Windows 驱动程序以及使用不同的协议,但没有成功。

Another weird behaviour that is exclusive to Windows: When inserting a card, the reader's LED flashes quickly and it takes around 9 seconds before the card can be accessed at all.另一个 Windows 独有的奇怪行为:插入卡时,读卡器的 LED 快速闪烁,大约需要 9 秒才能访问卡。

This is the first time I'm trying to interface with hardware, so it's probably something obvious, but I cannot figure it out.这是我第一次尝试与硬件接口,所以这可能很明显,但我无法弄清楚。 I'd appreciate any input and/or recommendations for (still available) readers that are known to work in this configuration.对于已知可在此配置中工作的(仍然可用的)读者,我将不胜感激。

Your three liner pretty much solved all the problems I was fighting for hours, thank you!你的三个班轮几乎解决了我挣扎了几个小时的所有问题,谢谢!

About the APDU: I took it from the ACR38X reference manual and you're right, it was for a different card.关于 APDU:我从 ACR38X 参考手册中获取了它,您是对的,它用于不同的卡。 I don't know how I didn't notice that, since all the other APDU codes are structured similarly.我不知道我怎么没有注意到这一点,因为所有其他 APDU 代码的结构都相似。 The (wrong) code works does work fine under linux though, I just tested it again to make sure.尽管(错误的)代码在 linux 下确实可以正常工作,但我只是再次对其进行了测试以确保。 Under Windows [0xff, 0x20, 0x00, 0x01, 0x02, 0xff, 0xff] (the last two bytes being the PIN/PSC) now responds with the expected answer (SW1 = 0x90, SW2 = 0xff for the PSC being correct, 0x00 for the card being locked or the actual error counter if both are not applicable).在 Windows 下[0xff, 0x20, 0x00, 0x01, 0x02, 0xff, 0xff] (最后两个字节是 PIN/PSC)现在响应预期的答案(SW1 = 0x90, SW2 = 0xff 表示 PSC 正确,0x00 表示卡被锁定或实际错误计数器(如果两者都不适用)。

About the certificate propagation service: Killing that service does not immediately solve the problem of the flashing & unresponsive reader.关于证书传播服务:杀死该服务并不能立即解决阅读器闪烁和无响应的问题。 After plugging in the reader and killing the service, the same behaviour occurs for the first 3-4 cards.插入读卡器并杀死服务后,前3-4张卡出现相同的行为。 After that, it responds immediately after inserting new cards and the led stays lit.之后,它在插入新卡后立即响应并且 LED 保持点亮。 Still weird, but at least it's usable after a few cards now!仍然很奇怪,但至少现在在几张牌后可以使用了!

APDU CLA value 'FF' isn't allowed according to ISO 7816-4.根据 ISO 7816-4,APDU CLA 值“FF”是不允许的。 Manufacturers of PC/SC readers sometime support APDU commands with CLA=FF to implement some specific functions like access to MIFARE cards or tuning of communication protocol settings. PC/SC 阅读器的制造商有时支持 CLA=FF 的 APDU 命令,以实现某些特定功能,例如访问 MIFARE 卡或调整通信协议设置。

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

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