moros_a moros_a - 6 months ago 51
Java Question

java smartCard I/O secure channel

I currently try to wrote test about a JavaCard applet. I'm using JUnit and javax.smartcardio to send all my commands to the smartCard.
But i need to open a secure channel to get one of my test running properly.
After two day of hard reasarch on the documentation and experiment I can't find a way to open this secure channel. do anyone have a clue with the smartcardio API ? or an other API willing to do that ?

//TODO: need secure channel
byte[] header = {(byte)0x02, (byte)0x01, (byte)0x01}; //tag + length
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] excpectedRes = outputStream.toByteArray();
// not a secure channel at all
ResponseAPDU answer = channel.transmit(new CommandAPDU(0x84, 0xCA, 0x02, 0x01, Value.Emptydata));
nameTest = "Test Select Serial number " + answer.toString();
CheckSW(0x90, 00, answer);
CheckResult(excpectedRes, result);

This is my code and i always get a 0x69 0x82 answer (Security status not satisfied)



The problem here is you are trying to send Get Data command which requires authentication which means you should run initialize update and external authenticate before using Get data command.

If you just want to test your code working or not you can test with selecting MF, and the APDU is
A0 A4 00 00 02 3F00 which will return 9F XX.