This discussion is archived
1 2 Previous Next 15 Replies Latest reply: Oct 14, 2012 5:51 AM by 965389 RSS

Problem to upload applet on javacard

949970 Newbie
Currently Being Moderated
Hi evrebody

I need some help to upload a applet into my javacard ID PROTECT v3 (JC 2.2.2 / GP 2.1.1 / 72K)
I am on ubuntu 12.04 LTS
i have already install global platform 6.0.0 , eclipse Version: 3.7.2 and gpshell 1.4.4

this is the step i have done

1-) javac monPakage/MonApplet.java -classpath /home/chaka/JAVACARD/decompresser/java_card_kit-2_2_2/lib/api_16.jar -source 1.3 -target 1.3

2-) converter -exportpath $JC_HOME/api_export_files -applet 0x01:0x02:0x03:0x04:0x05:0x06:0x07:0x08:0x09:0x00:0x00 MonApplet monPakage 0x01:0x02:0x03:0x04:0x05:0x06:0x07:0x08:0x09:0x00 1.0

i didn t get any error or warning

so when i am using gpshell and try to select the applet i have this error

mode_211
enable_trace
establish_context
card_connect
select -AID 0102030405060708090000


Command --> 00A404000B0102030405060708090000
Wrapped command --> 00A404000B0102030405060708090000
Response <-- 6D00
select_application() returns 0x80206D00 (6D00: Invalid instruction byte / Command not supported or invalid.)

Please i am a rookie on Javacard i realy need help

thanks.

this my applet .
package monPakage;

import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;

public class MonApplet extends Applet {

     
        /* Constantes */
        public static final byte CLA_MONAPPLET = (byte) 0xB0;

        public static final byte INS_INCREMENTER_COMPTEUR = 0x00;
        public static final byte INS_DECREMENTER_COMPTEUR = 0x01;
        public static final byte INS_INTERROGER_COMPTEUR = 0x02;
        public static final byte INS_INITIALISER_COMPTEUR = 0x03;

        /* Attributs */
        private byte compteur;

        /* Constructeur */
        private MonApplet() {
               compteur = 0;
        }

        public static void install(byte bArray[], short bOffset, byte bLength) throws ISOException {
               new MonApplet().register();
        }




