9 Replies Latest reply: Mar 3, 2012 9:59 AM by 918703 RSS

    Install command syntax issue in jcop tool

    918703
      Hello there, I want to implement pin concept in my applet, as i read about this ,i think i need to Bind the USER_PIN over install command , till now i am using install command like-
      install -i a0010203040506070809  -q C9#() a00102030405060708 a0010203040506070809
      but to pass pin number , i need to update this install command with new one.
      Can anybody suggest me the updated install command , with help of that i can pass pin-0102030405 to the install command and use it by below technique
      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
      my package id is -a00102030405060708
      my applet id is- a0010203040506070809

      regards:-
      daniel
        • 1. Re: Install command syntax issue in jcop tool
          Umer
          Hi,

          Are you trying to update your Pin with a defulat PIN that is when you personalize or install your card the PIN should be 12345. Is it what your trying to do ?

          BR
          Umer
          • 2. Re: Install command syntax issue in jcop tool
            918703
            i think install command invoke the applet in the memory or make a instance in memory which will be active in life time. right?
            so i want to pass a password like- 0102030405 with help of install command, it will be the default password , or in future if i will be require then i can change this with new one. As i read, after passing this in install command, i need to use below code to get 0102030405.
            following code:-
            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
            so tell me please what would be the install command?
            --- wallet code is like--
             public static void install(byte[] bArray, short bOffset, byte bLength){
                // create a Wallet applet instance
                new Wallet(bArray, bOffset, bLength);
              } // end of install method
            
            // constucor code is:-
            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
            
            // i want to implement this concept......................
            Edited by: daniel on Feb 28, 2012 7:17 AM
            • 3. Re: Install command syntax issue in jcop tool
              Umer
              Hi,

              Look if your goal is to set a default PIN of 12345 then don't do this in that way, it is very simple just do like that:
              private UserApplet(byte[] bArray, short bOffset, byte bLength) {
              try
               {
                             bArray[0] = 01;
                             bArray[1] = 02;
                             bArray[2] = 03;
                             bArray[3] = 04;
                             bArray[4] = 05;
                             bOffset = 0;
                             bLength = 5;
              
                             /*
                              setting the PIN default value to 12345
                              * 
                              */
                             pin.update(bArray, bOffset, bLength);
                             
                }
              catch()
              {
              
              }
              Also, you can't send your PIN within the install command.
              • 4. Re: Install command syntax issue in jcop tool
                918703
                hello umer,
                I dont think so that , i can not send data in install command, if we not then
                why install(byte[], short, byte)? have three parameter, if it is then , there would be use of this in somewhere, i think i can pass some data { pin here } in install command nd can retrive it and use it whenever we want.
                what do u think?
                [ look here it also use the parameter value, if it is using it means it is coming from somewhere, | http://www.informatik.uni-augsburg.de/swt/lehre/javacard/JavaCard-2.1-API/javacard.framework.Applet.html#_top_ ]
                one thing is more
                why we use -q option in install command
                • 5. Re: Install command syntax issue in jcop tool
                  Umer
                  When you read the Global Platform document you will find the following specs:
                  The array, bArray, shall contain the following consecutive LV coded data:
                  *• Length of the instance AID;*
                  *• The instance AID;*
                  *• Length of the Privileges;*
                  *• The Privileges;*
                  *• Length of the Application Specific Parameters;*
                  *• The Application Specific Parameters.*
                  The byte, bOffset, shall contain an offset within the array pointing to the length of the instance AID.
                  The byte, bLength, shall contain a length indicating the total length of the above-defined data in the array.
                  The applet is required to utilize the instance AID as a parameter when invoking the register (byte [] bArray, short bOffset, byte bLength) method of the Class Applet of the Java Card™ 2.2.x Application Programming Interface specification.

                  Also, you can see the GP install for install command and you will there is not field which states the PIN property or any data like that.

                  Hope you are clear now.

                  BR
                  Umer
                  • 6. Re: Install command syntax issue in jcop tool
                    Umer
                    Moreover, if you want to use the installation parameters as your default PIN then yes you can do that but in that case your default PIN will be up to 1-2 bytes only as installation parameters length is only 1-2 bytes.
                    • 7. Re: Install command syntax issue in jcop tool
                      safarmer
                      Hi,

                      To send install parameters in JCShell you would send the following:
                      install -i a0010203040506070809  -q C9#(0102030405) a00102030405060708 a0010203040506070809
                      The #() prepends the length of the data in the parenthesis. Also, you can send more than 2 bytes in the install parameter. There is a byte to define the length of the install params.

                      Cheers,
                      Shane
                      • 8. Re: Install command syntax issue in jcop tool
                        Umer
                        safarmer wrote:
                        Also, you can send more than 2 bytes in the install parameter. There is a byte to define the length of the install params.
                        Yes are right.
                        • 9. Re: Install command syntax issue in jcop tool
                          918703
                          thanks safamer,

                          I tried and it is working fine, thanks bro.