javacard - Smartcard with different historical bytes depending on interface -


i know if there way of changing historical bytes automatically power smartcard, in order have different response if on contact or contactless.

in javacard can use setatrhistbytes, , call depending on access interface. changes reflected on next power of card. want set them intermediately.

ta

actually contact-less interface has no attribute named atr. because atr contact interface only. counterpart on contactless interface named ats.

as said in question, can change atr using setatrhistbytes of global platform apis. here description of method:

setatrhistbytes

public static boolean setatrhistbytes(byte[] babuffer, short soffset, byteblength)

for contact cards according iso/iec 7816-4 , type contactless cards according iso/iec 14443-3, method sets historical bytes. sequence of bytes visible on subsequent power-up or reset.

notes:

• open locates entry of current applet context in globalplatform registry , verifies application has card reset privilege current card i/o interface;

• open responsible synchronizing length of historical bytes in format character t0 of atr.

parameters:

babuffer - source byte array containing historical bytes. must global array.

soffset - offset of historical bytes within source byte array.

blength - number of historical bytes.

returns:

true if historical bytes set, false if application not have required privilege.

as see in notes section, applet must has card reset privilege. without privilege, can't change historical bytes. use below command in globalplatformpro tool install applet card reset privilege:

commandline> gp.exe -install <pathtoyourapplet\apple.cap> --default 

i wrote program change atr of java card. can try it. (anyway, i'm not sure it)

package testatr;  import org.globalplatform.gpsystem;  import javacard.framework.apdu; import javacard.framework.applet; import javacard.framework.iso7816; import javacard.framework.isoexception;  public class historicalbyteschanger extends applet {     public static byte[] state = { (byte) 0, (byte) 0 };     public static byte[] histbytearray = { (byte) 0x01, (byte) 0x02,             (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,             (byte) 0x08, (byte) 0x09, (byte) 0x0a };      public static void install(byte[] barray, short boffset, byte blength) {         new historicalbyteschanger().register(barray, (short) (boffset + 1), barray[boffset]);     }      public void process(apdu apdu) {         if (selectingapplet()) {             return;         }          byte[] buf = apdu.getbuffer();         switch (buf[iso7816.offset_ins]) {         case (byte) 0x00:             gpsystem.setatrhistbytes(histbytearray, (short) 0, (byte) 10);             histbytearray[0] = (byte) (histbytearray[0] + 1);             break;          default:             isoexception.throwit(iso7816.sw_ins_not_supported);         }     }  } 

i wonder if can change ats or not. anyway if want have different atr , ats (normally different default!), need change atr.

take @ q&a , comments


Comments