9 Replies Latest reply: Mar 5, 2012 10:38 PM by Umer RSS

    CVM update() responds 6F00

    921719
      Hi all,

      I'm new of Java Card:
      I don't know exactly about CVM, CVM value? Please help me to explain them.
      And I try these lines:

      CVM aCVM = GPSystem.getCVM((byte) GPSystem.CVM_GLOBAL_PIN);
      aCVM.update(aCVMValue, (short) 1, (byte) 8, CVM.FORMAT_HEX);

      After that, it responds 6F00???

      I don't understand about update() function. I try with aCVMValue = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09...}

      I'm waiting for answers ...

      Thank all.
        • 1. Re: CVM update() responds 6F00
          Umer
          Plz share your complete code and stack trace..
          • 2. Re: CVM update() responds 6F00
            921719
            My source code:
            package TestGPPackage;
            import javacard.framework.APDU;
            import javacard.framework.Applet;
            import javacard.framework.ISO7816;
            import javacard.framework.ISOException;
            import org.globalplatform.CVM;
            import org.globalplatform.GPSystem;

            public class Test_GPS_getSecureChannel extends Applet
            {
            public static byte[] aCVMValue = new byte[100];

            private Test_GPS_getSecureChannel()
            {
            for (byte i = 0; i < 100; i++)
            {
            aCVMValue[ i ] = i;
            }
            }

            public static void install(byte bArray[], short bOffset, byte bLength)
            throws ISOException
            {
            Test_GPS_getSecureChannel appletTestGetSecureChannel = new Test_GPS_getSecureChannel();
            if (bArray[bOffset] != 0)
            {
            appletTestGetSecureChannel.register(bArray,
            (short) (bOffset + (short) 1), bArray[bOffset]);
            } else
            {
            appletTestGetSecureChannel.register();
            }

            }

            public static final short GP_RESPONSE_DATA = (short) 0x9F00;

            /**
            * Process method. Dispatch the process according to INS value.
            */
            public void process(APDU arg0) throws ISOException
            {
            byte[] buffer = arg0.getBuffer();
            if (selectingApplet())
            return;

            byte INS = buffer[ISO7816.OFFSET_INS];
            switch (INS)
            {
            case 0x01:
            TestIsActive();
            break;

            default:
            // Return SW_INS_NOT_SUPPORTED = 6D00
            ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
            break;
            }
            }

            public void TestIsActive()
            {
            CVM aCVM = GPSystem.getCVM((byte) GPSystem.CVM_GLOBAL_PIN);
            aCVM.update(aCVMValue, (short) 1, (byte) 8, CVM.FORMAT_HEX);
            }
            }
            >

            Trace log:

            >
            cm> /term "Remote|localhost:61067"
            --Opening terminal
            /card -a a000000003000000 -c com.ibm.jc.CardManager
            resetCard with timeout: 0 (ms)
            --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.
            IOCTL().
            ATR:
            T = 1
            => 00 A4 04 00 08 A0 00 00 00 03 00 00 00 00 ..............
            (789249 nsec)
            <= 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 01 17 33 00 73 4A 06 07 2A ...n.G...3.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> set-key 255/1/DES-ECB/404142434445464748494a4b4c4d4e4f 255/2/DES-ECB/404142434445464748494a4b4c4d4e4f 255/3/DES-ECB/404142434445464748494a4b4c4d4e4f
            cm> init-update 255
            => 80 50 00 00 08 1A AC 89 2E 8D D3 70 DD 00 .P.........p..
            (1566 usec)
            <= 00 00 DE 81 34 18 39 B7 09 70 FF 02 00 00 3D 02 ....4.9..p....=.
            9C 31 C7 89 7E 80 C8 68 F2 E2 61 2F 90 00 .1..~..h..a/..
            Status: No Error
            cm> ext-auth plain
            => 84 82 00 00 10 B1 C0 67 07 DC E9 1E A1 C1 8F 2C .......g.......,
            54 4B FF 0A 57 TK..W
            (1558 usec)
            <= 90 00 ..
            Status: No Error
            cm> delete -r 0102030405
            => 80 E4 00 80 07 4F 05 01 02 03 04 05 00 .....O.......
            (4230 usec)
            <= 6A 88 j.
            Status: Reference data not found
            jcshell: Error code: 6a88 (Reference data not found)
            jcshell: Wrong response APDU: 6A88
            Ignoring expected error
            cm> upload -c -b 250 "D:\WorkSpace\TestGP\bin\TestGPPackage\javacard\TestGPPackage.cap"
            => 80 E6 02 00 12 05 01 02 03 04 05 08 A0 00 00 00 ................
            03 00 00 00 00 00 00 00 ........
            (3125 usec)
            <= 00 90 00 ...
            Status: No Error
            Start loading Header.cap (36 byte)
            => 80 E8 00 00 24 C4 82 01 B8 01 00 1D DE CA FF ED ....$...........
            02 02 04 00 01 05 01 02 03 04 05 0D 54 65 73 74 ............Test
            47 50 50 61 63 6B 61 67 65 00 GPPackage.
            (1502 usec)
            <= 00 90 00 ...
            Status: No Error
            Header.cap loaded (36 byte)
            Start loading Directory.cap (36 byte)
            => 80 E8 00 01 24 02 00 21 00 1D 00 21 00 0A 00 14 ....$..!...!....
            00 32 00 10 00 7D 00 71 00 11 00 00 00 70 03 07 .2...}.q.....p..
            00 02 00 01 00 64 02 01 00 00 .....d....
            (1247 usec)
            <= 00 90 00 ...
            Status: No Error
            Directory.cap loaded (36 byte)
            Start loading Import.cap (23 byte)
            => 80 E8 00 02 17 04 00 14 02 03 01 07 A0 00 00 00 ................
            62 01 01 00 01 06 A0 00 00 01 51 00 00 b.........Q..
            (1426 usec)
            <= 00 90 00 ...
            Status: No Error
            Import.cap loaded (23 byte)
            Start loading Applet.cap (13 byte)
            => 80 E8 00 03 0D 03 00 0A 01 06 01 02 03 04 05 01 ................
            00 1C 00 ...
            (907236 nsec)
            <= 00 90 00 ...
            Status: No Error
            Applet.cap loaded (13 byte)
            Start loading Class.cap (19 byte)
            => 80 E8 00 04 13 06 00 10 00 00 00 80 03 00 FF 00 ................
            07 02 00 00 00 3D 00 66 00 .....=.f.
            (3324 usec)
            <= 00 90 00 ...
            Status: No Error
            Class.cap loaded (19 byte)
            Start loading Method.cap (128 byte)
            => 80 E8 00 05 80 07 00 7D 00 03 11 18 8C 00 01 03 .......}........
            30 70 0D 7B 00 06 1D 1D 38 1D 04 41 5B 30 1D 10 0p.{....8..A[0..
            64 6C F2 7A 05 31 8F 00 07 3D 8C 00 0B 2E 18 1D dl.z.1...=......
            25 60 0F 1B 18 1D 04 41 18 1D 25 8B 00 0A 70 06 %`.....A..%...p.
            1B 8B 00 04 7A 02 22 19 8B 00 00 2D 18 8B 00 09 ....z."....-....
            60 03 7A 1A 04 25 32 1F 73 00 0F 00 01 00 01 00 `.z..%2.s.......
            09 18 8B 00 03 70 08 11 6D 00 8D 00 08 7A 05 11 .....p..m....z..
            10 11 8D 00 05 2C 19 7B 00 06 04 10 08 06 8E 05 .....,.{........
            00 02 05 3B 7A 00 ...;z.
            (3153 usec)
            <= 00 90 00 ...
            Status: No Error
            Method.cap loaded (128 byte)
            Start loading StaticField.cap (116 byte)
            => 80 E8 00 06 74 08 00 71 00 02 00 01 00 01 03 00 ....t..q........
            64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d...............
            00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
            00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
            00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
            00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
            00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
            00 00 00 00 00 00 00 00 00 00 ..........
            (2598 usec)
            <= 00 90 00 ...
            Status: No Error
            StaticField.cap loaded (116 byte)
            Start loading ConstantPool.cap (53 byte)
            => 80 E8 00 07 35 05 00 32 00 0C 03 80 0A 01 06 80 ....5..2........
            03 00 01 81 01 00 03 00 02 08 03 80 03 01 06 81 ................
            03 03 05 00 00 00 01 00 02 00 06 80 07 01 03 80 ................
            03 03 03 80 03 02 06 00 00 01 00 ...........
            (3590 usec)
            <= 00 90 00 ...
            Status: No Error
            ConstantPool.cap loaded (53 byte)
            Start loading RefLocation.cap (20 byte)
            => 80 E8 80 08 14 09 00 11 00 00 00 0D 05 07 13 04 ................
            11 06 07 05 15 08 08 05 08 00 ..........
            (3584 usec)
            <= 00 90 00 ...
            Status: No Error
            RefLocation.cap loaded (20 byte)
            Load report:
            444 bytes loaded in 0.0 seconds
            effective code size on card:
            + package AID 5
            + applet AIDs 13
            + classes 19
            + methods 128
            + statics 109
            + exports 0
            ------------------------------
            overall 274 bytes
            cm> install -i 010203040501 -p -q C9#() 0102030405 010203040501
            => 80 E6 0C 00 1A 05 01 02 03 04 05 06 01 02 03 04 ................
            05 01 06 01 02 03 04 05 01 01 02 02 C9 00 00 00 ................
            (10900 usec)
            <= 00 90 00 ...
            Status: No Error
            cm> card-info
            => 80 F2 80 00 02 4F 00 00 .....O..
            (727464 nsec)
            <= 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..
            (698142 nsec)
            <= 06 01 02 03 04 05 01 07 02 90 00 ...........
            Status: No Error
            => 80 F2 10 00 02 4F 00 00 .....O..
            (1259 usec)
            <= 07 A0 00 00 00 03 53 50 01 00 01 08 A0 00 00 00 ......SP........
            03 53 50 41 05 01 02 03 04 05 01 00 01 06 01 02 .SPA............
            03 04 05 01 90 00 ......
            Status: No Error

            Card Manager AID : A000000003000000
            Card Manager state : OP_READY

            Application: SELECTABLE (------P-) 010203040501
            Load File : LOADED (--------) A0000000035350 (Security Domain)
            Module : A000000003535041
            Load File : LOADED (--------) 0102030405
            Module : 010203040501
            cm> @test
            /select 010203040501
            => 00 A4 04 00 06 01 02 03 04 05 01 00 ............
            (438783 nsec)
            <= 90 00 ..
            Status: No Error
            /send 8001000000
            => 80 01 00 00 00 .....
            (807052 nsec)
            <= 6F 00 o.
            Status: No precise diagnosis
            {quote}
            • 3. Re: CVM update() responds 6F00
              Umer
              At a glance i have found following error in your code:
              for (byte i = 0; i < 100; i++)
              {
               aCVMValue = i;
              }
              And please try to use
               tages across your code. I will let you know when i will find solution of your problem...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
              • 4. Re: CVM update() responds 6F00
                Umer
                Plz try the following code:
                package cvmPack;
                
                import org.globalplatform.CVM;
                import org.globalplatform.GPSystem;
                
                import javacard.framework.APDU;
                import javacard.framework.Applet;
                import javacard.framework.ISO7816;
                import javacard.framework.ISOException;
                
                public class CVMTest extends Applet {
                     public static byte[] aCVMValue = new byte[100];
                     public static final short GP_RESPONSE_DATA = (short) 0x9F00;
                     
                     private CVMTest()
                     {
                          for (byte i = 0; i < 100; i++)
                          {
                               aCVMValue[i] = i;
                          }
                     }
                     public static void install(byte bArray[], short bOffset, byte bLength)
                     throws ISOException
                     {
                          CVMTest appletTestGetSecureChannel = new CVMTest();
                          if (bArray[bOffset] != 0)
                          {
                               appletTestGetSecureChannel.register(bArray, (short) (bOffset + (short) 1), bArray[bOffset]);
                          } 
                          else
                          {
                               appletTestGetSecureChannel.register();
                          }
                     }
                     public void process(APDU arg0) throws ISOException
                     {
                          byte[] buffer = arg0.getBuffer();
                          if (selectingApplet())
                          return;
                     
                          byte INS = buffer[ISO7816.OFFSET_INS];
                          switch (INS)
                          {
                               case 0x01:
                               TestIsActive();
                          break;     
                          default:
                               ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
                          break;
                          }
                     }
                     public void TestIsActive()
                     {
                          CVM aCVM = GPSystem.getCVM((byte) GPSystem.CVM_GLOBAL_PIN);
                          aCVM.update(aCVMValue, (short) 1, (byte) 8, CVM.FORMAT_HEX);
                     }
                }
                Stack Tace:
                cm>  upload "E:\softwaress\3clipse\workspace\CVMTestProject\bin\cvmPack\javacard\cvmPack.cap"
                 => 80 E6 02 00 15 08 63 76 6D 2E 70 61 63 6B 08 A0    ......cvm.pack..
                    00 00 00 03 00 00 00 00 00 00 00                   ...........
                 (1295 usec)
                 <= 00 90 00                                           ...
                Status: No Error
                 => 80 E8 00 00 FF C4 82 01 B6 01 00 1A DE CA FF ED    ................
                    02 02 04 00 01 08 63 76 6D 2E 70 61 63 6B 07 63    ......cvm.pack.c
                    76 6D 50 61 63 6B 02 00 21 00 1A 00 21 00 0B 00    vmPack..!...!...
                    14 00 32 00 10 00 7D 00 71 00 11 00 00 00 70 02    ..2...}.q.....p.
                    B3 00 02 00 01 00 64 02 01 00 04 00 14 02 02 01    ......d.........
                    07 A0 00 00 00 62 01 01 00 01 06 A0 00 00 01 51    .....b.........Q
                    00 03 00 0B 01 07 63 76 6D 2E 61 70 70 00 1C 06    ......cvm.app...
                    00 10 00 00 00 80 03 00 FF 00 07 02 00 00 00 3D    ...............=
                    00 66 07 00 7D 00 03 11 18 8C 00 08 03 30 70 0D    .f..}........0p.
                    7B 00 07 1D 1D 38 1D 04 41 5B 30 1D 10 64 6C F2    {....8..A[0..dl.
                    7A 05 31 8F 00 00 3D 8C 00 01 2E 18 1D 25 60 0F    z.1...=......%`.
                    1B 18 1D 04 41 18 1D 25 8B 00 05 70 06 1B 8B 00    ....A..%...p....
                    02 7A 02 22 19 8B 00 0B 2D 18 8B 00 0A 60 03 7A    .z."....-....`.z
                    1A 04 25 32 1F 73 00 0F 00 01 00 01 00 09 18 8B    ..%2.s..........
                    00 06 70 08 11 6D 00 8D 00 04 7A 05 11 10 11 8D    ..p..m....z.....
                    00 09 2C 19 7B 00 07 04 10 08 06 8E 05 00 03 05    ..,.{...........
                    3B 7A 08 00 00                                     ;z...
                 (4788 usec)
                 <= 00 90 00                                           ...
                Status: No Error
                 => 80 E8 80 01 BB 71 00 02 00 01 00 01 03 00 64 00    .....q........d.
                    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
                    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
                    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
                    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
                    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
                    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
                    00 00 00 00 00 00 00 05 00 32 00 0C 01 00 02 00    .........2......
                    06 00 00 01 03 80 03 01 01 81 01 00 06 80 07 01    ................
                    03 80 03 02 03 00 02 08 05 00 00 00 06 80 03 00    ................
                    06 81 03 03 03 80 03 03 03 80 0A 01 09 00 11 00    ................
                    00 00 0D 05 07 13 04 11 06 07 05 15 08 08 05 08    ................
                    00                                                 .
                 (6708 usec)
                 <= 00 90 00                                           ...
                Status: No Error
                Load report:
                  442 bytes loaded in 0.0 seconds
                  effective code size on card:
                      + package AID       8
                      + applet AIDs       14
                      + classes           19
                      + methods           128
                      + statics           109
                      + exports           0
                     ------------------------------
                        overall           278  bytes
                cm>  install -i 63766d2e617070  -q C9#() 63766d2e7061636b 63766d2e617070
                 => 80 E6 0C 00 1F 08 63 76 6D 2E 70 61 63 6B 07 63    ......cvm.pack.c
                    76 6D 2E 61 70 70 07 63 76 6D 2E 61 70 70 01 00    vm.app.cvm.app..
                    02 C9 00 00 00                                     .....
                 (11672 usec)
                 <= 90 00                                              ..
                Status: No Error
                cm>  card-info
                 => 80 F2 80 00 02 4F 00 00                            .....O..
                 (483861 nsec)
                 <= 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..
                 (525486 nsec)
                 <= 07 63 76 6D 2E 61 70 70 07 00 90 00                .cvm.app....
                Status: No Error
                 => 80 F2 10 00 02 4F 00 00                            .....O..
                 (775238 nsec)
                 <= 07 A0 00 00 00 03 53 50 01 00 01 08 A0 00 00 00    ......SP........
                    03 53 50 41 08 63 76 6D 2E 70 61 63 6B 01 00 01    .SPA.cvm.pack...
                    07 63 76 6D 2E 61 70 70 90 00                      .cvm.app..
                Status: No Error
                
                Card Manager AID   :  A000000003000000
                Card Manager state :  OP_READY
                
                    Application:  SELECTABLE (--------) "cvm.app"       
                    Load File  :      LOADED (--------) A0000000035350   (Security Domain)
                     Module    :                        A000000003535041
                    Load File  :      LOADED (--------) "cvm.pack"      
                     Module    :                        "cvm.app"
                cm>  /select |cvm.app
                 => 00 A4 04 00 07 63 76 6D 2E 61 70 70 00             .....cvm.app.
                 (493639 nsec)
                 <= 90 00                                              ..
                Status: No Error
                cm>  /send 8001000000
                 => 80 01 00 00 00                                     .....
                 (648406 nsec)
                 <= 90 00                                              ..
                Status: No Error
                BR
                Umer
                • 5. Re: CVM update() responds 6F00
                  921719
                  aCVMValue = i;
                  It's not right with my source code:
                  aCVMValue[i] = i
                  : But it is not problem, forget it ^^

                  Yes, i have just tried with new project with new source code, and it responds 0x9000. But when I set Privileges to "CVM Management", it responds 0x6F00???
                  By the way, when your code responded 0x9000, can you check the update CVM values with aCVM.verify() method. So that we can check the update() worked correctly. I tried, and it failed.

                  Thank you for your support.

                  Best regards,
                  ...
                  Umer wrote:
                  At a glance i have found following error in your code:
                  for (byte i = 0; i < 100; i++)
                  {
                  aCVMValue = i;
                  }
                  And please try to use
                   tages across your code. I will let you know when i will find solution of your problem...
                  Edited by: 918716 on Mar 5, 2012 2:08 AM
                  • 6. Re: CVM update() responds 6F00
                    Umer
                    es, i have just tried with new project with new source code, and it responds 0x9000. But when I set Privileges to "CVM Management", it responds 0x6F00???
                    Plz always share your trace.

                    I have tried to upload that applet on my card but my card does not support CVM. So need to do it on your's card.
                    Steps are simple, install that code with the CVM Management privilige enabled and check by following that if the Pin is updated or not:
                         public void TestIsActive(APDU apdu)
                         {
                              byte[] buffer = apdu.getBuffer();
                              
                              CVM aCVM = GPSystem.getCVM((byte) GPSystem.CVM_GLOBAL_PIN);
                              if (aCVM == null)
                              {
                                   buffer[1] = (byte)0x03;
                              }
                              else
                              {
                                   if (aCVM.isActive())
                                        buffer[1] = (byte)0x04;               
                              }
                              boolean isUpdated = aCVM.update(aCVMValue, (short) 0, (byte) 8, CVM.FORMAT_HEX);          
                              if (isUpdated)
                                   buffer[0] = (byte)0x01;
                              else
                                   buffer[0] = (byte)0x00;
                              apdu.setOutgoingAndSend((short)0, (short)2);
                         }
                    • 7. Re: CVM update() responds 6F00
                      safarmer
                      Hi,
                      And I try these lines:

                      CVM aCVM = GPSystem.getCVM((byte) GPSystem.CVM_GLOBAL_PIN);
                      aCVM.update(aCVMValue, (short) 1, (byte) 8, CVM.FORMAT_HEX);

                      After that, it responds 6F00???

                      I don't understand about update() function. I try with aCVMValue = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09...}
                      You need to put the CVM value into a global array as the CVM is a global object. The only global array you have access to is the APDU buffer (or the install buffer in the install method). You can copy your CVM value into one of these buffers and use that in the call to update.

                      Cheers,
                      Shane
                      • 8. Re: CVM update() responds 6F00
                        921719
                        Thank you, Shane: You were right. I fixed my source code with your answer.

                        Thank you, Umer: for your support a lot.

                        safarmer wrote:
                        Hi,
                        And I try these lines:

                        CVM aCVM = GPSystem.getCVM((byte) GPSystem.CVM_GLOBAL_PIN);
                        aCVM.update(aCVMValue, (short) 1, (byte) 8, CVM.FORMAT_HEX);

                        After that, it responds 6F00???

                        I don't understand about update() function. I try with aCVMValue = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09...}
                        You need to put the CVM value into a global array as the CVM is a global object. The only global array you have access to is the APDU buffer (or the install buffer in the install method). You can copy your CVM value into one of these buffers and use that in the call to update.

                        Cheers,
                        Shane
                        • 9. Re: CVM update() responds 6F00
                          Umer
                          Welcome bro.