Memory on java cards

Hi, i wonder how can i know the space that an applet use on the card, i want a .cap that is 3K size and i what to know if i instantiate this app on the card how much memory it will consume (the .cap and the instantiate).

Hello
the size of the load block (what goes through LOAD commands) is a very good estimate.
You can't know for sure because it depends on how the card is implemented internally. Usually it's a tiny bit smaller than the load block.

Similar Messages

  • How to find out memory of a java card

    is there anyone could tell me that how can we check the size of the memory of a card? thank you in advance:D

    If the card is a Java Card 2.2.1, create an applet that returns
    JCSystem.getAvailableMemory(), install and queryit.
    Some other ideas for getting the free memory on card were presented in the thread "Java Forums - Free memory on card"
    http://forum.java.sun.com/thread.jspa?threadID=647894&tstart=30
    Jan

  • Java Card Memory Managament: How do you free-up allocated memory?

    I have a problem with java card memory management, that causes the applet to hang. I think the java card runs out of RAM when my applet runs for several iterations or process() calls. My program requires significant size of bytes for each APDU command to be sent. (around 100-250 bytes, for each apdu.sendBytes() call).
    I use a temporary byte array buffer that will contain the APDU command to be sent, declared as:
    private byte [] tmpBuff;Before each process() call, the tmBuff is initialized and contains a new byte array containing the APDU command to be sent. (array size around 100-250 bytes).
    tmpBuff = new byte[] {0x00, ... } On the process() call, the tmpBuff is copied to APDU and sendBytes() function is called. The tmpBuff byte array is reinitialized after every process() call to contain the next command. After about 20 successful commands by the process() call, the applet seems to ran out of RAM and hangs.
    I suspect, that when tmpBuff is reinitialized before each process() call, the Java Card garbage collector does now free-up the memory that was used for the previous tmpBuff byte array initialization.
    Is there a way to reclaim the memory allocated for tmpBuff after it has been initialized?
    Or maybe call the Java card garbage collector?

    Cenon,
    Generally speaking, the new keywork is a bad idea outside the install method or constructors as the JCRE is not guarenteed to have a garbage collector (and if it does, has to be called explicitly by JCSystem.requestObjectDeletion(); This however is slow.
    A better option may be to use memory more efficiently than to rely on garbage collection. A way of doing this would be to have an instance variable that is initialised once and reused. This allows you to use either a transient or persistent array.
    public class TestApplet extends Applet {
        private final static short BUFFER_SIZE = (short) 300;
        private final byte[] buffer;
        private TestApplet() {
            // only have one of the following not commented out
            /* persistent buffer */
            // buffer = new byte[BUFFER_SIZE];
            /* transient buffer (much faster) */
            buffer = JCSystem.makeTransientByteArray(BUFFER_SIZE, JCSystem.CLEAR_ON_DESELECT);
        public static void install(byte[] bArray, short bOffset, byte bLength) {
            // GP-compliant JavaCard applet registration
            new TestApplet().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
        public void process(APDU apdu) {
            // Good practice: Return 9000 on SELECT
            if (selectingApplet()) {
                return;
            // do some work here with buffer
    }In the above code you would be able to use the buffer to build the command and you will not have a memory leak.
    Cheers,
    Shane
    Edited by: safarmer on Jul 8, 2008 12:25 PM

  • Java Card Data Memory

    Hi,
    i am using java card applet for get data & Put data. Here, how can i get storage data memory , available data memory & Free memory.....
    Thanks in advance...
    Edited by: user12298678 on May 26, 2011 2:22 AM

    What is your use case? Do you want to be able to know how much space is available at runtime or is it for development purposes?
    If it is at runtime, you should be allocating all of your memory up front. This way you know your card will always work and you wont just run out of memory at some point and have an operation fail.
    Cheers,
    Shane

  • How to get a java card memory size info ?

    Hi everyone ,
    I want to get my card's memory size and free memory size .I appreciate it if anyone could help me with these questions :
    1 . Is there any way to find out card's defferrent memories size (EEPROM , ROM , RAM , FLASH) from Get Data command or any other apdu commands ?
    2 . is there any function in the API which we could use to reach memory size within an applet ? I found a function named GetMemorryAccessInstance in JCRE 2.2.2 API but I need something more global for all API versions .
    3 . Which Memories size information do we have access to ?
    Best Regards,
    Shemeine

    Hi Shemeine,
    Some cards have proprietary APDU's to find the free memory on a card. Even on cards that have such an APDU, you may have to have it enabled when the card is produced.
    As for a way to find it programatically, you can use:
    JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_PERSISTENT);
    JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_DESELECT);
    JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_RESET);The problem with these is they return a signed short. This will only show up to 32KB of free memory. If you have more than this, you will have to allocate some memory using new byte[32*1024] until you start seeing results less than 32KB. You then work out how many blocks of 32KB you had to allocate to reach this state. The types of memory you can find are self explanatory.
    Cheers,
    Shane

  • Java card query

    I am a student in my final year of university and im looking into using the java card as part of my final project. could somebody clarify for me some things i am unsure of. Am i able to use any smart card reader or do i need one specific for a java card, if so which one. If i can use any im ok as i can get hold of some. Also, am i correct in that i would write my java code as normal then use a program to write it to the card? any help would be much appreciated. Thanks

    Hi,
    you can use any reader.
    the java code has to be compiled , then converted using the sun-provided JCDK tool "converter" then loaded in the card using globalplatform, with the gpshell tool.
    beware, there are some restrictions to what can be written in the code. specifically, there is no "int" "float" "java.lang.String" and the memory is very small.
    and yes, objects are allocated in non volatile memory. So the "new" keyword must not be used too often, except in the initialization methods.
    why? because the JC virtual machine is always live. it does not stop. When you tear the card, the VM is suspended, then resumed when you reinsert the card, but the objects are still here.
    when an apdu is sent to the card, the JCVM calls a callback in your code. But your Applet object still exists.
    regards
    sebastien.

  • Java Card 2.2.2 draft is out for public review

    A draft for the upcoming release of the Java Card Specification is available for public review.
    The Java Card 2.2.2 Specification will provide numerous enhancements to the award-winning Java Card platform. In particular it will include specific support for contactless communication and ID cards :
    * enhancements to ease the management and increase interoperability of contactless cards.
    * additional cryptography and security features
    * utility APIs for memory-efficient applet development
    Java Card technology v2.2.2 is ready for the next generations of smart card standards, and is fully backward-compatible with previous versions.
    New features in Java Card 2.2.2 :
    * Utility APIs for TLV, BCD, short, int
    * ISO7816-based Extended length APDU support
    * Support for up to 20 logical channels
    * External memory access API
    * Multiple Interfaces management
    * Additional cryptography algorithms : HMAC-MD5, HMAC-SHA1, SHA-256 and Korean Seed
    * Signature with message recovery
    * Partial message digest
    * Standardized Biometrics API
    Please direct your comments on this draft at [email protected] Feedback received before December 15th will be considered for the final version of the specification. For more information on the Java Card Platform Specification v2.2.2, Public Review Draft, refer to the release notes on http://java.sun.com/products/javacard/RELEASENOTES_jcspecsp.html

    The Installer and the Applet Deletion Manager are implemented in the JCRE and GlobalPlatform. On-card the Card Manager manages the content management, communication and the related security. JCRE specifies how it has to handle installation and deletion, but leaves room for different implementations. To the outside world, on a GP card, the Installer/ADM is the Card Manager with a specific AID.
    Installer and ADM are optional. For instance a Java Card Static product does not need an Installer/ADM.
    JCOP cards have the Installer/ADM fully implemented. It uses the GP functionality. The CM has to be selected to install or delete a package/applet.

  • Give me *.scr script to simulate java card class

    this is the java file
    ++++++++++++++++++++++++++++++++
    //Package AID: 'D2 76 00 00 60 50 02'
    // Applet AID: 'D2 76 00 00 60 41 02'
    // Specification of the proprietary command READ
    // command APDU CLA = '80' || INS = '02' ||
    // P1 (= '00') || P2 (= offset [byte]) ||
    // Le (= number of bytes to read = DATA)
    // response APDU (good case) DATA (with length Le) || SW1 || SW2
    // response APDU (bad case) SW1 || SW2
    // Specification of the proprietary command WRITE
    // command APDU CLA = '80' || INS = '04' ||
    // P1 (= '00') || P2 (= offset [byte]) ||
    // Lc (= number of bytes to write) // DATA (bytes to write)
    // response APDU (all cases) SW1 || SW2
    package packmini; // this is the package name
    import javacard.framework.*; // import all neccessary packages for java card
    public class ReadWrite extends Applet {
    final static byte CLASS = (byte) 0x80; // class of the APDU commands
    final static byte INS_READ = (byte) 0x02; // instruction for the READ APDU command
    final static byte INS_WRITE = (byte) 0x04; // instruction for the WRITE APDU command
    final static short SIZE_MEMORY = (short) 9; // size of the data storage area
    static byte[] memory; // this is the data memory for the application
    //----- installation and registration of the applet -----
    public static void install(byte[] buffer, short offset, byte length) {
    memory = new byte[SIZE_MEMORY]; // this is the data storage area
    new ReadWrite().register();
    } // install
    //----- this is the command dispatcher -----
    public void process(APDU apdu) {
    byte[] cmd_apdu = apdu.getBuffer();
    if (cmd_apdu[ISO7816.OFFSET_CLA] == CLASS) {  // it is the rigth class
    switch(cmd_apdu[ISO7816.OFFSET_INS]) {      // check the instruction byte
    case INS_READ: // it is a READ instruction
    cmdREAD(apdu);
    break;
    case INS_WRITE: // it is a WRITE instruction
    cmdWRITE(apdu);
    break;
    default : // the instruction in the command apdu is not supported
    ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
    } // switch
    } // if
    else {                                        // the class in the command apdu is not supported
    ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
    } // else
    } // process
    //----- program code for the APDU command READ -----
    private void cmdREAD(APDU apdu) {
    byte[] cmd_apdu = apdu.getBuffer();
    //----- check the preconditions -----
    // check if P1=0
    if (cmd_apdu[ISO7816.OFFSET_P1] != 0) ISOException.throwIt(ISO7816.SW_WRONG_P1P2);
    // check if offset P2 is inside the bound of the memory array
    short offset = (short) (cmd_apdu[ISO7816.OFFSET_P2] & 0x00FF); // calculate offset
    if (offset >= SIZE_MEMORY) ISOException.throwIt(ISO7816.SW_WRONG_P1P2);
    // check if offset P2 and expected length Le is inside the bounds of the memory array
    short le = (short)(cmd_apdu[ISO7816.OFFSET_LC] & 0x00FF); // calculate Le (expected length)
    if ((offset + le) > SIZE_MEMORY) ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
    // check if expected length Le is 0
    if (le == 0) ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
    //----- now all preconditions are fulfilled, the data can be send to the IFD -----
    apdu.setOutgoing(); // set transmission to outgoing data
    apdu.setOutgoingLength((short)le); // set the number of bytes to send to the IFD
    apdu.sendBytesLong(memory, (short)offset, (short)le); // send the requested number of bytes to the IFD
    } // cmdREAD
    //----- program code for the APDU command WRITE -----
    private void cmdWRITE(APDU apdu) {
    byte[] cmd_apdu = apdu.getBuffer();
    //----- check the preconditions -----
    // check if P1=0
    if (cmd_apdu[ISO7816.OFFSET_P1] != 0) ISOException.throwIt(ISO7816.SW_WRONG_P1P2);
    // check if offset P2 is inside the bound of the memory array
    short offset = (short) (cmd_apdu[ISO7816.OFFSET_P2] & 0x00FF); // calculate offset
    if (offset >= SIZE_MEMORY) ISOException.throwIt(ISO7816.SW_WRONG_P1P2);
    // check if offset P2 and expected length Le is inside the bounds of the memory array
    short lc = (short)(cmd_apdu[ISO7816.OFFSET_LC] & 0x00FF); // calculate Lc (expected length)
    if ((offset + lc) > SIZE_MEMORY) ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
    // check if command length Lc is 0
    if (lc == 0) ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
    receiveAPDUBody(apdu); // receive now the rest of the APDU
    //----- now all preconditions are fulfilled, the data can be copied to the memory -----
    Util.arrayCopy(cmd_apdu, (short)((ISO7816.OFFSET_CDATA) & 0x00FF), memory, offset, lc); // this copy precedure is atomic
    ISOException.throwIt(ISO7816.SW_NO_ERROR); // command proper executed
    } // cmdWRITE
    //----- receive the body of the command APDU
    public void receiveAPDUBody(APDU apdu) {
    byte[] buffer = apdu.getBuffer();
    short lc = (short)(buffer[ISO7816.OFFSET_LC] & 0x00FF); // calculate Lc (expected length)
    // check if Lc != number of received bytes of the command APDU body
    if (lc != apdu.setIncomingAndReceive()) ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
    } // receiveAPDUBody
    ++++++++++++++++++++++++++++++++
    I hope u can give me sollution for my problem..
    Thank u all..

    need help ... somebody can help me ??
    I have java file..(on this below)..I want to run it with JCWDE...can you give me script APDU to run it on JCWDE ???
    thank for your attention .
    package packmini;
    import javacard.framework.APDU;
    import javacard.framework.ISO7816;
    import javacard.framework.Applet;
    import javacard.framework.ISOException;
    import javacard.framework.Util;
    public class IdCard extends Applet {
         //The Cla Value
         final static byte claValue = (byte) 0x08;
         //The Ins Value
         final static byte readName = (byte)0x01;
         final static byte readPhone = (byte) 0x02;
         final static byte writeName = (byte) 0x03;
         final static byte writePhone = (byte) 0x04;
         byte[] nameID;;
         byte[] phone ;
         public IdCard()
              nameID = new byte[12];
              phone = new byte[12];
         public static void install(byte[] bArray, short bOffset, byte bLength) {
              // GP-compliant JavaCard applet registration
              new packmini.IdCard().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();
              if(buf[ISO7816.OFFSET_CLA]!= claValue)
                   ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
              switch (buf[ISO7816.OFFSET_INS]) {
              case writeName :     
                        writeNameIn(apdu);
                        break;
              case writePhone:
                        writePhoneIn(apdu);
                        break;
              case readName:
                        readNameOut(apdu);
                        break;
              case readPhone:
                        readPhoneOut(apdu);
                        break;
              default:
                   // good practice: If you don't know the INStruction, say so:
                   ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
         public void writeNameIn(APDU apdu)
              byte[] buff = apdu.getBuffer();
              short lcLength = buff[ISO7816.OFFSET_LC];
              short readCount = apdu.setIncomingAndReceive();
              if(readCount== 0 || lcLength == 0)
                   ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
              Util.arrayCopy(buff,(short) ISO7816.OFFSET_CDATA, nameID, (short)0, readCount);     
         public void writePhoneIn(APDU apdu)
              byte [] buff = apdu.getBuffer();
              short readCount = apdu.setIncomingAndReceive();
              short lcLength = buff[ISO7816.OFFSET_LC];
              if(readCount== 0 || lcLength == 0)
                   ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
              Util.arrayCopy(buff, ISO7816.OFFSET_CDATA, phone, (short)0, readCount);     
         public void readNameOut(APDU apdu)
              byte [] buff = apdu.getBuffer();
              short le = apdu.setOutgoing();
              apdu.setOutgoingLength((short) nameID.length);
              Util.arrayCopy(nameID,(short) 0, buff,(short) 0,(short) nameID.length);
              apdu.sendBytes((short)0, (short) nameID.length);
         public void readPhoneOut(APDU apdu)
              byte [] buff = apdu.getBuffer();
              short le = apdu.setOutgoing();
              apdu.setOutgoingLength((short) phone.length);
              Util.arrayCopy(phone,(short) 0, buff,(short) 0,(short) phone.length);
              apdu.sendBytes((short)0, (short) phone.length);
    }

  • How to improve the performance of java card OS?

    Hi All,
    we are into Java card OS developement. We need some tips for performance improvement of OS.
    1. what are the possible calculations we can do during loading so that we show good performance during operational mode.
    2. Tips in bytecode implimentation.
    Thanks

    Dear Friend,
    Performance term has relative character in Java Card implementation because there is no etalon. CREF is PC simulated software and can not be used for measurements. So for determining card performance only another implementation comparison can be suggested. Few things should be taken in account while card implementation comparison.
    1. Measurement is done by analysis of time consumption by the card to perfrom a command starting from data transfer and ending by status code.
    2. Same bytecode should be used in both samples.
    3. Same transmission rate should be used.
    4. Analysis of similarity of hardware including CPU, persistent memory programming time
    5. To perform that kind of measurement special tool listeting to terminal-smartcard interface is required
    I have no tips to bytecode implementation because bytecode is a thing that is determined by same Sun compiler and Java Card converter. So all are in the same conditions.
    Yours sincerely
    Dmitri

  • How to design a file system based on java card

    I have reviewed all kinds of articles about it.And right now I can not find any source code to do that function.But how to design a full gsm file system using java card.
    of course you need fast access,dynamic allocate memory,file properties management.Let's talk about it.

    just do it.
    there is no such feature in the javacard api. This must be coded by hand, you have to manage memory, etc.
    I know, that's not cool.

  • Java card cap file install error in jcop tools

    When i try to run java card applet in real java card it gives this error.i used jcop tools and java version 1.5  and eclipse 3.2.when i run the applet in simulater it works fine.i saw some document it says allocate memory for the installation process.i don't know how to do that.
    /term "winscard:4|SCM Microsystems Inc. SCL010 Contactless Reader 0"
    --Opening terminal
    >  /card -a a000000003000000 -c com.ibm.jc.CardManager
    resetCard with timeout: 0 (ms)
    --Waiting for card...
    ATR=3B 8A 80 01 4A 43 4F 50 33 31 56 32 33 32 7A       ;...JCOP31V232z
    ATR: T=0, T=1, Hist="JCOP31V232"
    => 00 A4 04 00 08 A0 00 00 00 03 00 00 00 00          ..............
    (23807 usec)
    <= 6F 65 84 08 A0 00 00 00 03 00 00 00 A5 59 9F 65    oe...........Y.e
        01 FF 9F 6E 06 47 91 73 51 2E 00 73 4A 06 07 2A    ...n.G.sQ..sJ..*
        86 48 86 FC 6B 01 60 0C 06 0A 2A 86 48 86 FC 6B    .H..k.`...*.H..k
        02 02 01 01 63 09 06 07 2A 86 48 86 FC 6B 03 64    ....c...*.H..k.d
        0B 06 09 2A 86 48 86 FC 6B 04 02 15 65 0B 06 09    ...*.H..k...e...
        2B 85 10 86 48 64 02 01 03 66 0C 06 0A 2B 06 01    +...Hd...f...+..
        04 01 2A 02 6E 01 02 90 00                         ..*.n....
    Status: No Error
    cm>  set-key 255/1/DES-ECB/404142434445464748494a4b4c4d4e4f 255/2/DES-ECB/404142434445464748494a4b4c4d4e4f 255/3/DES-ECB/404142434445464748494a4b4c4d4e4f
    cm>  init-update 255
    => 80 50 00 00 08 AC B1 90 01 BF 2D 24 A0 00          .P........-$..
    (49906 usec)
    <= 00 00 91 18 01 39 93 95 05 59 FF 02 00 2C BE 39    .....9...Y...,.9
        5E A5 07 55 87 B8 C3 A8 A6 93 66 2B 90 00          ^..U......f+..
    Status: No Error
    cm>  ext-auth plain
    => 84 82 00 00 10 0C AE 50 3E C8 7E 1D 92 29 E2 59    .......P>.~..).Y
        08 D9 DA 02 16                                     .....
    (57276 usec)
    <= 90 00                                              ..
    Status: No Error
    cm>  delete 060504030201
    => 80 E4 00 00 08 4F 06 06 05 04 03 02 01 00          .....O........
    (40041 usec)
    <= 6A 88                                              j.
    Status: Reference data not found
    jcshell: Error code: 6a88 (Reference data not found)
    jcshell: Wrong response APDU: 6A88
    Ignoring expected error
    cm>  delete 010203040506
    => 80 E4 00 00 08 4F 06 01 02 03 04 05 06 00          .....O........
    (17392 usec)
    <= 6A 88                                              j.
    Status: Reference data not found
    jcshell: Error code: 6a88 (Reference data not found)
    jcshell: Wrong response APDU: 6A88
    Ignoring expected error
    cm>  upload -d -b 250 "Cap File location"
    => 80 E6 02 00 13 06 01 02 03 04 05 06 08 A0 00 00    ................
        00 03 00 00 00 00 00 00 00                         .........
    (32303 usec)
    <= 00 90 00                                           ...
    Status: No Error
    => 80 E8 00 00 FA C4 81 F2 01 00 23 DE CA FF ED 02    ..........#.....
        02 04 00 01 06 01 02 03 04 05 06 12 68 6D 73 2F    ............hms/
        6A 61 76 61 63 61 72 64 2F 68 65 6C 6C 6F 02 00    javacard/hello..
        21 00 23 00 21 00 0A 00 0B 00 1E 00 0E 00 3D 00    !.#.!.........=.
        0A 00 0B 00 00 00 4D 01 BE 00 00 00 00 00 00 01    ......M.........
        01 00 04 00 0B 01 02 01 07 A0 00 00 00 62 01 01    .............b..
        03 00 0A 01 06 06 05 04 03 02 01 00 08 06 00 0E    ................
        00 00 00 80 03 00 FF 00 07 01 00 00 00 1C 07 00    ................
        3D 00 01 10 18 8C 00 05 7A 05 30 8F 00 00 3D 8C    =.......z.0...=.
        00 01 18 1D 04 41 18 1D 25 8B 00 02 7A 02 21 18    .....A..%...z.!.
        8B 00 03 60 03 7A 19 8B 00 04 2D 1A 04 25 73 00    ...`.z....-..%s.
        09 00 00 00 00 00 0F 11 6D 00 8D 00 06 7A 08 00    ........m....z..
        0A 00 00 00 00 00 00 00 00 00 00 05 00 1E 00 07    ................
        01 00 02 00 06 00 00 01 03 80 03 02 03 80 03 03    ................
        03 80 0A 01 06 80 03 00 06 80 07 01 09 00 0B 00    ................
        00 00 07 05 06 04 0A 07 07 13 0B 00 4D 01 00 00    ............M...
    (764519 usec)
    <= 6A 80                                              j.
    Status: Wrong data
    jcshell: Error code: 6a80 (Wrong data)
    jcshell: Wrong response APDU: 6A80
    Unexpected error; aborting execution

    Thanks ReNa
    i am using nxp jcop 31 contact-less card.and it will support for java card 2.2.1 and global-platform card specification 2.1.1 .so i am using nxp jcop training 2007 tools and it has java card 2.2.1 and global-platform card specification 2.1.1.Inside my project there are three jar files these are jc221.jar and gp211.jar and bio10.jar
    i will appreciate your help
    Thanks

  • Is it possible to simulate whole java card application on simulator?

    Hello all,
    currently i dont have any real java card yet,not either reader . I already made a simple applet and check its working by CJCRE (net beans simulator), it is working fine,
    now i want to move to host application which will communicate with java card via card reader. Is this possible to simulate complete application ( host application + java card applets)?
    I want to check it out that:- which line of java program would be helpful to know that:-
    1-"how real host application will talk to reader"
    2- how it connect and disconnect the reader
    3- how it send apdu to java card by reader
    and much more.
    I am using netbeans 7.1 and it is using CJCRE as a simulator....

    you mean to say this
    http://askra.de/software/jcdocs/app-notes-2.2.2/apduio.html
    I am quite confused now, i read this but still can not imagine the concept ,
    an applet code is :-
    public class GetName extends Applet
         final static byte CLASS     = (byte) 0x80;  // Class of the APDU commands
         final static byte INS_READ  = (byte) 0x02;  // instruction for the READ APDU command
         final static byte INS_WRITE = (byte) 0x03;  // instruction for the READ APDU command
         final static byte INS_DY_CO = (byte) 0x04;  // instruction for the READ APDU command
         final static byte[] text    = {(byte) 'A', (byte) 'M', (byte) 'I', (byte) 'T'};
         public static byte[] holder;
         public static void install(byte[] bArray, short bOffset, byte bLength)
            new GetName();
        protected GetName()
            holder = new byte[5];// allocation of memory in runtime
            register();
        public void process(APDU apdu)
              if(selectingApplet())
                   return;
            byte[] cmd_apdu = apdu.getBuffer();         
             if (cmd_apdu[ISO7816.OFFSET_CLA] == CLASS)
                   switch(cmd_apdu[ISO7816.OFFSET_INS])
                        case INS_READ:  
                        if ((cmd_apdu[ISO7816.OFFSET_P1] != 0) || (cmd_apdu[ISO7816.OFFSET_P2] != 0))
                        ISOException.throwIt(ISO7816.SW_WRONG_P1P2);
                        short le = (short)(cmd_apdu[ISO7816.OFFSET_LC] & 0x00FF); 
                        short len_text = (short)text.length;                      
                        if (le != len_text)
                        ISOException.throwIt((short)(ISO7816.SW_CORRECT_LENGTH_00 + len_text)); 
                        apdu.setOutgoing();                      
                        apdu.setOutgoingLength((short)len_text);
                        apdu.sendBytesLong(text, (short)0, (short)len_text);
                        break;
                    // here we save data from apdu and will keep inside the data byte                   
                        case INS_WRITE:
                    short lc = (short)(cmd_apdu[ISO7816.OFFSET_LC] & 0x00FF); 
                    Util.arrayCopy(cmd_apdu, (short) ((ISO7816.OFFSET_CDATA) & 0xff), holder, (short) 0, lc);
                        short len_holder_inside_write= (short) holder.length;
                       apdu.setOutgoing();
                    apdu.setOutgoingLength((short)len_holder_inside_write);
                    apdu.sendBytesLong(holder, (short) 0, (short) len_holder_inside_write);
                    break;
                    case INS_DY_CO:
                        short len_holder= (short) holder.length;
                    apdu.setOutgoing();
                    apdu.setOutgoingLength((short)len_holder);
                    apdu.sendBytesLong(holder, (short) 0, (short) len_holder);
                    break;
                        default : 
                        ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
             else
                    ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
    }now i think i need to make a another java file which would contain a main class, Is this both file would be inside a single java card project. and how these both would be connect to each other.
    for manually run a applet- there were two steps 1-
    C:\java_card_kit-2_2\samples\src\demo>jcwde jcwde-getname.app
    Java Card 2.2 Workstation Development Environment (version 0.18).
    Copyright 2002 Sun Microsystems, Inc. All rights reserved.
    jcwde is listening for T=0 Apdu's on TCP/IP port 9,025.
    and in second terminal we wrote-
    C:\java_card_kit-2_2\samples\src\demo>apdutool -nobanner -noatr getname.scr > ge
    tname.scr.jcwde.out
    Here it is clear that, if i will use javacardio then no need to pass the apdu from a file .....but i am confuse about how it possible, ie. is both file lie in same project , because i m using simulator so i need to run these both file simoltaneously........give me some roughly steps to implement this.

  • Is it possible to use Magnetic Strip Card in Java Card

    Can Any body knows that is it possible to use magnetic strip card instead of IC MicroProssesor card in Java Card technology ?
    is it possible to write java card applet on magnetic strip card ?
    Please Help me in this topic
    Thanx in advance

    If you mean having a combo of mag stripe and cpu/memory on a card, which support javacard tech, then yes.
    If you mean having a mag stripe only card which supports javacard, then no, it does not support javacard technology. Correct me if I am wrong but a mag stripe only holds a couple of bytes of datd doesn't it? Regardless no way enough for jcre, applets etc.
    Apu

  • How to "convert" a PC/SC spec Smart Card (usb token) to a Java Card?

    Hi experts,
    I've got a usb token from OEM and the only thing they told me is that the token is manufactured according to PC/SC spec. OEM didn't say anything about the proccessor, memory, etc. I'm no expert in hardware. But according to what I read on the web, a Java Card must have JCVM in the on-card memory. I'm wondering if there is a way to initialize a JCVM in this PC/SC usb token?
    Any help will be much appreciated!
    Z.Zen

    "PC/SC compatible" is about software on the card as much as "PC compatible" is about the software in your computer. PC/SC deals with sending bytes to and from the token whereas JavaCard deals with working with those byte packets. Unless the token is a JavaCard, there's not much you can do. You need to get the ATR of the token via PC/SC, maybe that gives more information.

  • Security in each byte of Java card's EEPROM

    as i undrestand until now in my applet I define a variable and store data in that variable,
    Is it a way to know where these data are stored, I mean I wanna define the memory address of that data by myself,
    caz my card application is multi-app, and maybe in future I want to let someone else load his/her applet in that card beside my applets to do other application
    but from know I wanna think of security that in future let that person to have the memory address from i.e 0x01 up to 0x05
    and have no right to read or write in other memory bytes
    and also each part of memory address should have a security code for authentication...
    what's your idea about this post and what do u sudggest?
    Regards
    Hana

    I'm sorry for my ignorance, but i think that you do not want to mess around with the Card Issuer Keys unless you are the Card Issuer which does not seems like the case.
    I think that you want to use the Secure Channel Protocol inside your own applet(which is what i want to do also) and use your own issued keys.
    Why? Because in a real situation you will not want that your Java Card stuck with only one App, you want it to have as many as the user wants to. For that to happen, the card issuer keeps a keyset to load&install applets, but, when the applet is installed you want to maintain your privacy from the card issuer(and everyone else), so you will need an extra keyset for your own Secure Channel Protocol.
    What i'm saying is that:
    When you enter the Cards Security Domain, you need the cards security domain keys.
    When you select your applet, all your comunications become "plain-text" and you will not have any transaction security.
    I would like to know how to open this SCP channel from my app, but unfortunatelly i cannot help you any further.
    Edited by: rochajoel on Aug 31, 2009 9:48 AM

Maybe you are looking for