10 Replies Latest reply: Jul 12, 2012 5:13 AM by 948184 RSS

    How to load .cap on a smart card

    948184
      Hi everybody!

      I am very confused with java cards. I wrote an applet for java card. Tried it in Eclipse+JCWDE. Send some APDUs to it with apdutool.bat. Works fine!

      However, I want to go further and try it on a real smart card. The only problem is I do not know how to load .cap file onto my card. I tried to find some forums, references or something like that, but all I found was "I tried to load, but get error" or something like that.

      I use JCOP tool for Eclipse (if that to any help)

      Can someone explaine to me how loading works in princip? Is their any classes that can be used to simplify the task?

      Any help is appreciated
      /L
        • 1. Re: How to load .cap on a smart card
          Umer
          Hi,

          Don't be so confused and panic. There are tools by which you can easily load/install your applet on java card.
          Do you have a licensed JCOP version ?


          --------------------------------------------------------------------------
          http://adf.ly/AYdGX
          • 2. Re: How to load .cap on a smart card
            948184
            Thank you for your fast response :)

            Yes, I have licensed JCOP.
            I read about some tools : GPShell, GPJ, JCManager... However, I want to understand how they works not just use them.

            In JCManager code I saw a line
            cardManager.Transmit(apdu, p, apduLength);
            CardManager must be an applet that installed on a card from the begining and I need to select it and send my .cap file to it, and then send install command with my applet´s AID (or something like that). But I need to select CardManager first. How do I know its AID?

            The main question is how do I pass APDU message from Java code to PC/SC driver?

            Am I on a wrong way?

            Thanks
            /L
            • 3. Re: How to load .cap on a smart card
              Lyolik
              Hi Lyudmila,

              If you have a JCOP Tools look at this link:
              http://www.infres.enst.fr/~urien/openeapsmartcard/download.html

              It will be useful for you.
              • 4. Re: How to load .cap on a smart card
                948184
                Hi Lyolik,

                Have you tried to download scripts from the link you send me?
                I can´t. I can save .zip, but not open it.

                However, I get some interesting info about JCOP shell.

                Thank you

                /L
                • 5. Re: How to load .cap on a smart card
                  Umer
                  In JCManager code I saw a line
                  cardManager.Transmit(apdu, p, apduLength);
                  This line of code is sending APDU by using low level dll
                  CardManager must be an applet that installed on a card from the begining and I need to select it and send my .cap file to it, and then send install command with my applet´s AID (or something like that). But I need to select CardManager first. How do I know its AID?
                  If you want to select your card Manager without knowing its AID then send an APDU of 00A4040000, then you will be able to select your card manager by default
                  The main question is how do I pass APDU message from Java code to PC/SC driver?
                  There are always low level libraries behind java code which are doing job for you.
                  • 6. Re: How to load .cap on a smart card
                    Lyolik
                    Yes, of course. Absolutely normal .zip file.
                    I can print the content of file load.jcsh here:
                    # /set-var path d:/Wi-Fi/javacard/download/eappsk32k
                    #Switch trace mode on and connect to a PC/SC smart card reader
                    #
                    /mode trace=on
                    /terminal 
                    #
                    #Reset the card (request ATR) and select the CardManager
                    /card 
                    #Set the keys in key set 255 of the JCShell for authentication later on
                    #
                    set-key 255/1/DES-ECB/404142434445464748494A4B4C4D4E4F
                    set-key 255/2/DES-ECB/404142434445464748494A4B4C4D4E4F
                    set-key 255/3/DES-ECB/404142434445464748494A4B4C4D4E4F 
                    #
                    #Begin authentication using the appropriate key set
                    init-update 255 
                    #
                    #Complete authentication
                    ext-auth 
                    #
                    #Display the card registry to check if the applet is loaded and installed
                    card-info
                    # 
                    #delete 11223344556601
                    #delete 112233445566
                    card-info 
                    #
                    #Upload the package holding the applet
                    upload ${path}openeapsmartcard.cap 
                    #
                    #
                    #Install the applet in the package
                    install 112233445566 11223344556601 
                    #
                    #Display the card registry to check if the applet is loaded and installed
                    card-info 
                    You should make some substitutes for your project.
                    • 7. Re: How to load .cap on a smart card
                      948184
                      Hi Umer and Lyolik!!!

                      Thanks for your help!
                      Your answers helped a lot :)

                      /L
                      • 8. Re: How to load .cap on a smart card
                        948184
                        Hi Lyolik,

                        the link you poste above...
                        there is a print screen of the JCOP Shell...

                        when I type >help I get only those first commands until "?" plus commands "help", "quit" and "version"
                        Do you know why? Is it different version of the shell or something like that?

                        Tanks
                        /L
                        • 9. Re: How to load .cap on a smart card
                          Lyolik
                          Lyudmila,

                          To get the full list of commands (like at printscreem of JCOP Shell) you should connect to CardManager.
                          So, you have to execute next commands:

                          /atr
                          /card

                          set-key 255/1/DES-ECB/404142434445464748494A4B4C4D4E4F
                          set-key 255/2/DES-ECB/404142434445464748494A4B4C4D4E4F
                          set-key 255/3/DES-ECB/404142434445464748494A4B4C4D4E4F

                          init-update 255

                          ext-auth

                          After successful executing of these commands you will be able to get the full list of Card Manager commands with help command.

                          Edited by: Lyolik on 11.07.2012 9:15
                          • 10. Re: How to load .cap on a smart card
                            948184
                            Hi Lyolik!

                            Thank you very much!!!

                            /Lyudmila