Manually upload .cap file on a java card

Hi
I wonder how to manually upload a .cap file on a java card. I do know that it must be an or more APDUs that contain the file and so on.
What I wonder is how to convert a .cap file into a byte array (byte array that on-card installer can read and understand) without using JCOP or any other tools? Does (must) this array have a special format or something?
I am interested in the process of taking a.cap file and convert it to byte array (nothing else).
Thanks in advance!
/Lyudmila

The .cap file uploading mechanism depends if you have a java card or a GlobalPlatform card.Java Card cards are GlobalPlatform based.
If you have a java card you can use the same mechanism that it is used with Cref (see Java Card Kit - Development Kit - Chapter 11): .cap file is divided in n apdus, one or more (if a component not fit in one apdu, for example method component) for component (first:Header.cap, second:directory.cap, third:import.cap, etc).
If you use a GlobalPlatform card, the mechanism is more complex:
first you have to create a session using a specific protocol (SCP01, SCP02, etc) through INITIALIZE UPDATE and EXTERNAL AUTHENTICATE commands, then an INSTALL FOR LOAD command and n LOAD commads as they are necessary.
To use GlobalPlatform mechanism, see GlobalPlatform Specification 2.1.1.The JCRE spec does not define the applet loader and CREF has a basic version of an applet loader that is not GP compliant, but this is not the Java Card standard. To load onto any physical Java Card you will need to follow the GlobalPlatform specification.
- Shane

