Page 1 of 1

jCardSim as Javacard Applet debugger

Posted: Wed Aug 26, 2015 3:09 am
by UNKNwYSHSA
Today, i use the jCardSim to simulate an javacard, and i can debug my applet code with eclipse java.
But, when install the applet, if my code as following:

Code: Select all

   public static void install(byte[] bArray, short bOffset, byte bLength) {
      new TestApplet().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
   }

There is an exception raised;
when my code as following:

Code: Select all

   public static void install(byte[] bArray, short bOffset, byte bLength) {
      new TestApplet().register();
   }

The install operation process succeeded;
What's the wrong?

Re: jCardSim as Javacard Applet debugger

Posted: Sat Aug 29, 2015 11:13 pm
by UNKNwYSHSA
Oh no, the problem here, the authors did not do a good job handling this code.

Code: Select all

    /* Simulator.class */
    /**
     * Install
     * <code>Applet</code> into Simulator without installing data
     *
     * @param aid applet aid or null
     * @param appletClass applet class
     * @return applet <code>AID</code>
     * @throws SystemException if <code>appletClass</code> not instanceof
     * <code>javacard.framework.Applet</code>
     */
    public AID installApplet(AID aid, Class<? extends Applet> appletClass) throws SystemException {
        return installApplet(aid, appletClass, new byte[]{}, (short) 0, (byte) 0);
    }

Re: jCardSim as Javacard Applet debugger

Posted: Thu Aug 09, 2018 1:04 am
by hosseinpro
How can I run jCardSim in Eclipse?

Re: jCardSim as Javacard Applet debugger

Posted: Thu Aug 09, 2018 4:38 am
by kuafu
https://www.slideshare.net/ssusered0e6d/con1160
https://github.com/licel/jcardsim
This slide maybe help you.

Code: Select all

/ 1. create simulator
CardSimulator simulator = new CardSimulator();

// 2. install applet
AID appletAID = AIDUtil.create("F000000001");
simulator.installApplet(appletAID, HelloWorldApplet.class);

// 3. select applet
simulator.selectApplet(appletAID);

// 4. send APDU
CommandAPDU commandAPDU = new CommandAPDU(0x00, 0x01, 0x00, 0x00);
ResponseAPDU response = simulator.transmitCommand(commandAPDU);

// 5. check response
assertEquals(0x9000, response.getSW());