Get 6D00 when sending Extended APDU

JavaCard Applet Development Related Questions and Answers.
RexLi
Posts: 9
Joined: Wed Dec 21, 2016 11:46 pm
Points :82
Contact:

Get 6D00 when sending Extended APDU

Post by RexLi » Wed Mar 15, 2017 2:01 am

Hi. I have a problem about Extended APDU. When I sent extended APDU below to my card via pyApdutool, it returned 6D00,which means the INS parameter is not supported. But INS: 20 has been already defined in my code. It made me confused. Does anyone help me figure out the problem? Thanks a lot.

Code: Select all

CLA: 00 INS: 20 P1: 00 P2: 00 LC: 00 03 10 LE: 00 03 
Data: 30 82 03 0C 30 82 01 F4 A0 03 02 01 02 02 03 01 00 20 30 0D 06 09 2A 86 48 86 F7 0D
01 01 05 05 00 30 3E 31 0B 30 09 06 03 55 04 06 13 02 50 4C 31 1B 30 19 06 03 55 04 0A 13
12 55 6E 69 7A 65 74 6F 20 53 70 2E 20 7A 20 6F 2E 6F 2E 31 12 30 10 06 03 55 04 03 13 09
43 65 72 74 75 6D 20 43 41 30 1E 17 0D 30 32 30 36 31 31 31 30 34 36 33 39 5A 17 0D 32 37
30 36 31 31 31 30 34 36 33 39 5A 30 3E 31 0B 30 09 06 03 55 04 06 13 02 50 4C 31 1B 30 19
06 03 55 04 0A 13 12 55 6E 69 7A 65 74 6F 20 53 70 2E 20 7A 20 6F 2E 6F 2E 31 12 30 10 06
03 55 04 03 13 09 43 65 72 74 75 6D 20 43 41 30 82 01 22 30 0D 06 09 2A 86 48 86 F7 0D 01
01 01 05 00 03 82 01 0F 00 30 82 01 0A 02 82 01 01 00 CE B1 C1 2E D3 4F 7C CD 25 CE 18 3E
4F C4 8C 6F 80 6A 73 C8 5B 51 F8 9B D2 DC BB 00 5C B1 A0 FC 75 03 EE 81 F0 88 EE 23 52 E9
E6 15 33 8D AC 2D 09 C5 76 F9 2B 39 80 89 E4 97 4B 90 A5 A8 78 F8 73 43 7B A4 61 B0 D8 58
CC E1 6C 66 7E 9C F3 09 5E 55 63 84 D5 A8 EF F3 B1 2E 30 68 B3 C4 3C D8 AC 6E 8D 99 5A 90
4E 34 DC 36 9A 8F 81 88 50 B7 6D 96 42 09 F3 D7 95 83 0D 41 4B B0 6A 6B F8 FC 0F 7E 62 9F
67 C4 ED 26 5F 10 26 0F 08 4F F0 A4 57 28 CE 8F B8 ED 45 F6 6E EE 25 5D AA 6E 39 BE E4 93
2F D9 47 A0 72 EB FA A6 5B AF CA 53 3F E2 0E C6 96 56 11 6E F7 E9 66 A9 26 D8 7F 95 53 ED
0A 85 88 BA 4F 29 A5 42 8C 5E B6 FC 85 20 00 AA 68 0B A1 1A 85 01 9C C4 46 63 82 88 B6 22
B1 EE FE AA 46 59 7E CF 35 2C D5 B6 DA 5D F7 48 33 14 54 B6 EB D9 6F CE CD 88 D6 AB 1B DA
96 3B 1D 59 02 03 01 00 01 A3 13 30 11 30 0F 06 03 55 1D 13 01 01 FF 04 05 30 03 01 01 FF
30 0D 06 09 2A 86 48 86 F7 0D 01 01 05 05 00 03 82 01 01 00 B8 8D CE EF E7 14 BA CF EE B0
44 92 6C B4 39 3E A2 84 6E AD B8 21 77 D2 D4 77 82 87 E6 20 41 81 EE E2 F8 11 B7 63 D1 17
37 BE 19 76 24 1C 04 1A 4C EB 3D AA 67 6F 2D D4 CD FE 65 31 70 C5 1B A6 02 0A BA 60 7B 6D
58 C2 9A 49 FE 63 32 0B 6B E3 3A C0 AC AB 3B B0 E8 D3 09 51 8C 10 83 C6 34 E0 C5 2B E0 1A
B6 60 14 27 6C 32 77 8C BC B2 72 98 CF CD CC 3F B9 C8 24 42 14 D6 57 FC E6 26 43 A9 1D E5
80 90 CE 03 54 28 3E F7 3F D3 F8 4D ED 6A 0A 3A 93 13 9B 3B 14 23 13 63 9C 3F D1 87 27 79
E5 4C 51 E3 01 AD 85 5D 1A 3B B1 D5 73 10 A4 D3 F2 BC 6E 64 F5 5A 56 90 A8 C7 0E 4C 74 0F
2E 71 3B F7 C8 47 F4 69 6F 15 F2 11 5E 83 1E 9C 7C 52 AE FD 02 DA 12 A8 59 67 18 DB BC 70
DD 9B B1 69 ED 80 CE 89 40 48 6A 0E 35 CA 29 66 15 21 94 2C E8 60 2A 9B 85 4A 40 F3 6B 8A
24 EC 06 16 2C 73

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

