Verify user pin on a smart card & load a cap file on a card (with eclipse)

I have been able install JCWDE (Java card development Kit) successfully on eclipse.Basically all I need to do is verify user pin on a smart card.As in first set a pin and then verify it.
To begin with I have referred many tutorials (here: http://www.javaworld.com/jw-07-1999/jw-07-javacard.html?page=1) and implemented the wallet code in eclipse.I have the cap file generated and the scripts generated.I am not sure how to load it on the smart card with eclipse.
I tried to deploy the cap file but it keeps saying connected.Also when we initiate the applet I get the same result.
output:
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 9032.
Connected.
I have also tried : http://www.cs.ru.nl/E.Poll/hw/practical.html ........ but no luck.
I have the wallet.cap ,wallet.exp ,wallet.jca ,wallet.opt create.script, select,cap-download.scripts files already generated in eclipse.
How does a successfully implemented applet code on a smart card work?How does this wallet code work if it is successfully implemented ? Does it have like some GUI which prompts the user to enter the pin?
Wallet code for reference :
package com.sun.javacard.samples.wallet;
import javacard.framework.*;
public class Wallet extends Applet {
/* constants declaration */
// code of CLA byte in the command APDU header
final static byte Wallet_CLA =(byte)0x80;
// codes of INS byte in the command APDU header
final static byte VERIFY = (byte) 0x20;
final static byte CREDIT = (byte) 0x30;
final static byte DEBIT = (byte) 0x40;
final static byte GET_BALANCE = (byte) 0x50;
// maximum balance
final static short MAX_BALANCE = 0x7FFF;
// maximum transaction amount
final static byte MAX_TRANSACTION_AMOUNT = 127;
// maximum number of incorrect tries before the
// PIN is blockedd
final static byte PIN_TRY_LIMIT =(byte)0x03;
// maximum size PIN
final static byte MAX_PIN_SIZE =(byte)0x08;
// signal that the PIN verification failed
final static short SW_VERIFICATION_FAILED =
0x6300;
// signal the the PIN validation is required
// for a credit or a debit transaction
final static short SW_PIN_VERIFICATION_REQUIRED =
0x6301;
// signal invalid transaction amount
// amount > MAX_TRANSACTION_AMOUNT or amount < 0
final static short SW_INVALID_TRANSACTION_AMOUNT = 0x6A83;
// signal that the balance exceed the maximum
final static short SW_EXCEED_MAXIMUM_BALANCE = 0x6A84;
// signal the the balance becomes negative
final static short SW_NEGATIVE_BALANCE = 0x6A85;
/* instance variables declaration */
OwnerPIN pin;
short balance;
private Wallet (byte[] bArray,short bOffset,byte bLength) {
// It is good programming practice to allocate
// all the memory that an applet needs during
// its lifetime inside the constructor
pin = new OwnerPIN(PIN_TRY_LIMIT, MAX_PIN_SIZE);
byte iLen = bArray[bOffset]; // aid length
bOffset = (short) (bOffset+iLen+1);
byte cLen = bArray[bOffset]; // info length
bOffset = (short) (bOffset+cLen+1);
byte aLen = bArray[bOffset]; // applet data length
// The installation parameters contain the PIN
// initialization value
pin.update(bArray, (short)(bOffset+1), aLen);
register();
} // end of the constructor
public static void install(byte[] bArray, short bOffset, byte bLength) {
// create a Wallet applet instance
new Wallet(bArray, bOffset, bLength);
} // end of install method
public boolean select() {
// The applet declines to be selected
// if the pin is blocked.
if ( pin.getTriesRemaining() == 0 )
return false;
return true;
}// end of select method
public void deselect() {
// reset the pin value
pin.reset();
public void process(APDU apdu) {
// APDU object carries a byte array (buffer) to
// transfer incoming and outgoing APDU header
// and data bytes between card and CAD
// At this point, only the first header bytes
// [CLA, INS, P1, P2, P3] are available in
// the APDU buffer.
// The interface javacard.framework.ISO7816
// declares constants to denote the offset of
// these bytes in the APDU buffer
byte[] buffer = apdu.getBuffer();
// check SELECT APDU command
if (apdu.isISOInterindustryCLA()) {
if (buffer[ISO7816.OFFSET_INS] == (byte)(0xA4)) {
return;
} else {
ISOException.throwIt (ISO7816.SW_CLA_NOT_SUPPORTED);
// verify the reset of commands have the
// correct CLA byte, which specifies the
// command structure
if (buffer[ISO7816.OFFSET_CLA] != Wallet_CLA)
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
switch (buffer[ISO7816.OFFSET_INS]) {
case GET_BALANCE:
getBalance(apdu);
return;
case DEBIT:
debit(apdu);
return;
case CREDIT:
credit(apdu);
return;
case VERIFY:
verify(apdu);
return;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
} // end of process method
private void credit(APDU apdu) {
// access authentication
if ( ! pin.isValidated() )
ISOException.throwIt(SW_PIN_VERIFICATION_REQUIRED);
byte[] buffer = apdu.getBuffer();
// Lc byte denotes the number of bytes in the
// data field of the command APDU
byte numBytes = buffer[ISO7816.OFFSET_LC];
// indicate that this APDU has incoming data
// and receive data starting from the offset
// ISO7816.OFFSET_CDATA following the 5 header
// bytes.
byte byteRead =
(byte)(apdu.setIncomingAndReceive());
// it is an error if the number of data bytes
// read does not match the number in Lc byte
if ( ( numBytes != 1 ) || (byteRead != 1) )
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
// get the credit amount
byte creditAmount = buffer[ISO7816.OFFSET_CDATA];
// check the credit amount
if ( ( creditAmount > MAX_TRANSACTION_AMOUNT)
|| ( creditAmount < 0 ) )
ISOException.throwIt(SW_INVALID_TRANSACTION_AMOUNT);
// check the new balance
if ( (short)( balance + creditAmount) > MAX_BALANCE )
ISOException.throwIt(SW_EXCEED_MAXIMUM_BALANCE);
// credit the amount
balance = (short)(balance + creditAmount);
} // end of deposit method
private void debit(APDU apdu) {
// access authentication
if ( ! pin.isValidated() )
ISOException.throwIt(SW_PIN_VERIFICATION_REQUIRED);
byte[] buffer = apdu.getBuffer();
byte numBytes =
(byte)(buffer[ISO7816.OFFSET_LC]);
byte byteRead =
(byte)(apdu.setIncomingAndReceive());
if ( ( numBytes != 1 ) || (byteRead != 1) )
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
// get debit amount
byte debitAmount = buffer[ISO7816.OFFSET_CDATA];
// check debit amount
if ( ( debitAmount > MAX_TRANSACTION_AMOUNT)
|| ( debitAmount < 0 ) )
ISOException.throwIt(SW_INVALID_TRANSACTION_AMOUNT);
// check the new balance
if ( (short)( balance - debitAmount ) < (short)0 )
ISOException.throwIt(SW_NEGATIVE_BALANCE);
balance = (short) (balance - debitAmount);
} // end of debit method
private void getBalance(APDU apdu) {
byte[] buffer = apdu.getBuffer();
// inform system that the applet has finished
// processing the command and the system should
// now prepare to construct a response APDU
// which contains data field
short le = apdu.setOutgoing();
if ( le < 2 )
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
//informs the CAD the actual number of bytes
//returned
apdu.setOutgoingLength((byte)2);
// move the balance data into the APDU buffer
// starting at the offset 0
buffer[0] = (byte)(balance >> 8);
buffer[1] = (byte)(balance & 0xFF);
// send the 2-byte balance at the offset
// 0 in the apdu buffer
apdu.sendBytes((short)0, (short)2);
} // end of getBalance method
private void verify(APDU apdu) {
byte[] buffer = apdu.getBuffer();
// retrieve the PIN data for validation.
byte byteRead = (byte)(apdu.setIncomingAndReceive());
// check pin
// the PIN data is read into the APDU buffer
// at the offset ISO7816.OFFSET_CDATA
// the PIN data length = byteRead
if ( pin.check(buffer, ISO7816.OFFSET_CDATA,
byteRead) == false )
ISOException.throwIt(SW_VERIFICATION_FAILED);
} // end of validate method
} // end of class Wallet
Any help on this would highly appreciated !! :)

Hi,
Thanks a lot for reply.But I am not sure as to how can I delete the simulator.
All I want to do is write a pin on the smart card and verify it.But I am not being able to deploy the cap file or initiate the applet.
Also for passing the pin correct me if I am wrong........ according to what you said and what I have understood
If the code is like this :
public static void install(byte[] bArray, short bOffset, byte bLength) {
// create a Wallet applet instance
new Wallet(bArray, bOffset, bLength);
} // end of install method
byte aLen = bArray[bOffset]; // applet data length
// The installation parameters contain the PIN
// initialization value
pin.update(bArray, (short)(bOffset+1), aLen);
Lets say my pin is : 1234
then I would pass it here.....
new Wallet(bArray, 1234, bLength);

Similar Messages

  • How to Load the cap file to the SSD with DAP

    Dear everybody,
    How to use upload, load and install command to load cap file to the SSD with DAP?
    My step:
    1 I have already input the DAP Key into the SSD.
    2 Select ISD
    3 Do auth
    4 Upload -s ssdaid -d "XXX.cap", but JCOP return 6985.
    I don't kown why.
    Thank you very much.
    Edited by: Ivy_D on May 20, 2009 12:16 AM

    (The JCOP3.1,1 Eclipse Plugin's emulator) install for load still complains 6985 after i did these belows step by step. I will appreciate yours helps very much!
    1: install a new security domain.
    cm> install -s -b -i A000000003535042 A0000000035350 A000000003535041
    => 80 E6 0C 00 20 07 A0 00 00 00 03 53 50 08 A0 00 .... ......SP...
    00 00 03 53 50 41 08 A0 00 00 00 03 53 50 41 01 ...SPA......SPA.
    C0 02 C9 00 00 00 ......
    (5227 usec)
    <= 90 00
    cm> /select A000000003535041
    => 00 A4 04 00 08 A0 00 00 00 03 53 50 41 00 ..........SPA.
    (2303 usec)
    <= 6F 10 84 08 A0 00 00 00 03 53 50 41 A5 04 9F 65 o........SPA...e
    01 FF 90 00 ....
    Status: No Error
    2.1 use the ISD key to build a security channle by ISD to personalize the new secuirty domain
    cm> set-key 255/1/DES-ECB/404142434445464748494a4b4c4d4e4f 255/2/DES-ECB/404142434445464748494a4b4c4d4e4f 255/3/DES-ECB/404142434445464748494a4b4c4d4e4f
    cm> auth
    => 80 50 00 00 08 40 74 01 18 F9 FA 68 07 00 [email protected]..
    (2274 usec)
    <= 00 00 57 F3 97 D9 7F 72 88 55 FF 02 00 02 81 8D ..W....r.U......
    91 65 B4 F2 A9 29 B2 C0 A4 AD FD C5 90 00 .e...)........
    Status: No Error
    => 84 82 00 00 10 DE 01 A2 F1 79 12 8F 2E 87 6F FE .........y....o.
    63 0E E4 5D 40 c..]@
    (1969 usec)
    cm> put-pub-key --tokenpin 123456 115 c:/gptest.p12
    => 80 D8 00 01 88 73 A1 80 EA 15 24 8C 5C 26 E1 31 .....s....$.\&.1
    02 FE B1 44 0E 37 4F D5 49 29 25 14 5C 7B E0 63 ...D.7O.I)%.\{.c
    87 0C E8 B8 03 FF AF 0B F2 2B 54 6A 16 4A D6 8F .........+Tj.J..+
    EE B6 E0 1A 29 F2 13 E8 2B 04 FC 5F 2F D2 51 ED    ....)....._/.Q._
    _18 40 D3 E1 AF 36 CA A2 58 45 AC 38 3D 5F D4 56 [email protected]=_.V
    56 D8 87 5D 45 86 B9 36 F0 07 88 AD 59 78 A1 03 V..]E..6....Yx..
    2D F4 DE E9 51 E3 75 65 E3 2B B7 49 11 A5 E3 75 -...Q.ue.+.I...u
    39 25 1C 44 FB D5 3C 57 40 DD 64 22 D0 0A 8E 88 9%.D..<[email protected]"....
    2C 52 7B E2 67 A4 0B 65 A0 03 01 00 01 00 ,R{.g..e......
    (2614 usec)
    <= 73 90 00
    cm> card-info
    => 80 F2 80 00 02 4F 00 00 .....O..
    (1488 usec)
    <= 08 A0 00 00 00 03 00 00 00 01 9E 90 00 .............
    Status: No Error
    => 80 F2 40 00 02 4F 00 00 [email protected]..
    (2125 usec)
    <= 08 A0 00 00 00 03 53 50 42 0F C0 90 00 ......SPB....
    Status: No Error
    => 80 F2 10 00 02 4F 00 00 .....O..
    (1794 usec)
    <= 07 A0 00 00 00 03 53 50 01 00 01 08 A0 00 00 00 ......SP........
    03 53 50 41 90 00 .SPA..
    Status: No Error
    Card Manager AID : A000000003000000
    Card Manager state : OP_READY
    Sec. Domain:{color:#ff0000}PERSONALIZED (SV------) A000000003535042{color}
    Load File : LOADED (--------) A0000000035350 (Security Domain)
    Module : A000000003535041
    cm> /cap-sign --tokenpin 123456 a.cap A000000003535042 c:/gptest.p12
    cm> /cap-info a.cap
    SHA (Load File data): {color:#ff0000}1BD8F3CCC0042A5EEF9845FA3C667834051F4FAD{color} -- Load File Data Block Hash
    SHA (Load File dbg) : A36B4AED89FF8C4B8D8BBDDEB40757E36477143F
    SHA (Load File) : 0D4AD84E20D00C26ABA1BF5677636414234F5743
    DAP block(s) :
    DAP block : 1
    AID : A000000003535042
    Signature : 19F414292C00F9B7C89E7341A13AF15B
    CCF90D17A112418EAF556B5172EBE39C
    E05DF0CDDD68EFD2559CC7EC591878DF
    14B5C0FBC5C6CF6A0DC6E50B4AC99216
    7D6C46DC4098E0A1AC11DB69596E4A71
    F34CBFBD7DFABA88C6E8C2348FF8A9FC
    A8E22074B4D1B9D2AB5993A539BE8E1F
    6187252B9912909AE1DA4E5FAE866960
    Algorithm : VOP 2.0.1'
    Signed by : c=CN, st=beijing, l=beijing, o=logis, ou=logiscn, cn=gptest
    Load Token(s) : none
    Install Token(s) : none
    then send install for load
    cm> send 80E602002908{color:#ff0000}72666370626F6332{color}08{color:#ff0000}A000000003535042{color}14{color:#ff0000}1BD8F3CCC0042A5EEF9845FA3C667834051F4FAD{color}000000
    => 80 E6 02 00 29 08 72 66 63 70 62 6F 63 32 08 A0
    00 00 00 03 53 50 42 14 1B D8 F3 CC C0 04 2A 5E
    EF 98 45 FA 3C 66 78 34 05 1F 4F AD 00 00 00
    (3108 usec)
    <= 69 85 i.
    Status: Conditions of use not satisfied

  • How to load a .cap file

    i am new to smartcard programming...
    now i am able to compile sample card program and and generated .cap file.
    now my question is how to load that .cap file onto simulator and also smartcard.
    my requirement is to store some value on smart card and retrive that value and update it. what is the process to achive this.plz mail me in detail to my id : [email protected] or [email protected]
    advance thanks for mailing to me ....

    i am new to smartcard programming...
    now i am able to compile sample card program and and generated .cap file.
    now my question is how to load that .cap file onto simulator and also smartcard.
    my requirement is to store some value on smart card and retrive that value and update it. what is the process to achive this.plz mail me in detail to my id : [email protected] or [email protected]
    advance thanks for mailing to me ....

  • Upload cap file by net on client card, and protect cap file. Encode cap?

    How upload cap file by internet on client card, and protect cap file. Encode cap file?
    cap file > Server (keys) --> internet --> Client Program --> JCOP10 card
    Can I use secure channel protocol ? How ?

    Thanks for response.
    Problem for me is communication between client program(computer) -> reader -> card.     
    The cap file is in Bin format.
    Transmission can by easy scanned. How to protect this step of upload process?.
    Internet is no problem.
    My English is pure, and I have problem to understand specification.
    Can I upload, install cap file encoded by Secure Channel Protocol '02' ?
    If yes, then some example, log file can help me understand how to do this and how build APDU commend. I Use my program (Delphi) to communicate with reader and card.

  • How to load the .cap file in a Smart Card?

    Dear All,
    Hello..!!
    I am using JCDK 2.2 and have used Eclipse JCDK.
    I have written a simple read/write applet and created a .cap file using Eclipse's Converter Java Card tool.
    What is the next step to be done?
    I have a smart card device and have installed its drivers.
    When do the APDU commands come into picture?
    Expecting help.
    Thanks a lot.
    Regards,
    Suril

    Suril Sarvaiya wrote:
    Hi Shane....
    Thnx a lot....
    I have downloaded GP-Shell 1.4.4
    When I open its application and write any command and press enter ; the app window closes immendiately.
    Can you please help me on this?
    One more thing Shane......
    I'm writig a java class using javax.smartcardio
    I have installed drivers of Omnikey 3021
    but the TerminalFactory is not detecting it?
    Any idea on that?
    Thanks again...
    Regards,
    SurilHi all,
    Is Mr. thread starter has solved his problem?
    I profit this thread to post my question. I'm working with new environment and I have problem loading cap file into my smartcard.
    specification come first :-)
    - My smartcard is said to be JC2.2.1 and GP2.1.1 compatible
    - My code (for testing) is written in Java under eclipse Helios service 2 with JavaCard plugin (for JC2.2.2)
    I compile my code with JDK 1.3 (for compatible version) and using the JC plugin to generate cap file (along with exp and jca).
    My problem is exactly the same as one that was posted in this forum about 2 years ago but is not answered :-)
    [Problem Loading Application to Card |http://forums.oracle.com/forums/thread.jspa?threadID=1749334&tstart=420]
    + I successfully authenticate with smartcard
    + APDU command Install for Load is executed successfully
    + BUT the APDU command LOAD file fails with returned status word is 6424
    For details, I post here my javacard applet code and APDU command executed with my tool:
    package mksAuthSys;
    import javacard.framework.APDU;
    import javacard.framework.Applet;
    import javacard.framework.ISO7816;
    import javacard.framework.ISOException;
    import javacard.framework.OwnerPIN;
    public class Jcardlet extends Applet {
         private final static byte[] myPIN = { (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04};
         final static byte Jcardlet_CLA =(byte)0xB0;
         final static byte VERIFY = (byte) 0x20;
         final static byte PIN_TRY_LIMIT =(byte)0x03;
         final static byte MAX_PIN_SIZE =(byte)0x08;
         final static short SW_VERIFICATION_FAILED = 0x6300;
         OwnerPIN pin;
         private Jcardlet() {
              pin = new OwnerPIN(PIN_TRY_LIMIT, MAX_PIN_SIZE);
              pin.update(myPIN, (byte) 0, (byte) 4 );
             register();
         public static void install(byte bArray[], short bOffset, byte bLength)
                   throws ISOException {
              new Jcardlet().register();
         public boolean select() {
              if ( pin.getTriesRemaining() == 0 ) return false;
             return true;     
         public void deselect(){
              pin.reset();
         //@Override
         public void process(APDU apdu) throws ISOException {
              // TODO Auto-generated method stub
              byte[] buffer = apdu.getBuffer();
              if ((buffer[ISO7816.OFFSET_CLA] == 0) &&
                      (buffer[ISO7816.OFFSET_INS] == (byte)(0xA4))) return;          
              if (buffer[ISO7816.OFFSET_CLA] != Jcardlet_CLA)
                    ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);          
              switch (buffer[ISO7816.OFFSET_INS]) {
               case VERIFY: verify(apdu);
                 return;
               default: ISOException.throwIt (ISO7816.SW_INS_NOT_SUPPORTED);
         private void verify(APDU apdu) {
              // TODO Auto-generated method stub
             byte[] buffer = apdu.getBuffer();
             // retrieve the PIN data for validation.
             byte byteRead = (byte)(apdu.setIncomingAndReceive());
             // check pin
             // the PIN data is read into the APDU buffer
             // at the offset ISO7816.OFFSET_CDATA
             // the PIN data length = byteRead
             if ( pin.check(buffer, ISO7816.OFFSET_CDATA,byteRead) == false )
               ISOException.throwIt(SW_VERIFICATION_FAILED);          
    }And my APDU command:
    Loading "D:\mksAuthSys.cap" ...
    T - 80F28000024F00
    C - 08A000000003000000079E9000
    ISD AID : A000000003000000
    T - 80E602001508F23412345610000008A00000000300000000000000
    C - 009000
    T - 80E80000C8C482018B010012DECAFFED010204000108F23412345610000002001F0012001F000C001500420012009D0011001C0000009F00020001000402010004001502030107A0000000620101000107A000000062000103000C0108F234123456100001002306001200800301000104040000003DFFFF0030004507009D000510188C0003188F00013D0610088C00028700AD007B000403078B0005188B00067A02308F00073D8C00088B00067A0110AD008B00096104037804780110AD008B000A7A0221198B000B2D1A0300
    C - 6424
    Stopped loading due to unexpected status words.Urgently look forward to hearing from you.
    Thanks a bunch in advance
    Best Regards,
    JDL

  • Unable to load the cap file to the JCOP card

    I develop my applet by JCOP IDE and it works well in the VM. But when I want to load it on my JCOP card, I face a problem. it can successful send the 1st 254 bytes, but always return 6A86 when send the second 254 bytes to the card.
    Status: Incorrect parameters (P1,P2)
    Error code: 6a86 (Incorrect parameters (P1,P2))
    Offending APDU: 6A86
    Wrong response APDU.
    I don't know why this happen. Can anyone show some light on that. Thank you in advance.

    Have you written your own loader for this ?
    What is the prompt "cm>" from, is that a standard Java Card tool ?
    Looking at the data I can see, its looks well formed. However when I wrote my own loader I found I could only send 239 bytes of data (255 - 16) otherwise I'd get an error. Maybe part of this is todo with the option of using M-DAP to MAC each APDU. FYI its a JCOP10 I'm using.
    Also my data was never concatentated, that is to say, check your 'FileSystem.cap' file with "unzip -tv FileSystem.cap" for the real CAP files. Each of these files never crossed an APDU boundary, the first one Header.cap (IIRC) is a small file, so my first APDU was less than 40 bytes of actual data (with C4 TLV data before it), certainly not 254 bytes.
    I'm not sure if this is allowed or not, I've plans to try it out soon and see myself since i've not read anything that says you can not do this.
    This is the only obvious difference I can see to other loader scripts and programs I have seen.

  • How to generate APDU to load a cap file?

    Below is a code to load a cap that I got here.
    public byte[] readJar(File file) throws IOException {
              int BLOCK_SIZE1;
              String[] xCaps;
              if(installDescriptor){
                   xCaps = iCapsWD;
              }else{
                   xCaps = iCapsWoD;
              JarFile jf = new JarFile(file);
              Enumeration e = jf.entries();
              byte[] result = new byte[(int)file.length()];
              int size = 0;
              int dsize = 0;
              JarEntry je;
              boolean found;
              InputStream is;
              //byte[] temp;
              for (int i = 0; i<xCaps.length; i++){
                   found = false;
                   e = jf.entries();
                   System.out.println("searching: "+xCaps);
                   while (e.hasMoreElements()){
                        je = (JarEntry)e.nextElement();
                        //System.out.println("component:"+je.getName());
                        if(je.getName().endsWith(xCaps[i])){
                             found = true;
                             is = jf.getInputStream(je);
                             int dim = (int)je.getSize();
                             //temp=new byte[dim];
                             System.out.println("found cap to install: "+xCaps[i]+" of length:"+dim);
                             try{
                                  //int dim = is.available();
                                  //is.read(temp);
                                  //printApdu(temp);
                                  is.read(result, size, dim);
                             }catch (Exception ex){
                                  ex.printStackTrace();
                                  System.exit( -1);
                             if(i==0){
                                  BLOCK_SIZE1 = dim+4;
                             }else if(i==1){//analyze directory.cap
                                  int component;
                                  int ddim;
                                  for (int h = 3; h<25; h += 2){
                                       component = (int)Math.floor((h-3)/2)+1;
                                       if(component==11&& !installDescriptor){//elimino descriptor da directory
                                            result[size+h] = 0;
                                            result[size+h+1] = 0;
                                       ddim = ((result[size+h]<<8)+result[size+h+1]);
                                       System.out.println("component size with tag: ["+component+"] "+ddim);
                                       dsize += ddim;
                             size += dim;
                             break;
                   if( !found){
                        if(i==3||i==7||i==10){
                             System.out.println("Not found cap component for optional installing: "+xCaps[i]);
                        }else{
                             System.out.println("Critical error: Not found cap component necessary for install:"+xCaps[i]);
                             System.exit( -1);
              byte[] fresult = new byte[size];
              System.arraycopy(result, 0, fresult, 0, size);
              FileOutputStream fo = new FileOutputStream("pcapdump.cap");
              fo.write(result);
              System.out.println("size="+size+", according to directory:"+dsize);
              return fresult;
    I open the result file of this program called "pcapdump.cap".
    However, when I compare APDU generated by Tool and APDU
    generated by this program , they are slightly different.
    I wonder why these 2 APDU results are different.
    Can anyone help me to corrent above code?
    Please~

    Please read the "Java Card Development Kit User&#8217;s Guide" Chapter 11. Using the Installer. There you find a detailed description how to install a java card applet.
    The JC-dev User's Guid comes as HTML & PDF document with the Java Card development Kit - subdirectory "doc".
    Jan

  • Help:  Problem in Uploading Cap File to JCOP41v22  Card

    Hi,
    I am new in Java Card development.
    Having successfully tested the simulation with HelloWorld Applet using JCOP Tools 3.1 on Eclipse, I tried to excecute the code using the real JCOP41V22 card, I encountered the following error message after the Cap File is uploaded:
    jcshell: Error code: 45d (0x045D)
    jcshell: Command failed: SCardTransmit(): 0x45d, PCSC failed with 0x45D: 0x45D (OK,--,(System))
    Unexpected error; aborting execution
    What could go wrong?
    Please endlighten.

    Finally, I got the answer from IBM Zurich Research Lab after sending 4 emails to three different email addresses there within a week.
    It boils down to the Gemplus USB GemPC430 smart card reader which is not fully ISO-compliant.
    After switching to Sclumberger Refelx USB reader, it works perfectly.
    CrreativeMan,
    I strongly recommend JCOP java card if you are keen to embark on the development. You need to install Eclispse Java IDE first, download the JCOP Tools and;
    - Buy an activation code at CHF 40 to make use of the Java Card Simulator
    - or buy a JCOP Engineering Sample Card at CHF 75. The activation code is bundled with the card. It will be activated automatically when you click Run Java Card Application the first time. Once activated, you can either work in simulation or real card condition.
    - As for the reader, I have just replied that Schlumberger Relext USB reader works fine.
    JCOP ordering information is at
    http://www.zurich.ibm.com/jcop/order/tools.html
    The delivery by Federal Express is very fast . Mine took three days only..
    I hope the above informatio will help.

  • "Cap file can not load on java card"

    Hi every one,
    My problem is :
    I created a cap file from my package .when I want to load cap file in the card, I got an error and loading was stoped.I opened the cap file with "HexEditor" program and I saw the version in the "Import.cap" file is "02 01", when I changed it to "00 01" my problem was solved and I could load the cap file in the card successfully.
    I would like to know what is the reason of this problem ,how the capfile gets "02 01" version ?
    And I would like to know, how can I find the version of sun library packages that are in the java card that I am working with(it is GemXpresso card).My mean is , the version of these packages on the card :
    A0000000620001 (java.lang)
    A0000000620101 (javacard.framework)
    A0000000620102 (javacard.security)
    A0000000620201 (javacardx.crypto)
    I 'll appreciated for any help.
    yours sincerely,
    Orchid

    Dear NewOrchid
    j2sdk-1_4_2_15-windows-i586-p.exe is 48.9 MB.
    i downloaded it from sun with using a proxy server software.
    if you like, i can send my software to your email.
    to Woj:
    if you use jdk1.5 for compiling and your card doesn't conform to
    java card 2.2.2 , you can not load your cap file on the card.

  • Cannot load cap file to G&D sm@rtCafe Expoert 2.0 Java card

    Hi all,
    I am new to JavaCard. I tried to load a HelloWorld cap file to G&D sm@rtCafe Expoert 2.0 Java card by using G&D Customizer 4.0. It can connect and open secure channel successfully. But when I tried to load the cap file into that card. It always provided this error:
    Error: PC/SC SCardTransmit returned error code 0x45D: unknown error code
    The cap file is the one in GPShell1.4.2. I tried other cap files, same error was provided. Anyone can give me some hints to solve this problem? Thank you very much!
    Edited by: fanfan on Nov 20, 2008 5:36 PM

    I think it may be the problem of JCDK version because G&D sm@rtCafe Expoert 2.0 Java card support JCDK2.1.1. So I compile and gen a new cap file of the HelloWord example in JCDK2.1.1 and tried to load this new cap to the javacard.
    But same error provided.
    Then I gen cap file of AppNull example in JCDK2.1.1 and load it to javacard. This time a get another error :
    Error: LOAD (1. of 1) response check failed with SW 6A 80
    any comments here?
    Edited by: fanfan on Nov 20, 2008 7:06 PM

  • How to Install .CAP file in the Java Card?

    Hi Friends..
    How to install *.CAP* file in the Java Card?..
    I've GPShell script as follows :
    mode_211
    enable_trace
    establish_context
    card_connect -readerNumber 2
    open_sc -security 1 -keyind 0 -keyver 0 -mac_key 404142434445464748494a4b4c4d4e4f -enc_key 404142434445464748494a4b4c4d4e4f
    install_for_load -pkgAID a00000006203010c01 -nvCodeLimit 500  -sdAID A000000003000000
    load -file HelloWorld.cap
    card_disconnect
    release_contextwith that script i can load HelloWorld.cap file successfully..
    Now, how to install the HelloWorld.cap file?..
    if i add script : load -file HelloWorld.cap i got this error :
    install -file HelloWorld.cap
    file name HelloWorld.cap
    Command --> 80E602001B09A00000006203010C0107A00000015100000006EF04C60201A80000
    Wrapped command --> 84E602002309A00000006203010C0107A00000015100000006EF04C60201
    A80030C859793049B85300
    Response <-- 6985
    install_for_load() returns 0x80206985 (6985: Command not allowed - Conditions of
    use not satisfied.)i ask this question because when i tried to select the applet through its AID, by this script :
    establish_context
    card_connect -readerNumber 2
    select -AID a00000006203010c0101i got this message error : select_application() returns 0x80216A82 (6A82: The application to be selected could not be found.)
    but there's exactly any that AID in my Java Card..
    here's is the list of AID from My Java Card :
    C:\GPShell-1.4.2>GPShell listgp211.txt
    mode_211
    enable_trace
    establish_context
    card_connect -readerNumber 3
    * reader name OMNIKEY CardMan 5x21-CL 0
    select -AID a000000003000000
    Command --> 00A4040008A000000003000000
    Wrapped command --> 00A4040008A000000003000000
    Response <-- 6F108408A000000003000000A5049F6501FF9000
    open_sc -security 1 -keyind 0 -keyver 0 -mac_key 404142434445464748494a4b4c4d4e4
    f -enc_key 404142434445464748494a4b4c4d4e4f // Open secure channel
    Command --> 80CA006600
    Wrapped command --> 80CA006600
    Response <-- 664C734A06072A864886FC6B01600C060A2A864886FC6B02020101630906072A864
    886FC6B03640B06092A864886FC6B040215650B06092B8510864864020102660C060A2B060104012
    A026E01029000
    Command --> 8050000008AAF7A87C6013BC0300
    Wrapped command --> 8050000008AAF7A87C6013BC0300
    Response <-- 0000715457173C2A8FC1FF0200937A55C288805D8F2A04CCD43FA7E69000
    Command --> 848201001023CA18742D36165ED992CFF2146C3D51
    Wrapped command --> 848201001023CA18742D36165ED992CFF2146C3D51
    Response <-- 9000
    get_status -element 10
    Command --> 80F21000024F0000
    Wrapped command --> 84F210000A4F004FF8BE1492F7275400
    Response <-- 0CF0544C00004D4F44554C415201000009A00000006203010C010100010AA000000
    06203010C01019000
    GP211_get_status() returned 2 items
    List of Ex. Load File (AID state Ex. Module AIDs)
    f0544c00004d4f44554c4152        1
    a00000006203010c01      1
            a00000006203010c0101
    card_disconnect
    release_contextPlease help me..
    And please correct me if i'm wrong,,
    Thanks in advance..

    Any suggestions for my question?..
    Please help me..
    Thanks in advance..

  • Sent step by step apdu command to load cap file into javacard

    Dear All,
    I have log file about process loading cap file into card:
    Loading "E:\Sample.cap" ...
    T - 80F28000024F00
    C - 08A000000003000000019E9000
    ISD AID : A000000003000000
    T - 80E602001407A000000132000108A00000000300000000000000
    C - 009000
    T - 80E80000C8C48209B6010011DECAFFED010202010107A000000132000102001F0011001F00000015009A005D0772000A00C8001B03E400020000000002000004001502000107A0000000620001000107A000000062010106005D80810000C20000810200800000FF000100000000810500FF0003000000028000130008010D000002CA02DE02E202E702EE02F602FB0308032B036204AA04C804E8000009040308020705060C0D00010D040308020705060C0D090A0B010707720003201D046D06048D00141C7500120001000300
    C - 009000
    T - 80E80001C800098F00163D1D8C001A77068D001401770110188C001B7A0220181D8C001C7A03101C026B07017F001D7A7B001D670D8F001F3D1C8C00207F001D7B001D1C8B00127B001D93038903290803290903290A03290B03290D03290E707F1506160E251100FF53290C160C606D1B1604160E41251100FF53290D160D605C191E160E41251100FF531505160E251100FF53435B290F160F6308160F0245290F160F10096D075909017005590801160F10146D27160D160C432910161063081610024529101610100C6D0700
    C - 009000
    T - 80E80002C8590B01700B161010106F05590A01590E01160E1607A4FF7F1100961609411608430547290F160F630703290F700E160F1100FF6F071100FF290FAD0005160F5B38104B160B41160A43290F160F630703290F700E160F1100FF6F071100FF290FAD0007160F5B387A045603290503290603290704290803290916066008160610096F0F1B1607590701251100FF53290616056008160510096F0E191E590201251100FF532905160610096F2E160510096F281605160643290A160A6308160A0245290A160A10086D00
    C - 009000
    T - 80E80003C80C16091008160A434129095908017042160610096F0E590801160565355905FF7030160510096F0E590801160665235906FF701E160616056F0E16061605432906032905700C1605160643290503290616071604A4FF5D1609106445290916096307117FFF29091609160847290916091100FF6F071100FF2909AD000316095B387A0430191E0441251100FF5375002D00020081000D0082001B18068901191E0541251100FF537818078901191E054125191E0641258D001778191E0441251100FF53107F6E101800
    C - 009000
    T - 80E80004C8058901191E0441251100FF537803780320188C001B18110100900B870218110118900B870318110118900B870418110080900B87051808900C8706181D880718AE0788081804048D00138709181006048D00158700181006048D0015870A7A02201D046D06048D0014181D880718AE0788087A011006780110AE0B780210AD090325780310AD090303387A0110AE08780330191E1103008D00183B057805501D1604411100806F040378AE0B6106078D0014AD051D1A1F16048D00193B1604780540AD090303381800
    C - 009000
    T - 80E80005C803880B1803890C1803890D1803890E1803880F1F60081FAD05926F06058D0014191EAD05031F8D00193B1804880F7A0543032905AE0B046B06088D001419031E41257501300002FFC600110000000D058D00141819031E418C001E290618AF011E41890119AF0125066A06058D00141806881008AF01412904A800E2181916048C001E2905191604257300C800010004000F0031008600A71605AD02926F06058D0014191604AF0141AD020316058D00193B181605890CA8009AAD0603191604AF0141251100FF5300
    C - 009000
    T - 80E80006C839AD0604191604AF01410441251100FF5339AD0605191604AF01410541251100FF5339AD0606191604AF01410641251100FF5339AD0607191604AF01410741251100FF533970441605AD03926F06058D0014191604AF0141AD030316058D00193B181605890D70231605AD04926F06058D0014191604AF0141AD040316058D00193B181605890E700216041605AF014141290416041606A7FF1DAF0CAF0D41AF0E41610C058D00147006058D00147A0210AE0B046A0BAE0F6007AE10066A06088D00141804880B1800
    C - 009000
    T - 80E80007C8AE0788087A0440AD09030338AE0B6106078D0014180488111F650A18191E1F8B00217802780846032905032906032907032908AE116106088D0014AE0861040378AE107501DF00010003000918191E8C001E29091FAF011609416C6B04AF01412904705D181916041E418C001E29051916041E41257300400000000400110013004000220031702F1605652B1E160441AF0141290870201605651C1E160441AF0141290670111605650D1E160441AF01412907700216041605AF0141412904160416096FA1AD060700
    C - 009000
    T - 80E80008C8261100FF53290916091609452909AD0A0316098D00183B16069800B916079800B418191606191607AD03AD04AF0E8C0022AD0007251100FF53AD0606264510084F29091609AD0607266C14AD0903043818AE078808180388111140007816091609452909AD000716098D00183BAD0005251100FF53AD0605264510084F29091609AD0607266C14AD0903043818AE078808180388111140007816091609452909AD000516098D00183BAD0005AD0007AD0A058D0023AD0A05AD0A038D00246214AD0903043818AE0700
    C - 009000
    T - 80E80009C8880818038811114000781608604918191608AD02AF0C8C0025AD0003251100FF53AD0604264510084F29091609AD0607266C14AD0903043818AE078808180388111140007816091609452909AD000316098D00183BAD0003AD0A05AD0A078D0023AD0A07AD0A038D00246214AD0903043818AE0788081803881111400078AD09030338AE086511183D840804435B88087006058D0014037803430329047031181D160441251100FF5329051A1F160441251100FF532906160516066F040478160516066D0402781600
    C - 009000
    T - 80E8000AC80404415B29041604056CCE03780462032906042907703D181D160741251100FF531A1F160741251100FF534116064129061504160516074116065B3816061100FF6F070429067005032906160704435B2907160763C37A08000A000200010000000000000A001B0500000000000100000004000000130002002B003300090001000105009A002602001D0602001D0B02001D0002001D0102001D0202001D0302001D0402001D0D02001D0E02001D0502001D0702001D0F02001D0802001D0902001D0A02001D110200
    C - 009000
    T - 80E8000BC8001D0C02001D10038105020681080C060000330681080D01001D000681100506811006068110020600027A06800000068105000500000006000225010013000600002B03001D0D0600005906000728060006EB060001430900C8008BFF1726E2220E1F1A080808060403020809090F0302090507081D08100704040404060B0A082A04030C03260C030C050609060B060B060B060F0C030C060C030C080D02031205040B030205050A1D08061408330F0F0B0C111A020205080C060602040D09080C060602040D0900
    C - 009000
    T - 80E8800C5A03030603080602040E0205080C060602040D090303060308060204060506050039090D050508080B04050503030403FFFF06243509090D31180A2C091416081414200E690E130E270615190E19171B711B3B3C0D09233B0D092C00
    C - 009000
    Completed !
    However, I want to run step by step a command to load this cap file into card.
    When I sent "80F28000024F00", it is ok. It response: 08A000000003000000019E9000
    After that, I sent next command: 80E602001407A000000132000108A00000000300000000000000, it response as 6985.
    I don't understand why. Please help me this problem. I must do how to load this cap
    Thanks & Best Regards
    Kelvin Nguyen

    Hi,
    You need to delete the old CAP file before loading it again. The problem is that when you call INSTALL FOR LOAD it sees there is already a CAP file with that AID present.
    You can try sending a GET STATUS command listing load files to see what is on the card already. You need to delete what is present to be able to load/install again.
    Shane

  • How to Install the CAP file on the Java Card

    Hi guys. I've already written and tested a java card applet. Now i want to put the CAP file on the card. Could anyone please tell me the procedures or direct me to where i can find the procedures on how to do this?
    Thanks

    I suggest you search this forum. That question has been answered a lot.
    1) If you are using a pure Java Card use scriptgen tool and send those commands to the card.
    2) If you are using a Java Card with Global Platform
    A) Follow the Global Platform specs and authenticate to the card with developer keyset(0x40,0x41,0x42,0x43...0x4f)
    b) Get a kit
    Since you are a beginner, I recommend you get the a kit like JCOP or one from card vendors like G&D, Gemplus, etc.

  • Compressor shuts down when I try to load a mov file.

    I am trying to make a DVD. I have edited the film in FCP and now want to put it on to DVD but I must use Compressor, the file is about 500meg, about three minutes long. When I set Compressor to do a DVD for me and attempt to load the mov file it closers down with the message as per image. I have the help but to no avail. Is there anyone out there that can put some light on it forme please

    Earlier versions of FCP aren't compatible with the newest version of Compressor. From your screen shot, it appears your project is in one of those earlier (and highly coveted) versions.  Try exporting a self-contained QT movie from your FCP project and then bring that file into Compressor. 
    Good luck.
    Russ

  • Can we load a J2ME application on SIM Card?

    Hi All,
    Can we load a J2ME application on SIM Card? I have seen SIM Manager Softwares but they only give phone book and pin code related functionality. Kindly tell me if there is any such software which can load an application on SIM ?
    Thanks,
    Muhammad Bilal Awan,
    Sr. Software Engineer.

    Hi,
    Usually SIM cards are from 16K - 64K in size but with the invent of Flash memory SIM cards have now capacity of upto 512MB i.e. half a gig.
    These SIM card providers provide softwares which can load J2ME applications on SIM.
    http://www.gi-de.com/pls/portal/mai...5066&p_pg_id=42
    http://www.oberthurcs.com/press_page.aspx?id=21

Maybe you are looking for