Our Online Store have the new products: RFID antenna board. Currently it can work with JC10M24R and JCOP4 card chips.
Compared with normal cards, the antenna board module has a smaller size and fixed holes, which is easy to integrate in the IOT(Internet Of Things) project.

change the javacard Historical Bytes

Communication

Moderator: UNKNwYSHSA

Tarantino
Posts: 101
Joined: Wed Aug 19, 2015 1:56 am
Points :478
Contact:

change the javacard Historical Bytes

Post by Tarantino » Tue Aug 25, 2015 2:17 am

I am looking for a way to change the historical bytes of my javacard.
Is there any ways to do this?
It's very thankful for your help.
The greatest glory in living lies not in never falling, but in rising every time we fall.--Nelson Mandela

User avatar
horse dream
Posts: 76
Joined: Thu May 21, 2015 11:48 pm
Points :138
Contact:

Re: change the javacard Historical Bytes

Post by horse dream » Wed Aug 26, 2015 8:53 am

Maybe you can use the below applet.

Code: Select all

public class HistoricalBytesChanger extends Applet {
    public static byte[] state = { (byte) 0, (byte) 0 };
    //change the Historical Bytes you want
    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);
        }
    }

}

After you install it successfully into you card, set the card reset privilege to this applet.

Bob2002
Posts: 36
Joined: Wed Jul 29, 2015 10:50 pm
Points :1218
Contact:

Re: change the javacard Historical Bytes

Post by Bob2002 » Wed Aug 26, 2015 9:53 pm

Another sample come from oracle community.

Code: Select all

/**
 *
 */
package hands_on_setATRHistBytes;

import javacard.framework.*;
import visa.openplatform.OPSystem;

/**
 * @author sonnyyu
 *
 */
public class hands_on_setATRHistBytes_cls extends Applet {
     private static final byte[] newATRHistory  = { 
          (byte)'J', (byte)'C', (byte)'O', (byte)'P', (byte)'4', (byte)'1', (byte)'V', (byte)'2', (byte)'2', (byte)'1'
          } ;
     private static final byte[] newATRHistory1  = { 
          (byte)'J', (byte)'C', (byte)'O', (byte)'P', (byte)'4', (byte)'1', (byte)'V', (byte)'2', (byte)'2', (byte)'3'
          } ;
     public static void install(byte[] bArray, short bOffset, byte bLength) {
          // GP-compliant JavaCard applet registration
          new hands_on_setATRHistBytes_cls().register(bArray,
                    (short) (bOffset + 1), bArray[bOffset]);
     }

     public void process(APDU apdu) {
          // Good practice: Return 9000 on SELECT
          if (selectingApplet()) {
               return;
          }

          byte[] buf = apdu.getBuffer();
          // good practice: If you don't know the CLA, say so:
          if (buf[ISO7816.OFFSET_CLA] != 0) ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
          switch (buf[ISO7816.OFFSET_INS]) {
          case (byte) 0x00:
               if (GPSystem.setATRHistBytes(newATRHistory, (short)0, (byte)newATRHistory1.length))
               {
                    return;
               }
               else
               {
                    ISOException.throwIt(ISO7816.SW_WARNING_STATE_UNCHANGED);
               }
          case (byte) 0x01:
               if (GPSystem.setATRHistBytes(newATRHistory1, (short)0, (byte)newATRHistory1.length))
               {
                    return;
               }
               else
               {
                    ISOException.throwIt(ISO7816.SW_WARNING_STATE_UNCHANGED);
               }               
          default:
               // good practice: If you don't know the INStruction, say so:
               ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
          }
     }
}

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 19 guests

JavaCard OS : Disclaimer