Re: Get 6D00 when sending Extended APDU

Post by mabel » Wed Mar 15, 2017 3:19 am

Could you show some related code to us?

RexLi
Posts: 9
Joined: Wed Dec 21, 2016 11:46 pm
Points :82
Contact:

Re: Get 6D00 when sending Extended APDU

Post by RexLi » Wed Mar 15, 2017 3:24 am

My applet:

Code: Select all

public class RCApp extends Applet implements ExtendedLength {

    // Card status
    private final static byte ST_UNINITIALIZED     = (byte) 0x01;
    private final static byte ST_INITIALIZED       = (byte) 0x02;

    // Instructions
    private final static byte INS_INIT_UPDATE      = (byte) 0x50;
    private final static byte INS_EXT_AUTH         = (byte) 0x82;

    private final static byte INS_INITIALIZE       = (byte) 0x20;

    // Card is not initialized
    private final static short SW_CARD_ALREADY_INITIALIZED   = (short) 0x9102;

    private Data content;
    private short cardStatus;

     public static void install(byte[] bArray, short bOffset, byte bLength) {
          new REApp( bArray, bOffset, bLength);
     }

    public REApp(byte[] bArray, short bOffset, byte bLength) {
        cardStatus = ST_UNINITIALIZED;
        content = new Data();
       
        byte aidLen = bArray[bOffset];
        if (aidLen== (byte)0){
            register();
        } else {
            register(bArray, (short)(bOffset+1), aidLen);
        }
    }

    public void process(APDU apdu) {
          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) == (byte) 0x80) {
            switch (ins) {
                case INS_INIT_UPDATE:
                case INS_EXT_AUTH:
                    apdu.setOutgoingAndSend(ISO7816.OFFSET_CDATA, sc.processSecurity(apdu));
                    return;
            default:
                ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
            }
        } else
            switch (ins) {
                case INS_INITIALIZE:
                    processInitialize(apdu);
                    break;
                default:
                    ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
            }
     }

    private void processInitialize(APDU apdu) {
        if(cardStatus == ST_INITIALIZED)
            ISOException.throwIt(SW_CARD_ALREADY_INITIALIZED);
        byte[] buffer = apdu.getBuffer();
        short lc = apdu.getIncomingLength();
        short rcvLen = apdu.setIncomingAndReceive();

        byte[] data = new byte[lc];
        short destOffset = 0;
        while (rcvLen > 0) {
            short dataOffset = apdu.getOffsetCdata();
            Util.arrayCopy(buffer, dataOffset, data, destOffset, rcvLen);
            destOffset += rcvLen;
            rcvLen = apdu.receiveBytes(dataOffset);
        }
        content.setData(data);
        cardStatus = ST_INITIALIZED;
    }

}


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

Re: Get 6D00 when sending Extended APDU

Post by mabel » Wed Mar 15, 2017 4:55 am

It seems that your code doesn't have any question. Under which protocol do you use Extended APDU?

RexLi
Posts: 9
Joined: Wed Dec 21, 2016 11:46 pm
Points :82
Contact:

Re: Get 6D00 when sending Extended APDU

Post by RexLi » Wed Mar 15, 2017 11:16 pm

mabel wrote:It seems that your code doesn't have any question. Under which protocol do you use Extended APDU?


I sent Extended APDU via T0. Is there any question with this protocol?

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

Re: Get 6D00 when sending Extended APDU

Post by mabel » Thu Mar 16, 2017 5:36 am

It's a little complex under T0. If you need to send data which is more than 255 bytes, then you have to implement command chaining.
With T=1 you can send large data of some 65535 bytes of in a single APDU. But if want to send that amount of data with T=0 then you will need more than 1 APDUs.

Samuel
Posts: 1
Joined: Thu May 10, 2018 11:54 pm
Points :8
Contact:

Re: Get 6D00 when sending Extended APDU

Post by Samuel » Fri May 11, 2018 12:20 am

In ISO 7816 T0 mode, The extension APDU is essentially split by serial commands and sent to the smart card. So it's a good idea to find a tool that supports an automatic split.

jennyvenus
Posts: 23
Joined: Sun Aug 23, 2015 11:14 pm
Points :362
Contact:

Re: Get 6D00 when sending Extended APDU

Post by jennyvenus » Thu May 17, 2018 3:29 am

under T0 mode, Use envelope command(C2) format APDU into TPDU and send them to card

TPDU format under T0
Cla ins p1 p2 p3
Or
Cla ins p1 p2 p3 + p3 length data

so the card must support envelope mechanism

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: Google [Bot] and 6 guests

JavaCard OS : Disclaimer