初始更新在两种不同的情况下给出了6985和61xx

Arj*_*jun 10 smartcard javacard

我有一张java卡,我写了一个小代码,将APDU发送到java卡.这里当我发送Init_Update命令时,得到0x6985像: -

CMD -> 80 50 00 00 08 11 22 33 44 55 66 77 88
RES <- 6985
Run Code Online (Sandbox Code Playgroud)

但是当我用其他工具发送此命令时,它会给出所需的结果,如: -

Transmit: 80 50 00 00 08    []
  11 22 33 44 55 66 77 88                            ."3DUfw.
Card answered: 61 1C
Run Code Online (Sandbox Code Playgroud)

我的java代码对我有的其他java卡很有用.谁能告诉我这种不同行为的原因是什么?

// full java code


     public static void main(String[] args) {
            // TODO code application logic here
            try
            {

        factory = TerminalFactory.getDefault();
                    terminals = factory.terminals().list(); 
                terminal = terminals.get(0);
                card = terminal.connect("*");
                    channel =card.getBasicChannel();

                    CommandAPDU cmdAPDU;
                     ResponseAPDU response;
                    byte[] select_isd = {(byte) 0x00,(byte) 0xA4,(byte) 0x04,(byte) 0x00,(byte) 0x08,(byte) 0xA0,(byte) 0x00,
                                         (byte) 0x00,(byte) 0x00,(byte) 0x03,(byte) 0x00,(byte) 0x00,(byte) 0x00 };
                    cmdAPDU = new CommandAPDU(select_isd);
                     response = channel.transmit(cmdAPDU);
                    byte[] INIT_UPDATE = {(byte) 0x80,(byte) 0x50,(byte) 0x00,(byte) 0x00,(byte) 0x08,(byte) 0x11,(byte) 0x22,
                                          (byte) 0x33,(byte) 0x44,(byte) 0x55,(byte) 0x66,(byte) 0x77,(byte) 0x88 };
                     cmdAPDU = new CommandAPDU(INIT_UPDATE);
                     response = channel.transmit(cmdAPDU);
 }
        catch( Exception ex)
        {

        }
    }
Run Code Online (Sandbox Code Playgroud)

其他工具日志如下: -

Card opened
12 bytes ATR received:
3B 68 00 00 00 73 C8 40 00 00 90 00

Transmit: 00 A4 04 00 08    [SELECT FILE]
  A0 00 00 00 03 00 00 00                            ........
Card answered: 61 12

Transmit: 00 C0 00 00 12    [GET RESPONSE]
Card answered: 90 00
  6F 10 84 08 A0 00 00 00 03 00 00 00 A5 04 9F 65    o..............e
  01 FF                                              ..

Transmit: 80 50 00 00 08    []
  11 22 33 44 55 66 77 88                            ."3DUfw.
Card answered: 61 1C
Run Code Online (Sandbox Code Playgroud)

但是当我运行我的java代码时,我得到6985 INIT_UPDATE命令.

如果我方需要任何其他信息,请告诉我..

==新增===我试着在JCOP shell中运行我的脚本,我的脚本如下: -

/mode trace=on
/terminal 
/atr
/send 80CAA08D05
/send 802E000014B555C94B0B2368B4840201808502032288020060
/send 80D8000000
/atr
/send 80500000081122334455667788
Run Code Online (Sandbox Code Playgroud)

它给了我所需的结果.我尝试在java中实现,我的新java代码如下所示: - =====新更新的JAVA代码===

factory = TerminalFactory.getDefault();
         terminals = factory.terminals().list(); 
         terminal = terminals.get(0);

         card = terminal.connect("*");
         channel =card.getBasicChannel();

         CommandAPDU cmdAPDU;
         ResponseAPDU response;
         byte[] x = { (byte) 0x80, (byte) 0xCA, (byte) 0xA0,(byte) 0x8D,(byte)0x05};
         byte[] y = {    remove command for security reasons};
         byte[] z = {     (byte) 0x80, (byte) 0xD8, (byte) 0x00, (byte) 0x00, (byte) 0x00}; // it set default key


           cmdAPDU = new CommandAPDU(x);
         response = channel.transmit(cmdAPDU);
                System.out.println(response.toString());

                  cmdAPDU = new CommandAPDU(y);
         response = channel.transmit(cmdAPDU);
                System.out.println(response.toString());

                           cmdAPDU = new CommandAPDU(z);
         response = channel.transmit(cmdAPDU);
                System.out.println(response.toString());

                   card.disconnect(true);
                    card = terminal.connect("*");
                   channel =card.getBasicChannel();


         byte[] INIT_UPDATE = {(byte) 0x80,(byte) 0x50,(byte) 0x00,(byte) 0x00,(byte) 0x08,(byte) 0x11,(byte) 0x22,(byte) 0x33,(byte) 0x44,(byte) 0x55,(byte) 0x66,(byte) 0x77,(byte) 0x88 };

         cmdAPDU = new CommandAPDU(INIT_UPDATE);
        response = channel.transmit(cmdAPDU);
Run Code Online (Sandbox Code Playgroud)

Maa*_*wes 7

6985表示不满足使用条件.由于到目前为止你没有使用任何密钥,这可能意味着卡被锁定或终止.


611C是用于APDU通过T = 0发送的状态字.T = 0不处理同一APDU中的命令和响应(也称为"ISO情况4"),因此GET RESPONSEISO情况4命令需要a .第一个应用程序处理此视图(如Java卡本身所做) - 组合两个APDU - 或者它创建T = 1连接而不是T = 0连接.

它与6985状态字几乎没有关系,因为您希望在处理INITIALIZE UPDATE命令的业务逻辑之前生成此警告 - 仅在可以生成输出时才处理该命令.