Reputation: 11
Hi i am writing a script to personalize java card using smartcardio API.
Following is the java code
TerminalFactory tf = TerminalFactory.getDefault();
List<CardTerminal> terminals = tf.terminals().list();
CardTerminal cardTerminal1 = (CardTerminal) terminals.get(0);
Card connection1 = cardTerminal1.connect("T=0");
CardChannel channel = connection1.getBasicChannel();
byte[] apdu = new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x04, (byte) 0x00, (byte) 0x07, (byte) 0xA0,(byte) 0x00, (byte) 0x00, (byte) 0x01,(byte) 0x51,(byte) 0x00,(byte) 0x00};
String hex1 = DatatypeConverter.printHexBinary(apdu);
System.out.println("Select Request : " + hex1 + "\n");
ResponseAPDU respApdu = channel.transmit(new CommandAPDU(apdu));
byte[] resp1 = respApdu.getBytes();
hex1 = DatatypeConverter.printHexBinary(resp1);
System.out.println("Select Response : " + hex1 + "\n");
apdu = new byte[] { (byte) 0x80, (byte) 0xCA, (byte) 0x9F, (byte) 0x7F, (byte) 0x2A};
hex1 = DatatypeConverter.printHexBinary(apdu);
System.out.println("Get Request with CLA 80 : " + hex1 + "\n");
respApdu = channel.transmit(new CommandAPDU(apdu));
resp1 = respApdu.getBytes();
hex1 = DatatypeConverter.printHexBinary(resp1);
System.out.println("Get Response with CLA: " + hex1 + "\n");
apdu = new byte[] { (byte) 0x00, (byte) 0xCA, (byte) 0x9F, (byte) 0x7F, (byte) 0x2A};
hex1 = DatatypeConverter.printHexBinary(apdu);
System.out.println("Get Request with CLA 00 : " + hex1 + "\n");
respApdu = channel.transmit(new CommandAPDU(apdu));
resp1 = respApdu.getBytes();
hex1 = DatatypeConverter.printHexBinary(resp1);
System.out.println("Get Response with CLA 00: " + hex1 + "\n");
apdu = new byte[] { (byte) 0x80, (byte) 0x50, (byte) 0x00, (byte) 0x00, (byte) 0x08,(byte) 0xEC, (byte) 0xB9, (byte) 0x27, (byte) 0x11, (byte) 0xDF, (byte) 0x0F, (byte) 0x61, (byte) 0x79};
hex1 = DatatypeConverter.printHexBinary(apdu);
System.out.println("Initialize Request Command : " + hex1 + "\n");
respApdu = channel.transmit(new CommandAPDU(apdu));
resp1 = respApdu.getBytes();
hex1 = DatatypeConverter.printHexBinary(resp1);
System.out.println("Initialize Response : " + hex1 + "\n");
Following is output
Select Request : 00A4040007A0000001510000
Select Response : 6F5B8407A0000001510000A550734A06072A864886FC6B01600C060A2A864886FC6B02020101630906072A864886FC6B03640B06092A864886FC6B040215650B06092B8510864864020103660C060A2B060104012A026E01029F6501FF9000
Get Request with CLA 80 : 80CA9F7F2A
Get Response with CLA: 9F7F2A53430019492170676001E7702B05718231581144729111447291114472912A0D000000000000006D00
Get Request with CLA 00 : 00CA9F7F2A
Get Response with CLA 00: 53430019492170676001E7702B05718231581144729111447291114472912A0D000000000000000000009000
Initialize Request Command : 8050000008ECB92711DF0F6179
Initialize Response : 6D00
If i send a command with CLA 00 i get proper response 90 00 otherwise card is returning 6D 00.
If any one has idea just let me know how can i resolve this issue using smartcardio API?
Upvotes: 0
Views: 475
Reputation: 4142
This has nothing to do with smartcardio, 6D00 means that the command you are sending is not recognized by the card. Check your card/applet manual for correct coding of the command APDU.
Upvotes: 2