我有一个 JCOP V2.4.2 R3 java 卡,它的数据表中提到“该卡支持T=1
and T=0
通信协议”
我还有一个 ACR38 智能卡读卡器,它支持 T=0 和 T=1 协议。 (我与一张卡成功进行了 T=0 通信,并且与该卡成功进行了 T=1 通信。)
我编写了以下程序并将其上传到卡上以发送和接收扩展 APDU:
package extAPDU;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISOException;
import javacardx.apdu.ExtendedLength;
public class ExAPDU extends Applet implements ExtendedLength {
private ExAPDU() {
}
public static void install(byte bArray[], short bOffset, byte bLength)
throws ISOException {
new ExAPDU().register();
}
public void process(APDU arg0) throws ISOException {
short number = arg0.setIncomingAndReceive();
arg0.setOutgoingAndSend((short)0, (short)(number+7));
}
}
在 CAD 端,我使用 python 脚本将不同的 APDU 发送到卡。问题是:
1-为什么我无法开始使用T=0协议进行通信(虽然提到该卡支持该协议):
蟒蛇脚本:
from smartcard.scard import *
import smartcard.util
from smartcard.System import readers
from smartcard.CardConnection import CardConnection
r=readers()
print r
connection =r[0].createConnection()
connection.connect(CardConnection.T0_protocol)
normalCommand=[0x00,0xa4,0x04,0x00,0x06,0x01,0x02,0x03,0x04,0x05,0x06]
data,sw1,sw2=connection.transmit(normalCommand)
print "SW for Normal Command:"
print data,hex(sw1),hex(sw2)
Output:
>>> ================================ RESTART ================================
>>>
['ACS CCID USB Reader 0']
Traceback (most recent call last):
File "C:\extAPDU.py", line 13, in <module>
connection.connect(CardConnection.T0_protocol)
File "D:\PythonX\Lib\site-packages\smartcard\CardConnectionDecorator.py", line 54, in connect
self.component.connect(protocol, mode, disposition)
File "D:\PythonX\Lib\site-packages\smartcard\pcsc\PCSCCardConnection.py", line 118, in connect
raise CardConnectionException('Unable to connect with protocol: ' + dictProtocol[pcscprotocol] + '. ' + SCardGetErrorMessage(hresult))
CardConnectionException: Unable to connect with protocol: T0. The requested protocols are incompatible with the protocol currently in use with the smart card.
>>>
2- 为什么该卡不能与 T=1 协议上扩展形式的 Select APDU 命令正常工作:
蟒蛇脚本:
from smartcard.scard import *
import smartcard.util
from smartcard.CardConnection import CardConnection
from smartcard.System import readers
r=readers()
print r
connection =r[0].createConnection()
connection.connect(CardConnection.T1_protocol)
normalCommand=[0x00,0xa4,0x04,0x00,0x00,0x00,0x06,0x01,0x02,0x03,0x04,0x05,0x06]
data,sw1,sw2=connection.transmit(normalCommand)
print "SW for Normal Command:"
print data,hex(sw1),hex(sw2)
Output :
>>> ================================ RESTART ================================
>>>
['ACS CCID USB Reader 0']
SW for Normal Command:
[] 0x67 0x0
>>>
我想我误解了这个概念,并且我将扩展 APDU 与T=1
and T=0
协议!
Every T=1
兼容的智能卡,可以发送和接收扩展APDU吗?我们无法通过以下方式发送和接收扩展 APDUT=0
协议?如果我们想要发送扩展 SELECT APDU 命令到安全域,SD 必须实现ExtendedLength
界面?
对于扩展 APDU 传输有哪些要求?
- T=1 兼容读卡器
- T=1 兼容智能卡
- 一个小程序实现了
ExtendedLength
界面
这样对吗?
我真的很困惑扩展兼容性和T=0/1
智能卡的兼容性。任何光线都会受到赞赏。
请注意,我可以使用以下命令成功地将扩展 APDU 发送到上述小程序T=1
协议!