Page 1 of 1

Is it possible to return some data along with the status word 9000 on selecting an applet in javacard?

Posted: Thu Nov 26, 2015 5:37 am
by Lehrling81
I was wondering if i could send back some data from the java card applet when it is selected.

Since select() method returns a boolean value, I don't know how to return data bytes from it.

Can anyone help me with this? i want the applet to return a simple byte array along with the status word 9000 (which is default for success), when i send the select command to the card.

ie, when i send the following command

00 A4 04 00 06 01 02 03 04 05 06

i want a response like,

01 02 03 04 90 00

(first four bytes are the data returned from the applet)

Thanks in advance.

Re: Is it possible to return some data along with the status word 9000 on selecting an applet in javacard?

Posted: Thu Nov 26, 2015 7:34 am
by rena2019

Code: Select all

public void process(APDU apdu) {
      if (selectingApplet()) {
         apdu.getBuffer()[0] = 0x01;
         apdu.getBuffer()[1] = 0x02;
         apdu.getBuffer()[2] = 0x03;
         apdu.getBuffer()[3] = 0x04;
         apdu.setOutgoingAndSend((short)0, (short)4);
         return;
      }
       ...

Re: Is it possible to return some data along with the status word 9000 on selecting an applet in javacard?

Posted: Fri Nov 27, 2015 5:59 am
by Lehrling81
Thanks @rena2019. It works!

Re: Is it possible to return some data along with the status word 9000 on selecting an applet in javacard?

Posted: Fri Nov 27, 2015 6:01 am
by mabel

Code: Select all

public void process(APDU apdu) 
{
  byte[] buf = apdu.getBuffer();
  if (selectingApplet())
       {
          //send  data in the buffer
          return;
       }
}