You cannot just use any instruction class (CLA) you want to. See ISO7816 part 4 section 5 APDU level data structures , 5.4.1 Class byte - Table 8 – Coding and meaning of CLA. As you can see, a CLA of 0x01
is a request to open logical channel #1, something which is not supported when you are not in an authenticated GlobalPlatform session (hence why it worked in the GPP CLI, which does implicit authentication). I recommend using only the inter-industry CLA 0x80
(or 0x80
| 0x10
= 0x90
if you are sending a message with chained fragmentation) for normal communication.
Your command should be: 80 40 00 00 00
(CLA = 0x80
, INS = 0x40
(thats what you have in your JC code switch case), P1/P2 = 0x00, 0x00
, 0x00
command bytes, indeterminate response).
I also recommend adding e.g. 0xFF
to the command to set the maximum amount of bytes expected to be replied to prevent buffer overruns.