applet - Java Card to send data without get data APDU -


i'm new field, forgive me if question naive.

i want issue java card has auto-select applet , apdus going handled in applet. need applet send data cad not using usual format in java card standard (i.e. without sending 0x61 0xbytestoread , waiting 0x00 0xc0).
example i'd send 0x23 bytes in answer 0xa0a40000027f20 select command wrong first byte!

so possible this? , if it's possible please tell me how.

thanks.

yes, possible. aim goal, have 2 steps below :

  1. you must make applet default selected.
  2. you must return data on reception of command, and/or reception of select apdu command.

for first step, answered here:

it depends on cards - not of them seem support making applet default after installation. can use open source globalplatform tool java has --make-default option:

java -jar gp.jar --make-default a000100201100001 

iirc jcop 1 of cards supported it.

and second step, answered here :

i guess "good practice" of "if selectingapplet() return" in process? need process incoming apdu instead of simple return. can return data select normal way, careful return 0x9000 if select successful.

it must looked this:

public void process(apdu apdu)     {         byte[] buf = apdu.getbuffer();        if (selectingapplet())           {            //send data in buffer return;           }     }  

update:

to answer comment below answer :

i wrote below program :

package test;  import javacard.framework.apdu; import javacard.framework.iso7816; import javacard.framework.applet; import javacard.framework.isoexception; import javacard.framework.util;  public class test extends applet {      public static final byte[] res = { (byte) 0x00, (byte) 0x00, (byte) 0x3b,             (byte) 0xad, (byte) 0x3f, (byte) 0x00, (byte) 0x01, (byte) 0x00,             (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x16,             (byte) 0xb3, (byte) 0x03, (byte) 0x06, (byte) 0x04, (byte) 0x00,             (byte) 0x83, (byte) 0x8a, (byte) 0x83, (byte) 0x8a, (byte) 0x00,             (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x3b, (byte) 0xad,             (byte) 0x00, (byte) 0x00, (byte) 0x3b, (byte) 0xad, (byte) 0x2f,             (byte) 0x06, (byte) 0x02 };      public static void install(byte[] barray, short boffset, byte blength) {         new test.test()                 .register(barray, (short) (boffset + 1), barray[boffset]);     }      public void process(apdu apdu) {         if (selectingapplet()) {             return;         }          byte[] buf = apdu.getbuffer();          if (buf[iso7816.offset_cla] == (byte)0xa0 && buf[iso7816.offset_ins] == (byte) 0xa4 && buf[iso7816.offset_p1] == (byte) 0x00&& buf[iso7816.offset_p2] == (byte) 0x00                  && buf[iso7816.offset_lc] == (byte) 0x02 && buf[iso7816.offset_lc + 1] == (byte) 0x7f  && buf[iso7816.offset_lc + 2] == (byte) 0x20) {             isoexception.throwit((short) 0x9f23);         } else if (buf[iso7816.offset_cla] == (byte) 0xa0 && buf[iso7816.offset_ins] == (byte) 0xc0  && buf[iso7816.offset_p1] == (byte) 0x00                  && buf[iso7816.offset_p2] == (byte) 0x00  && buf[iso7816.offset_p2+1] == (byte) 0x23 ) {             util.arraycopynonatomic(res, (short) 0, buf, (short) 0, (short) 35);             apdu.setoutgoingandsend((short) 0, (short) 35);          } else {             isoexception.throwit((short) 0x9090);         }     } } 

then installed default selected applet :

commandline> gp -install e:\soq.cap --default  commandline> 

and send apdu commands :

commandline> osc.exe -s a0a40000027f20 -s a0c0000023 using reader card: acs ccid usb reader 0 sending: a0 a4 00 00 02 7f 20 received (sw1=0x9f, sw2=0x23) sending: a0 c0 00 00 23 received (sw1=0x90, sw2=0x00): 00 00 3b ad 3f 00 01 00 00 00 00 00 16 b3 03 06 ..;.?........... 04 00 83 8a 83 8a 00 03 00 00 3b ad 00 00 3b ad ..........;...;. 2f 06 02                                        /.. 

it seems works wanted.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -