JavacardOS will not accept order any more, please contact our partner Feitian online Store:
https://ftsafe.en.alibaba.com/index.html

Encounter 6D00 when using secure channel sample code

JavaCard Applet Development Related Questions and Answers.
Valks
Posts: 16
Joined: Wed Oct 12, 2016 11:45 pm
Points :176
Contact:

Encounter 6D00 when using secure channel sample code

Post by Valks » Tue Dec 06, 2016 2:12 am

I found a sample code which is used to implement secure channel. When I tried to get the security level, I got error status word 6D00. Any help plz.

Sample code:

Code: Select all


package test;
 
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
 
import org.globalplatform.GPSystem;
import org.globalplatform.SecureChannel;
 
public class TestSecureChannel extends Applet {
    private final static byte INS_INIT_UPDATE = 0x50;
    private final static byte INS_EXT_AUTH = (byte) 0x82;
 
    private TestSecureChannel() {
    }
 
    public static void install(byte bArray[], short bOffset, byte bLength) throws ISOException {
        new TestSecureChannel().register();
    }
 
    public void process(APDU apdu) throws ISOException {
        if (selectingApplet()) {
            return;
        }
 
        byte[] buffer = apdu.getBuffer();
 
        byte cla = buffer[ISO7816.OFFSET_CLA];
        byte ins = buffer[ISO7816.OFFSET_INS];
        SecureChannel sc = GPSystem.getSecureChannel();
 
        if ((byte) (cla & 0x80) == 0x80) {
            switch (ins) {
                case INS_INIT_UPDATE:
                case INS_EXT_AUTH:
                    apdu.setOutgoingAndSend(ISO7816.OFFSET_CDATA, sc.processSecurity(apdu));
                    return;
 
                default:
            }
        }
 
        switch (ins) {
            case (byte) 0x01:
                buffer[0] = sc.getSecurityLevel();
                apdu.setOutgoingAndSend((short) 0, (short) 1);
                break;
            default:
                ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
        }
 
    }
}



APDU commands are as belows:
>>/send 00A4040007A000000003000000
<< 6F 60 84 08 A0 00 00 00 03 00 00 00 A5 54 73 4A 06 07 2A 86 48 86 FC 6B 01 60 0C 06 0A 2A 86 48 86 FC 6B 02 02 01 01 63 09 06 07 2A 86 48 86 FC 6B 03 64 0B 06 09 2A 86 48 86 FC 6B 04 02 15 65 0B 06 09 2B 85 10 86 48 64 02 01 01 66 0C 06 0A 2B 06 01 04 01 2A 02 6E 01 02 9F 6E 01 01 9F 65 01 FE 90 00
>>/send 00A4040000
<< 6F 60 84 08 A0 00 00 00 03 00 00 00 A5 54 73 4A 06 07 2A 86 48 86 FC 6B 01 60 0C 06 0A 2A 86 48 86 FC 6B 02 02 01 01 63 09 06 07 2A 86 48 86 FC 6B 03 64 0B 06 09 2A 86 48 86 FC 6B 04 02 15 65 0B 06 09 2B 85 10 86 48 64 02 01 01 66 0C 06 0A 2B 06 01 04 01 2A 02 6E 01 02 9F 6E 01 01 9F 65 01 FE 90 00
>> /send 00a4040008A000000003000000
<< 6F 60 84 08 A0 00 00 00 03 00 00 00 A5 54 73 4A 06 07 2A 86 48 86 FC 6B 01 60 0C 06 0A 2A 86 48 86 FC 6B 02 02 01 01 63 09 06 07 2A 86 48 86 FC 6B 03 64 0B 06 09 2A 86 48 86 FC 6B 04 02 15 65 0B 06 09 2B 85 10 86 48 64 02 01 01 66 0C 06 0A 2B 06 01 04 01 2A 02 6E 01 02 9F 6E 01 01 9F 65 01 FE 90 00
>> /send 8050000008B5255216B9038BBD00
<< 00 00 00 00 20 11 00 05 00 00 FF 02 00 26 B1 0A A0 5E 3F 2C CD 2A 15 63 32 CD A4 1F 90 00
>> /send 8482000010AE7B8687E8CAB7225B4FED305529EA64
<< 90 00
>> /send 8001000000
<< 6D 00

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: Encounter 6D00 when using secure channel sample code

Post by mabel » Tue Dec 06, 2016 5:47 am

Just select your applet firstly. You didn't select the applet yet.

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 50 guests

JavaCard OS : Disclaimer