I'm trying to set the CommandAPDU buffer with a byte array. However, if the length is >7, it throws the following error:
Exception in thread "main" java.lang.IllegalArgumentException: Invalid APDU: length=8, b1=1 at javax.smartcardio.CommandAPDU.parse(CommandAPDU.java:318) at javax.smartcardio.CommandAPDU.(CommandAPDU.java:98) at terminal.Main.main(Main.java:78)
My code:
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);
Can someone help me out?