Similar Messages

  • 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..

  • 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.

  • 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.

  • 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.

  • Plz, help me~! not upload  cap file.

    I am new to the javacard technology.
    I have implementing an applet by using eclipse 3.1 + JCOP plug-in.
    And I set my project to build against JC211.
    The created cap-file I'm trying to upload works fine when used with a simulated card.
    But, When i try to upload it to my cards(G&D smartcare expert 3.1) I get the following error.
    upload "F:\02. 2006\05. 10\10.17\\HelloWorld\bin\HelloWorld\javacard\HelloWorld.cap"
    jcshell: Cannot read <F:\02. 2006\05. 10\10.17\\HelloWorld\bin\HelloWorld\javacard\HelloWorld.cap>: java.util.zip.ZipException
    ??> install -i d4106509900010 -q C9#() d410650990 d4106509900010
    => 80 E6 0C 00 1C 05 D4 10 65 09 90 07 D4 10 65 09 ........e.....e.
    90 00 10 07 D4 10 65 09 90 00 10 01 00 02 C9 00 ......e.........
    00 00 ..
    (121415 usec)
    <= 6A 80 j.
    Status: Wrong data
    jcshell: Error code: 6a80 (Wrong data)
    jcshell: Wrong response APDU: 6A80
    Unexpected error; aborting execution
    Has anyone seen this error before?
    Anyone help me, plz!!
    plz! plz! plz! plz! plz! Help me~~~!

    Make sure you are using the right java card library version (JavaCard and OpenCard version).
    Most cards only support jc2.1.2 - in opposite of the emulator which was designed for jc2.2.1.
    Jan

  • 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 upload the file without using java components?

    Hello,
    I need to upload the file using JSP, but I don't want to use java componets(such as
    jspsmart).
    Who can tell me how to realize it? This issue is very important to me,
    thanks all in advance!

    make you're own servlet using the multipartrequest from o'reilly.
    easy and simple, no jspsmart, only 1 jar file and some descent programming.
    I use it like that...

  • How to debug byteCode? Can cap file convert to java source file?

    Are there tools can debug byteCode?
    Are there tools can convert cap file to java source file?
    Are there tools can convert jca file to java soure file?

    I think it's little bit difficult to give you a correct answer. Frankly speaking, cap file debugging is possible if you have sufficient devices and knowledge to do that. Converting cap file to java source code is also possible only if the cap file has descriptor component in it. Names of variables, functions will not be completely restored because cap file doesn't have the names in it. But I am not sure that there is a publicly opened tool to do that. JCVM chapter 6 may show you the way even it's not the direct one.

  • Java Card 2.2.2

    q1 ) Are there any cards complaint with Java Card 2.2.2 ?
    q2) When using the jdk v 2.2.2 is it possible to generate cap files for the Java card version 2.2.1
    10x

    Did you try to search the forum or is it more convinient for you to just post something and expect that people are just waiting to help you?
    http://forum.java.sun.com/thread.jspa?forumID=23&threadID=5137732
    JC 2.2.2 does not mandate backward compatibility, but since the CAP file format did not change it should be no problem to load JC 2.2.1 CAP files.

  • Java Card Product and Price List

    Where to find the Java Card, Card Reader to read Java Card and its Price List issued by Sun Microsystems.I want these products and price list.
    What is the tool needed to install the .CAP file in to Java Card?. I have read from the Sun Material, that there will be a off-card installer that loads the binary file of .CAP to Java Card through the CAD device. Where to find the off- card installer?
    I had tested a sample application in Eclipse IDE with JCDK 2.2.2 and EclipseJCDE.
    Please anyone provide me the details
    Edited by: sachindev on Oct 24, 2007 6:22 PM

    Hi there,
    I found this site with everything that you might need, I would say that prices are reasonable (correct me if I am wrong):
    Cards: http://www.smartcardsource.com/cards.htm
    Readers: http://www.smartcardsource.com/readers1.htm
    SDK: http://www.smartcardsource.com/sdk.htm
    Hope it helps...

  • Java card doubts..

    Hello all,
    I am trying to understand the concept of java card , I have some doubts , I want to share with , perhaps you would any best suggestion for me.
    //Jcop-  I read somewhere that Java Card OpenPlatform (JCOP) is a smart card operating system for the Java Card platform developed by IBM Zürich Research Laboratory.
    question 1 - if this above sentence is right it means jcop is an operating system developed by IBM, handle all operation inside the card.right? I have a card which indicate
    ATR like- 3b 89 80 01 4a ....40 ( in character form it indicate- ;---jcop41v22m) , so can i say? this is a card which o.s is made by IBM. and we require only and only JCOP tool to send cap inside this card because OS inside is JCOP and jcop tool would be the only option to talk to jCOp card?
    question 2 - or is there any other method by which i can send the applet inside my card?
    enable_trace
    establish_context
    card_connect
    select -AID a0000000030000
    open_sc -security 1 -keyind 0 -keyver 0 -mac_key 404142434445464748494a4b4c4d4e4f -enc_key 404142434445464748494a4b4c4d4e4f // Open secure channel
    delete -AID D0D1D2D3D4D50101
    delete -AID D0D1D2D3D4D501
    delete -AID D0D1D2D3D4D50101
    install -file helloworld.cap -nvDataLimit 500 -instParam 00 -priv 2
    # getdata
    # close_sc // Close secure channel
    # putkey // Put key
      // options:
      //          -keyind Key index
      //          -keyver Key version
      //          -key Key value in hex
    card_disconnect
    release_context
    question 3 - above code i got from gpshell 1.4.4 , the code style indictate that this is also a method tp send cap file inside the java card, I want to know that for my card case { atr is -3b 89 80 01 4a ....40 ( in character form it indicate- ;---jcop41v22m)} , I can apply gpshell to send .cap file in my card.
    question 4 - is gpshell is used to send cap into a special java card which is not jcop enable or which does not contaion jcop operating system?
    there are so many techniques , so many type of java card, it makes me confuse , I hope you seems this question genuine and would give me revert back
    regards:-
    Edited by: daniel on Feb 29, 2012 10:08 AM

    Alright, I'll awnser your questions my best.
    Question 1 :
    Yes, you could say that. However, i'm using a J2A080 card(JCOP card) and i'm not using the jcop tool kit.
    I use eclipse with EclipseJCRE add on to develop my application, since there is a JavaCard emulator in it, you can test it witout installing your applet everytime you make a modification.
    Question 2-3 :
    GPShell is a nice tool for card communication, but i would also suggest you GPJ. Specially if you start with java cards because it is way more easier. It works with my J2A080 and have been tested with your card type and should work. You just have to generate the cap file with eclipse and load it with GPJ
    Question 4 :
    I'm not sure about that but I think GPShell can works for pretty much all type of card that has OpenPlatform on it.
    But it is more complicated to find the good keys and get the good options at the good places, that is why I recomand you GPJ.
    Hope it helps you out!
    P.S. Pay attention to the JavaCard platform supportd by the card, yours is 2.2.1. If you try to build CAP file with an other version installed, it may not work properly.
    Edited by: FrancisOL on Feb 29, 2012 11:22 AM

  • CAP file

    Suddenly I am not able to get the CAP file. The Java Card project is successfully built. The converter produced only one CAP file for one package. The package in which the applet is defined is not converted. Is there any trace where can I found out what is wrong?

    I am using NXP Jcop tools plugin for the eclipse. My project has two java card packages. In one package there is Java Card applet and in the other is the rest of the classes. I divide it like that because my application is very large and the splitting was necessary. The package in which other classes are successfully built and converted while the other was jut built. At the end I am having only one CAP file. Where can I found the information why the conversion of the other package failed?

  • Java Card File System ...Please reply

    Hi all ,
    I am working on Java Card technology for last one year . Presently I am facing some problem regarding some file concept of java card .
    I know that Java Card 2.1 does not support file system . But I want to simulate the file system in java card using applets . i.e . I want to write an application(applet) , which can simulate the EF , DF in smart card . Whenever APDU command is send to the file system applet , it should generate a Elementary file (EF) or dedicated file (DF) etc and store data to that file.
    Can I do this type of thing using Java Card ? I am really in doubt .
    If you have any idea on this , please let me know your view on this . If you know any open source code for this type of simulated Java card file system , please let me know .
    I am desperately looking for a help .
    regards
    Dibyendu .
    you can contact me to this email
    [email protected]

    dear duran ,
    You have written that
    "Follow the guidelines for the different supported filesystems on the JC"
    But after Java Card version 2.0 , it does not support file system . I am using Java Card 2.1 .
    Could please some sample code to my mail Id , so that I can take a look at it .
    My mail id is : [email protected]
    Please share the idea , as I am really need some help.
    Regards ,
    Dibyendu.

Maybe you are looking for