0 Replies Latest reply: Jul 10, 2014 12:49 AM by Kenat RSS

    Some question about install for personalization

    Kenat

      Hi, comrade.
      I'm created SD with DAP, load and install applet into it.
      Now, where i have send command install for personalization, SD responsible that INS value not supported, what is wrong ?

      applet source code

       

      public class J2AGP extends Applet implements Application {
          SecureChannel m_SecureChannel;
          byte [] m_persoData;
          short m_pdLength;
          /**
           * Installs this applet.
           *
           * @param bArray
           *            the array containing installation parameters
           * @param bOffset
           *            the starting offset in bArray
           * @param bLength
           *            the length in bytes of the parameter data in bArray
           */
          public static void install(byte[] bArray, short bOffset, byte bLength) {
              new J2AGP();
          }

          /**
           * Only this class's install method should create the applet object.
           */
          protected J2AGP()
          {
              m_persoData = new byte[256];
              m_pdLength = 0;
              register();
          }

          public boolean select()
          {
              m_SecureChannel = GPSystem.getSecureChannel();
              return true;
          }
          public void deselect()
          {
              m_SecureChannel.resetSecurity();
          }
          /**
           * Processes an incoming APDU.
           *
           * @see APDU
           * @param apdu
           *            the incoming APDU
           */
          public void process(APDU apdu) {
              //Insert your code here
              byte [] buffer = apdu.getBuffer();
              short le = 0;
             
              switch ( buffer[ISO7816.OFFSET_INS] )
              {
                  case ISO7816.INS_SELECT:
                           if  ( !selectingApplet() )
                      {
                          ISOException.throwIt(ISO7816.SW_APPLET_SELECT_FAILED);
                      }
                      break;
                  case 0x20:
                      {
                          OPSystem.getCPLCData(apdu,(short)0,(short)0x0C,(short)0x04);                 
                          apdu.setOutgoingAndSend((short) 0, (short) 4);
                      }
                      break;
                  case 0x21:
                      {
                          apdu.setOutgoing();
                          apdu.setOutgoingLength(this.m_pdLength);
                          apdu.sendBytesLong(this.m_persoData, (short)0, this.m_pdLength);

                          return;
                      }
                      break;
                  default:
                      le = m_SecureChannel.processSecurity(apdu);
                      //ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
              }
              if ( 0 != le )
              {
                  apdu.setOutgoingAndSend(ISO7816.OFFSET_CDATA, le);
              }
          }
         
          public void processData( byte[] buffer, short offset, short length )
          {
              Util.arrayCopyNonAtomic(buffer, offset, this.m_persoData , (short)0, length);
              this.m_pdLength = length;
          }

       

      JCShell
      cm> /card
      --Waiting for card...
      ATR=3B F8 13 00 00 81 31 FE 45 4A 43 4F 50 76 32 34    ;.....1.EJCOPv24
          31 B7                                              1.
      ATR: T=1, FI=1/DI=3 (93clk/etu), N=0, IFSC=254, BWI=4/CWI=5, Hist="JCOPv241"
      => 00 A4 04 00 07 A0 00 00 00 03 00 00 00             .............
      (51298 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 81 02 31 00 73 4A 06 07 2A    ...n.G...1.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> /card -a a000000003000000 -c com.ibm.jc.CardManager
      set-key
      init-update 255
      --Waiting for card...
      ATR=3B F8 13 00 00 81 31 FE 45 4A 43 4F 50 76 32 34    ;.....1.EJCOPv24
          31 B7                                              1.
      ATR: T=1, FI=1/DI=3 (93clk/etu), N=0, IFSC=254, BWI=4/CWI=5, Hist="JCOPv241"
      => 00 A4 04 00 08 A0 00 00 00 03 00 00 00 00          ..............
      (51139 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 81 02 31 00 73 4A 06 07 2A    ...n.G...1.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> cm>  => 80 50 00 00 08 BA 21 F6 49 91 09 D8 5B 00          .P....!.I...[.
      (66480 usec)
      <= 00 00 01 06 06 19 40 95 22 28 FF 02 01 1B 1C FC    ......@."(......
          DA A4 22 2C EE 3B 40 00 47 D5 FF 18 90 00          ..",.;@.G.....
      Status: No Error
      cm> ext-auth plain
      => 84 82 00 00 10 83 9A 87 61 18 0B 90 7B 8D A3 49    ........a...{..I
          04 B5 63 23 FF                                     ..c#.
      (66449 usec)
      <= 90 00                                              ..
      Status: No Error
      cm> ls
      => 80 F2 80 00 02 4F 00 00                            .....O..
      (23946 usec)
      <= 08 A0 00 00 00 03 00 00 00 01 9E 90 00             .............
      Status: No Error
      => 80 F2 40 00 02 4F 00 00                            ..@..O..
      (28375 usec)
      <= 08 A0 00 00 00 03 53 50 42 0F C0 06 E7 4A 06 8C    ......SPB....J..
          24 72 07 02 90 00                                  $r....
      Status: No Error
      => 80 F2 10 00 02 4F 00 00                            .....O..
      (39565 usec)
      <= 07 A0 00 00 00 03 53 50 01 00 01 08 A0 00 00 00    ......SP........
          03 53 50 41 06 E7 4A 06 8C 24 71 01 00 01 06 E7    .SPA..J..$q.....
          4A 06 8C 24 72 90 00                               J..$r..
      Status: No Error

      Card Manager AID   :  A000000003000000
      Card Manager state :  OP_READY

          Application:  SELECTABLE (------P-) E74A068C2472
          Sec. Domain:PERSONALIZED (SV------) A000000003535042
          Load File  :      LOADED (--------) A0000000035350   (Security Domain)
           Module    :                        A000000003535041
          Load File  :      LOADED (--------) E74A068C2471
           Module    :                        E74A068C2472
      cm> /select A000000003535042
      set-key
      init-update 1
      => 00 A4 04 00 08 A0 00 00 00 03 53 50 42 00          ..........SPB.
      (53332 usec)
      <= 6F 65 84 08 A0 00 00 00 03 53 50 42 A5 59 9F 65    oe.......SPB.Y.e
          01 FF 9F 6E 06 47 91 81 02 31 00 73 4A 06 07 2A    ...n.G...1.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> cm>  => 80 50 01 00 08 DB 2C F3 72 68 45 50 E2 00          .P....,.rhEP..
      (66937 usec)
      <= 50 42 00 00 00 00 00 00 00 00 01 02 00 11 89 29    PB.............)
          1B 0D 8D 6A B6 81 2F E3 31 E8 30 4C 90 00          ...j../.1.0L..
      Status: No Error
      cm> ext-auth plain
      => 84 82 00 00 10 3E 81 FC E0 EE 17 D6 AB 39 CA 7A    .....>.......9.z
          45 8D C7 C6 96                                     E....
      (66960 usec)
      <= 90 00                                              ..
      Status: No Error
      cm> send "80E620000C000006E74A068C247200000000"
      => 80 E6 20 00 0C 00 00 06 E7 4A 06 8C 24 72 00 00    .. ......J..$r..
          00 00                                              ..
      (22700 usec)
      <= 6D 00                                              m.
      Status: INS value not supported
      cm>