This discussion is archived
3 Replies Latest reply: Jul 18, 2012 7:19 PM by safarmer RSS

java card returns data that is required but with 6D00 in SW field

948184 Newbie
Currently Being Moderated
Hi all,

I am new in smart card programming, so I need help.

I am running Eclipse with JCWDE. Trying a simple applet that should return a certain value. I get the value! And I get an 6D00 error code in SW fields. 6D00 means that instruction code is not supported or invalid. My question is how is it possible that instruction code is invalid, but the applet return the data anyway?
You can find the part of the code below:
public void process(APDU apdu) throws ISOException {
        byte[] buffer = apdu.getBuffer();
        // check SELECT APDU command
        
        if (apdu.isISOInterindustryCLA()) {
            if (buffer[ISO7816.OFFSET_INS] == (byte)(0xA4)) {
                return;
            } else {
                ISOException.throwIt (ISO7816.SW_CLA_NOT_SUPPORTED);
            }
        }
        // verify the reset of commands have the
        // correct CLA byte, which specifies the
        // command structure
        if (buffer[ISO7816.OFFSET_CLA] != Applet_CLA)
            ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
        
        switch (buffer[ISO7816.OFFSET_INS]) {
        case 0x04:
             sendData(apdu);
        default:
            ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
        }
the method sendData(APDU apdu) is shown below
private void sendData(APDU apdu){
           byte[] buffer = apdu.getBuffer();
           
           short le = apdu.setOutgoing();
             
          if ( le < 4 )
                ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
          
          apdu.setOutgoingLength((byte) 4);
          
          // move the balance data into the APDU buffer
          // starting at the offset 0
          buffer[0] = dataBack[0];
          buffer[1] = dataBack[1];
          buffer[2] = dataBack[2];
          buffer[3] = dataBack[3];
             
          // send the 2-byte balance at the offset
          // 0 in the apdu buffer
          apdu.sendBytes((short)0, (short)4);
     }
the script I run is:

powerup;
// Select the installer applet
0x00 0xA4 0x04 0x00 0x09 0xa0 0x00 0x00 0x00 0x62 0x03 0x01 0x08 0x01 0x7F;
// create FirstStep applet
0x80 0xB8 0x00 0x00 0xd 0xb 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x00 0x02 0x00 0x7F;
// select FirstStep applet
0x00 0xA4 0x04 0x00 0xb 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x00 0x02 0x7F;
// apdu get data
0xB0 0x04 0x00 0x00 0x00 0x04;
powerdown;

the answer I get is:
Received ATR = 0x3b 0xf0 0x11 0x00 0xff 0x00
CLA: 00, INS: a4, P1: 04, P2: 00, Lc: 09, a0, 00, 00, 00, 62, 03, 01, 08, 01, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b8, P1: 00, P2: 00, Lc: 0d, 0b, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, 02, 00, Le: 0b, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, 02, SW1: 90, SW2: 00
CLA: 00, INS: a4, P1: 04, P2: 00, Lc: 0b, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, 02, Le: 00, SW1: 90, SW2: 00
CLA: b0, INS: 04, P1: 00, P2: 00, Lc: 00, Le: 04, 9e, 37, 79, b9, SW1: 6d, SW2: 00

Does this error code (6D00) means something else as well?

Edited by: Lyudmila on 2012-jul-09 03:40

Edited by: Lyudmila on 2012-jul-09 03:49

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points