我正在尝试使用字节数组设置 CommandAPDU 缓冲区。但是,如果长度>7,则会引发以下错误:
线程“主”java.lang.IllegalArgumentException 中的异常:APDU 无效:长度 = 8,b1 = 1 在 javax.smartcardio.CommandAPDU.parse(CommandAPDU.java:318) 在 javax.smartcardio.CommandAPDU.(CommandAPDU.java:98 ) 在终端.Main.main(Main.java:78)
我的代码:
byte terminal = 0x00;
byte instruction = 0x01;
byte [] msg = {0x01,0x00,0x01,0x00};
byte [] fullmsg = new byte[msg.length + 4];
System.arraycopy(new byte []{terminal}, 0, fullmsg, 0, 1);
System.arraycopy(new byte [] {instruction}, 0, fullmsg, 1, 1);
System.arraycopy(new byte [] {0,0}, 0, fullmsg, 2, 2);
System.arraycopy(msg, 0, fullmsg, 4, msg.length);
CommandAPDU cmdapdu = new CommandAPDU(fullmsg);
有人可以帮我吗?