Skip to Main Content

Java Card

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Newbie question about JCWDE

PixantLoJan 9 2013 — edited Jan 27 2013
Hello,

I'm sending that message because I'm starting with java card applets and I'm a bit confused about the testing.
I have the eclipse 3.2 and I installed succesfully the eclipsejcde with java card kit 2.2.2 and I started a java card project and used a simple applet (hello world).specifying the AID for the project and applet.

Then I created the .cap with the convert option from JCDE and then generated the scripts but I'm not sure the APDU I have to send to interact with the applet using JCWDE.

The applet I'm using is the following:
package hello;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import javacard.framework.Util;

public class HelloWorld extends Applet
{
/** The String "Hello" */
private final static byte[] hello =
{ 0x48, 0x65, 0x6c, 0x6c, 0x6f } ;

/** Basic Java Card applet registration */
public static void install(byte[] bArray, short bOffset, byte bLength) {
new HelloWorld().register();
}

/**
* Method that processes APDUs. The only accepted command is
* <code>00 40 00 00 00</code>, which returns the string "Hello".
* All other commands (except SELECT) are rejected.
*/
public void process(APDU apdu) {
// Good practice: Return 9000 on SELECT
if (selectingApplet()) {
return;
}

byte[] buf = apdu.getBuffer();

switch (buf[ISO7816.OFFSET_INS]) {
case (byte) 0x40:
Util.arrayCopy(
hello,(byte)0,buf,ISO7816.OFFSET_CDATA,(byte)5);
apdu.setOutgoingAndSend(
ISO7816.OFFSET_CDATA,(byte)5);
break;
default:
// good practice: If you don't know the INStruction, say so:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
}
}

And the script this one:

powerup;
// Select the installer applet
0x00 0xA4 0x04 0x00 0x09 0xa0 0x00 0x00 0x00 0x62 0x03 0x01 0x08 0x01 0x7F;
// create HelloWorld applet
0x80 0xB8 0x00 0x00 0xd 0xb 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x00 0x00 0x00 0x7F;

// select?¿
0x00 0x40 0x00 0x00 0x00 0x7F;
powerdown;

The responses from the JCWDE:

Java Card 2.2.2 APDU Tool, Version 1.3
Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
Opening connection to localhost on port 9025.
Connected.
Received ATR = 0x3b 0xf0 0x11 0x00 0xff 0x00
CLA: 00, INS: a4, P1: 04, P2: 00, Lc: 09, a0, 00, 00, 00, 62, 03, 01, 08, 01, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b8, P1: 00, P2: 00, Lc: 0d, 0b, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, 00, 00, Le: 0b, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, 00, SW1: 90, SW2: 00
CLA: 00, INS: 40, P1: 00, P2: 00, Lc: 00, Le: 00, SW1: 6d, SW2: 00

Thanks for your help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 24 2013
Added on Jan 9 2013
11 comments
1,233 views