6 Replies Latest reply: Mar 18, 2013 9:19 AM by fgrieu RSS

    GPShell - installing file .cap error 6985

    995187
      Hi !!!

      I am using
      GPShell
      Java Card Gemalto TOP IM GX4

      script:
           mode_201
           gemXpressoPro
           enable_trace
           establish_context
           card_connect
           select -AID A000000018434D00
           open_sc -security 3 -keyind 0 -keyver 0 -key 47454d5850524553534f53414d504c45
           install -file C:\Users\Kar\workspace\_Transporte_JC\src\applets\javacard\applets.cap -sdAID A000000018434D00

           card_disconnect
           release_context

      I've got this message, when i tried to load .CAP file into Java Card :

      C:\Users\Karina>gpshell.exe
      mode_201
      mode_201
      gemXpressoPro
      gemXpressoPro
      enable_trace
      enable_trace
      establish_context
      establish_context
      card_connect
      card_connect
      select -AID A000000018434D00
      select -AID A000000018434D00
      Command --> 00A4040008A000000018434D00
      Wrapped command --> 00A4040008A000000018434D00
      Response <-- 6F198408A000000018434D00A50D9F6E061291609505009F6501FF9000
      open_sc -security 3 -keyind 0 -keyver 0 -key 47454d5850524553534f53414d504c45
      open_sc -security 3 -keyind 0 -keyver 0 -key 47454d5850524553534f53414d504c45
      Command --> 8050000008B60D52C464F836A200
      Wrapped command --> 8050000008B60D52C464F836A200
      Response <-- 4D008169000174850866FF019CA5C42738E5A0B7FA23EA1A31353EC29000
      Command --> 8482030010FDBB3FE3F201C9250972FCEF58766DA1
      Wrapped command --> 8482030010FDBB3FE3F201C9250972FCEF58766DA1
      Response <-- 9000
      install -file C:\Users\Karina\workspaceAndroid\_Transporte_JC\src\applets\javaca
      rd\applets.cap -sdAID A000000018434D00
      install -file C:\Users\Karina\workspaceAndroid\_Transporte_JC\src\applets\javaca
      rd\applets.cap -sdAID A000000018434D00
      Command --> 80E602001D0A0102030405060708090008A000000018434D000006EF04C60208F000
      00
      Wrapped command --> 84E60200283F72458FC3BB9C74FC680E0DB55CE54BC8E00E80C123BFB7BA
      AFB950F2D0842502C7AC8A3F67301200
      Response <-- 009000
      Command --> 80E80000EFC48208E0010014DECAFFED01020400010A010203040506070809000200
      1F0014001F002B001500BA0036048B001B00A600000213000A0002000B02030004001502030107A0
      000000620101000107A000000062000103002B030B010203040506070809000301760B0102030405
      06070809000202C80B01020304050607080900010036060036008003020002040400000043FFFFFF
      FF004B008003010001040400000183FFFFFFFF018C0080030100010404000002D5FFFFFFFF02DE07
      048B000510188C00041807900B3D0304383D0404383D0504383D0604388700188F00173D06078C00
      248701AD01AD0003AD00
      Wrapped command --> 84E80000F85200740D2270081C6B42B0CE2A5CE273B9AB3E8142EEED54AB
      A4D975FEAB62647E87A5DB8D4E47E05AEF70E907585055C065F26104DD839ABC31EBE15F310927B6
      74C7267895628578D3DFC9167DBC8BC86C5C1AACA174F94220AA33914C0C0A91092EA01BE42C4DC6
      28DD916533979115D94B19F4466F06CF720E38AC0D315423DFCD0BC3CC663D2777EA6F64124E86D3
      6A2619749C6C17F60280479E7C25F5CAA6EC2E49848B76DE5794EC8600E88E2066D363A37B0C12EF
      AA8FBE60A5E299A39B592722525B790040069691A9596989DCB9A4C4B3F13E0E9528A3AC8EDC5E7B
      8FB617C31C672BD126FA5D5385B0D27E1F6B45AA21080B
      Response <-- 6985
      load() returns 0x80206985 (6985: Command not allowed - Conditions of use not sat
      isfied.)

      There's message error :
      install_for_load() returns 0x80206985 (6985: Command not allowed - Conditions of use not satisfied.

      Please help me
        • 1. Re: GPShell - installing file .cap error 6985
          safarmer
          Hi,

          Your cap file is not valid for your card (either wrong version or missing a dependency). My guess is that the cap file was not converted with the correct Java Card version. Looking at the CAP file header it looks like you used JCDK v3.0.1 to convert the classes to a CAP file yet your card is JC2.1.2. Try an older version of the converter and see if that works.

          - Shane
          • 2. Re: GPShell - installing file .cap error 6985
            995187
            Thanks for replying

            Before I used to compile and convert JCDK 2.2.2
            Now I'm using to compile JCDK 2.2.2 and to convert JCDK 2.1.2

            But, now I get this message :
            install_for_install_and_make_selectable() returns 0x80206A80 (6A80: Wrong data / Incorrect values in command data.)

            mode_201
            enable_trace
            enable_timer
            establish_context
            command time: 31 ms
            card_connect
            command time: 141 ms
            select -AID A000000018434D00
            Command --> 00A4040008A000000018434D00
            Wrapped command --> 00A4040008A000000018434D00
            Response <-- 6F198408A000000018434D00A50D9F6E061291609505009F6501FF9000
            command time: 890 ms
            open_sc -security 3 -keyind 0 -keyver 0 -key 47454d5850524553534f53414d504c45 -k
            eyDerivation visa2 // Open secure channel
            Command --> 8050000008D8A7A6597AF2A89A00
            Wrapped command --> 8050000008D8A7A6597AF2A89A00
            Response <-- 4D008169000174850866FF015D31EE4A194F878F2EF11B91670965769000
            Command --> 848203001097E072EA110C6362E46531272B838585
            Wrapped command --> 848203001097E072EA110C6362E46531272B838585
            Response <-- 9000
            command time: 436 ms
            delete -AID 01020304050607080900
            Command --> 80E400000C4F0A0102030405060708090000
            Wrapped command --> 84E4000018CC8AABCBF8F9613BD3F025C9B71D46839D221706C011D68D00

            Response <-- 6A88
            delete() returns 0x80206A88 (6A88: Referenced data not found.)
            command time: 32 ms
            delete -AID D1D2D3D4D5
            Command --> 80E40000074F05D1D2D3D4D500
            Wrapped command --> 84E4000010DCA92DD250B979B72100167F559E782300
            Response <-- 009000
            command time: 93 ms
            delete -AID D0D1D2D3D4D50101
            Command --> 80E400000A4F08D0D1D2D3D4D5010100
            Wrapped command --> 84E400001833644C791C1A78809B1ED43E00BE93398AC1808C0254DC1300

            Response <-- 6A88
            delete() returns 0x80206A88 (6A88: Referenced data not found.)
            command time: 31 ms
            delete -AID D0D1D2D3D4D501
            Command --> 80E40000094F07D0D1D2D3D4D50100
            Wrapped command --> 84E400001800A1450E77025930767A487F93497F12B230B25712CAE0E200

            Response <-- 6A88
            delete() returns 0x80206A88 (6A88: Referenced data not found.)
            command time: 32 ms
            install -file C:\Users\Karina\workspaceAndroid\aaaa\src\app\javacard\app.cap -s
            dAID A000000018434D00 -nvCodeLimit 4000
            Command --> 80E602001805D1D2D3D4D508A000000018434D000006EF04C6020FB00000
            Wrapped command --> 84E60200287F5A23CD3D94C9535230D1B1A8F593DB25DB45BDEE96F23FD6
            887BBB0C6F3AC52AFD46D58AD411FB00
            Response <-- 009000
            Command --> 80E80000EFC482012B01000FDECAFFED010202000105D1D2D3D4D502001F000F001F
            0000000B001600120027000A00090009006900000000000001000004000B01000107A00000006201
            0106001200800300FF00040400000019FFFF0015001C070027000110188C0000188B00017A01308F
            00028C00037A0110047800107A022018198C00047A00207A08000A000000000000000000000A0009
            01000000020001000C05001600050680030003800301010000000600000106000024090009000000
            05050406030F0B00690100010000000000000600810001000C0009000000000109000C0012000700
            00000006010015001500
            Wrapped command --> 84E80000F864B3562C2CBDBC6ED52D5F8FC77440275023E2C5ED6E78F69A
            B59FF27F6D4248E6E2544490EEF12F984F9B147A9745F6D2EB3E9D630BD866AB2656AF34296A28D6
            B288470F23801C688186D65C20EEC742CBD3855FED66D5B16D3BAC617599C2A6EFE5EA12D529A204
            BA7EFD7BDDFC65FDE575CD0932890C626D5067ECAACC5037FE6ABC7D025BCED8CE3F2AF72738CC53
            0860B7BDAB2F9A7CAF642AB301D2F5FEBE2BF4B7A5E0ABBE0F6D0511744C96E1FEE5F8AED41FF231
            B5E05F1E8DC4426F35976917D046ABAE4523C1CB210FEC78BCAFD64B9FC6B1717919B31A0D7FE10C
            EDB4DB7A5233C270324375ECD86096317C90567AC40261
            Response <-- 009000
            Command --> 80E8800140020000000004010019000C0001000000000701001C000E000600000000
            FF020024000E0001000000000005000C000CFFFF000C000E0110066800A104B431012000
            Wrapped command --> 84E88001501D9E52731C969363CE60851847352C08FEEE87AE43DFF6A9E4
            FB8F6FACD5238A8C0B1A5AB2AC89EC7BEA35D6714134E29DB08CD0CE7832F9589C01B231516B12F8
            0F538AE4E03D99DEEA9E69A5C1EF9200
            Response <-- 009000
            Command --> 80E60C000E05D1D2D3D4D50000010002C9000000
            Wrapped command --> 84E60C00186C7CCD2C269CCCAAD6018CA7A3CC2A0E52CCAC8DD2BDD4F100

            Response <-- 6A80
            install_for_install_and_make_selectable() returns 0x80206A80 (6A80: Wrong data /
            Incorrect values in command data.)
            • 3. Re: GPShell - installing file .cap error 6985
              safarmer
              You are probably missing a required install parameter. It is hard to say without seeing the applet code though.

              - Shane
              • 4. Re: GPShell - installing file .cap error 6985
                995187
                I have a "hello world" applet to test installation in my card, this is the code:

                package app;

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

                public class Pre extends Applet {

                     private byte[] echoBytes;
                private static final short LENGTH_ECHO_BYTES = 256;

                     public Pre() {
                          echoBytes = new byte[LENGTH_ECHO_BYTES];
                register();
                     }

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

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

                          short bytesRead = apdu.setIncomingAndReceive();
                          short echoOffset = (short)0;

                          while ( bytesRead > 0 ) {
                Util.arrayCopyNonAtomic(buffer, ISO7816.OFFSET_CDATA, echoBytes, echoOffset, bytesRead);
                echoOffset += bytesRead;
                bytesRead = apdu.receiveBytes(ISO7816.OFFSET_CDATA);
                }

                apdu.setOutgoing();
                apdu.setOutgoingLength( (short) (echoOffset + 5) );

                // echo header
                // apdu.sendBytes( (short)0, (short) 5);
                // echo data
                apdu.sendBytesLong( echoBytes, (short) 0, echoOffset );
                     }
                }
                • 5. Re: GPShell - installing file .cap error 6985
                  995187
                  I've tried installing the sample helloworld.cap that brings GPshell-1.4.4 and are installed correctly, but applets created by me throws the error 6A80.

                  I do not know the composition of that example code, as was compiled and generated the file .cap
                  • 6. Re: GPShell - installing file .cap error 6985
                    fgrieu
                    Quoting:
                    public void process(APDU apdu) throws ISOException {
                      byte buffer[] = apdu.getBuffer();
                    
                      short bytesRead = apdu.setIncomingAndReceive();
                      short echoOffset = (short)0;
                    
                      while ( bytesRead > 0 ) {
                        Util.arrayCopyNonAtomic(buffer, ISO7816.OFFSET_CDATA, echoBytes, echoOffset, bytesRead);
                        echoOffset += bytesRead;
                        bytesRead = apdu.receiveBytes(ISO7816.OFFSET_CDATA);
                      }
                    
                      apdu.setOutgoing();
                      apdu.setOutgoingLength( (short) (echoOffset + 5) );
                    
                      // echo header
                      // apdu.sendBytes( (short)0, (short) 5);
                      // echo data
                      apdu.sendBytesLong( echoBytes, (short) 0, echoOffset );
                      }
                    }
                    Unless I err badly,<tt> arrayCopyNonAtomic </tt>is first called on data that was not already read by<tt> apdu.receiveBytes</tt>, and thus depending on implementation may or may not be already in the buffer. Then the data is read using<tt> apdu.receiveBytes </tt>, which typically will return the same value as first returned by<tt> apdu.setIncomingAndReceive </tt>, and data gets written a second time in<tt> echoBytes </tt>, which ends up containing twice as much data as Nc (the number coded by Lc), or cause an exception when Nc>128.

                    Also,<tt> apdu.sendBytesLong </tt>is called without a previous<tt> apdu.sendBytes </tt>, and the length passed to<tt> apdu.sendBytesLong </tt>is 5 less than announced by<tt> apdu.setOutgoingLength </tt>; that alone could explain the card is mute.