        public void process(APDU apdu) throws ISOException
        {
             if (selectingApplet())
             {
                  return ;
             }
               byte[] buffer = apdu.getBuffer();

               if (this.selectingApplet()) return;

               if (buffer[ISO7816.OFFSET_CLA] != CLA_MONAPPLET) {
                       ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
               }

               switch (buffer[ISO7816.OFFSET_INS]) {
                       case INS_INCREMENTER_COMPTEUR:
                               compteur++;
                               break;

                       case INS_DECREMENTER_COMPTEUR:
                               compteur--;
                               break;

                       case INS_INTERROGER_COMPTEUR:
                               buffer[0] = compteur;
                               apdu.setOutgoingAndSend((short) 0, (short) 1);
                               break;

                       case INS_INITIALISER_COMPTEUR:
                               apdu.setIncomingAndReceive();
                               compteur = buffer[ISO7816.OFFSET_CDATA];
                               break;

                       default:
                               ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);

               }

        }
}
  • 1. Re: Problem to upload applet on javacard
    Umer Journeyer
    Currently Being Moderated
    Hi,

    It seems like your card is not a GP card. How did you install your .cap file on your card ?
  • 2. Re: Problem to upload applet on javacard
    949970 Newbie
    Currently Being Moderated
    thanks to reply
    I can t install the .cap because i have to select the applet first .

    i generated my .cap wich this commande

    javac monPakage/MonApplet.java -classpath /home/chaka/JAVACARD/decompresser/java_card_kit-2_2_2/lib/api_16.jar -source 1.3 -target 1.3

    converter -exportpath $JC_HOME/api_export_files -applet 0x01:0x02:0x03:0x04:0x05:0x06:0x07:0x08:0x09:0x00:0x00 MonApplet monPakage 0x01:0x02:0x03:0x04:0x05:0x06:0x07:0x08:0x09:0x00 1.0

    regards
  • 3. Re: Problem to upload applet on javacard
    Umer Journeyer
    Currently Being Moderated
    I can t install the .cap because i have to select the applet first .
    You need to install the .cap file and then you will be able to select that installed applet

    But even if you .cap file (converted applet file) is not installed then ox6D00 should not be returned.
    So, you need to do the following:

    1. Convert the .class file into .cap file (you already did it)
    2. connect your reader+card and select card manager
    3. Install .cap file
    4. Select your applet.
  • 4. Re: Problem to upload applet on javacard
    949970 Newbie
    Currently Being Moderated
    I use gpshell 1.4.4 .
    Where can i get card manager do you have a link for me ?
    regards
  • 5. Re: Problem to upload applet on javacard
    Umer Journeyer
    Currently Being Moderated
    Card Manager is an applet which is pre-installed on java cards.
    You can select your card manager by sending following APDU:
    00A4040000
  • 6. Re: Problem to upload applet on javacard
    949970 Newbie
    Currently Being Moderated
    # gpshell

    mode_211
    enable_trace
    establish_context
    card_connect

    send_apdu -sc 0 -APDU 00A4040000
    Command --> 00A4040000
    Wrapped command --> 00A4040000
    Response <-- 6F0F8407A0000001510000A5049F6501FF9000
    send_APDU() returns 0x80209000 (9000: Success. No error.)
    ---------------------------------------------------------------------------------------------------
    Now what should i do can you give me the command for install my .cap

    i am deeply sorry but i am a novice in javacard
  • 7. Re: Problem to upload applet on javacard
    949970 Newbie
    Currently Being Moderated
    I try to install the .cap but i get this error
    ---------

    install -file monPakage.cap
    Command --> 80E602001C0A0102030405060708090007A00000015100000006EF04C60201B80000
    Wrapped command --> 80E602001C0A0102030405060708090007A00000015100000006EF04C60201B80000
    Response <-- 6985
    install_for_load() returns 0x80206985 (6985: Command not allowed - Conditions of use not satisfied.)

    -------
  • 8. Re: Problem to upload applet on javacard
    Umer Journeyer
    Currently Being Moderated
    Well i think I should revise my steps here ;)

    1. convert .class file to .cap file
    2. Select card manager
    3. Authenticate your card
    4. Install .cap file
  • 9. Re: Problem to upload applet on javacard
    949970 Newbie
    Currently Being Moderated
    lol don t worry

    but how i do, your step 3 (authentification) ?

    look something this is an exemple for upload an apllet into javacard , it come wich gptchell archive

    -----------------------.-
    root@chaka-gaye-ubuntu:/home/travail/java/upload/monPakage/javacard# cat helloInstall.txt
    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

    ------------------------

    As you can see he select the AID before
    Are you sure that i don t have to do the same ?
    Anyway how can i do your step 3 , i have tried to do that but i get error


    ----------------
    open_sc -security 1 -keyind 0 -keyver 0 -mac_key 404142434445464748494a4b4c4d4e4f -enc_key 404142434445464748494a4b4c4d4e4f
    Command --> 80500000082E8B26DB2972EE3A00
    Wrapped command --> 80500000082E8B26DB2972EE3A00
    Response <-- 6D00
    mutual_authentication() returns 0x80206D00 (6D00: Invalid instruction byte / Command not supported or invalid.)

    --------------


    regard
  • 10. Re: Problem to upload applet on javacard
    Umer Journeyer
    Currently Being Moderated
    Select card manager first and then start mutual authentication process.
  • 11. Re: Problem to upload applet on javacard
    safarmer Expert
    Currently Being Moderated
    but how i do, your step 3 (authentification) ?
    open_sc should do it but you need to have the correct keys. If you have too many failed attempts with the incorrect keys you will lock the card.
    look something this is an exemple for upload an apllet into javacard , it come wich gptchell archive
    You might have better luck with helloInstallGp211.txt since you have a GP 2.1.1 card.
    mode_211
    enable_trace
    enable_timer
    
    establish_context
    card_connect
    select -AID a000000003000000
    open_sc -security 1 -keyind 0 -keyver 0 -mac_key 404142434445464748494a4b4c4d4e4f -enc_key 404142434445464748494a4b4c4d4e4f // Open secure channel
    
    delete -AID <your applet AID> // may fail if the applet is not there but can be ignored
    delete -AID <your package AID>
    install -file <your cap file> -nvDataLimit 2000 -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
    As you can see he select the AID before
    Are you sure that i don t have to do the same ?
    Select with no data is the same as selecting the card manager. It is a discoverability feature of GlobalPlatform cards since the card manager can have any AID.
    Anyway how can i do your step 3 , i have tried to do that but i get error
    Try the script mentioned and post the results here. It may have been to do with the mode (mode_201 is implied)


    Shane
  • 12. Re: Problem to upload applet on javacard
    949970 Newbie
    Currently Being Moderated
    Hi

    you re the best it s look like it work s fine
    i am going to do some test and tell you tomorow
    thank s for all

    regards
  • 13. Re: Problem to upload applet on javacard
    949970 Newbie
    Currently Being Moderated
    Hi shane

    I don t know why but if i test wich the helloword script , it s block on

    select -AID a000000003000000

    you can see the code
    enable_trace
    establish_context
    card_connect
    select -AID a0000000030000
    Command --> 00A4040007A0000000030000
    Wrapped command --> 00A4040007A0000000030000
    Response <-- 6D00
    select_application() returns 0x80206D00 (6D00: Invalid instruction byte / Command not supported or invalid.)
    root@chaka-gaye-ubuntu:/home/travail/java/upload/monPakage/javacard# 
  • 14. Re: Problem to upload applet on javacard
    949970 Newbie
    Currently Being Moderated
    problem nor resolved
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points