Page 4 of 4

Re: Video Tutorial - How to download CAP file to smart card?

Posted: Thu May 25, 2017 12:21 pm
by schisskiss
Hi i have the problem that i cant upload my Applet to the Smartcard (NXP J3A081) and the Card is Empty but when i try Download i get the message:"6A 80"

The Code is:

Code: Select all

package pwSafe;

import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import javacard.framework.APDU;
import javacard.framework.JCSystem;
import javacard.framework.Util;
import javacard.framework.OwnerPIN;
import javacard.security.RandomData;

public class pwSafe extends Applet
{

   final static byte CLA_NUMBER = (byte) 0x80;
   
   final static byte INS_INIT       = (byte) 0x10;
   final static byte INS_CHANGE_PIN = (byte) 0x11;
   final static byte INS_PIN_VERIFY = (byte) 0x12;
   
   final static byte INS_CREATE_FILE   = (byte) 0xE0;
    final static byte INS_UPDATE_BINARY = (byte) 0xD6;
    final static byte INS_READ_BINARY   = (byte) 0xB0;
    final static byte INS_DELETE_FILE   = (byte) 0xE4;
       
    //Variables for the PIN
    private final static byte PIN_MAX_TRIES  = (byte) 3;
    private final static byte PIN_MIN_LENGTH = (byte) 4;
    private final static byte PIN_MAX_LENGTH = (byte) 16;
    //Variables for the PUK
    private final static byte PUK_MAX_TRIES = (byte) 5;
    private final static byte PUK_LENGTH    = (byte) 12;
   
    private static final byte STATE_INIT           = (byte) 0x00;
    private static final byte STATE_SECURE_NO_DATA = (byte) 0x01;
    private static final byte STATE_SECURE_DATA    = (byte) 0x05;
   
    // Status words:
    public static final short SW_PIN_TRIES_REMAINING = (short)0x63C0;
    public static final short SW_COMMAND_NOT_ALLOWED_GENERAL = (short)0x6900;
   
    private byte state;
    private OwnerPIN pin = null;
    private OwnerPIN puk = null;
   private RandomData randomKey;
   
   private fileSystem fileClass;
   
      public static void install(byte[] buffer, short offset, byte length) {
        new pwSafe();
    } 
   
   protected pwSafe() {
      
      pin = new OwnerPIN(PIN_MAX_TRIES, PIN_MAX_LENGTH);
        puk = new OwnerPIN(PUK_MAX_TRIES, PUK_LENGTH);
      
      fileClass = new fileSystem();
      
      //Set state and write to file
        state = STATE_INIT;
       
        randomKey = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);
       
        register();
   }

   public boolean select() { 
        return true;
    }
   
    public void deselect() {
        pin.reset();
        puk.reset();
    }

   public void process(APDU apdu) {
      byte buffer[] = apdu.getBuffer();
      byte cla = buffer[ISO7816.OFFSET_CLA];
        byte ins = buffer[ISO7816.OFFSET_INS];
       
        if(cla == CLA_NUMBER) {
           
           switch (ins)
           {
              //Personal Data
              //INS = 0x10
            case INS_INIT:
               cardINIT(apdu);
               break;
            //INS = 0x11   
            case INS_CHANGE_PIN:
               changePIN(apdu);
               break;
            //INS = 0x12
            case INS_PIN_VERIFY:
               checkPIN(apdu);
               break;
               
            //Storage Data
            //INS = 0xE0
            case INS_CREATE_FILE:
               createFile(apdu);
               break;
            //INS = 0xD6
            case INS_UPDATE_BINARY:
               break;
            //INS = 0xB0
            case INS_READ_BINARY:
               break;
            //INS = 0xE4
            case INS_DELETE_FILE:
               break;
            default:
               ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
           }
          
        } else {
           
            ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
        }
      
   }
   
   //CLA = 0x80; INS = 0x10; P1 = 0x00; P2 = 0x01
   private void cardINIT(APDU apdu) throws ISOException {
      byte[] buf = apdu.getBuffer();
      byte p1 = buf[ISO7816.OFFSET_P1];
        byte p2 = buf[ISO7816.OFFSET_P2];
        short offset_cdata;
        short lc;
       
        //Check lenght field
        lc = apdu.setIncomingAndReceive();
        if(lc != apdu.getIncomingLength()) {
            ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
        }
        //Get the Offset of the Data
        offset_cdata = apdu.getOffsetCdata();
        //Check if the State is correct
        if(state != STATE_INIT) {
           ISOException.throwIt(ISO7816.SW_COMMAND_NOT_ALLOWED);
        }
       
        if(p1 != (byte)0x00 && p2 != (byte)0x01) {
           ISOException.throwIt(ISO7816.SW_INCORRECT_P1P2);
        }
       
        if(lc > PIN_MAX_LENGTH || lc < PIN_MIN_LENGTH) {
           ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
        }
       
        Util.arrayFillNonAtomic(buf, (short)(offset_cdata + lc), (short)(PIN_MAX_LENGTH - lc), (byte) 0x00);
        pin.update(buf, offset_cdata, PIN_MAX_LENGTH);
        pin.resetAndUnblock();
       
        generatePUKKey(apdu); 
   }
   
   //Verify PIN
   //CLA = 0x80; INS = 0x12; P1 = 0x01; P2 = 0x00; Data = PIN
   private void checkPIN(APDU apdu) throws ISOException {
      byte[] buf = apdu.getBuffer();
      byte p1 = buf[ISO7816.OFFSET_P1];
        byte p2 = buf[ISO7816.OFFSET_P2];
        short offset_cdata;
        short lc;
       
        //Check lenght field
        lc = apdu.setIncomingAndReceive();
        if(lc != apdu.getIncomingLength()) {
            ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
        }
        //Get the Offset of the Data
        offset_cdata = apdu.getOffsetCdata();
        //Check if the State is correct
        if(state == STATE_SECURE_NO_DATA || state == STATE_SECURE_DATA) {
           ISOException.throwIt(ISO7816.SW_COMMAND_NOT_ALLOWED);
        }
       
        if(p1 != (byte)0x01 && p2 != (byte)0x00) {
           ISOException.throwIt(ISO7816.SW_INCORRECT_P1P2);
        }
       
        Util.arrayFillNonAtomic(buf, (short)(offset_cdata + lc), (short)(PIN_MAX_LENGTH - lc), (byte) 0x00);
       
        if(! pin.check(buf, offset_cdata, PIN_MAX_LENGTH)) {
           ISOException.throwIt((short)(SW_PIN_TRIES_REMAINING | pin.getTriesRemaining()));
        }
       
   }

   //Change PIN
   //CLA = 0x80; INS = 0x11; P1 = 0x00; P2 = 0x02;Data = PUK + PIN
   private void changePIN(APDU apdu) throws ISOException {
      byte[] buf = apdu.getBuffer();
      byte p1 = buf[ISO7816.OFFSET_P1];
        byte p2 = buf[ISO7816.OFFSET_P2];
        short offset_cdata;
        short lc;
       
        if(! pin.isValidated()){
           ISOException.throwIt(ISO7816.SW_SECURITY_STATUS_NOT_SATISFIED);
        }
       
        //Check lenght field
        lc = apdu.setIncomingAndReceive();
        if(lc != apdu.getIncomingLength()) {
            ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
        }
        //Get the Offset of the Data
        offset_cdata = apdu.getOffsetCdata();
        //Check if the State is correct
        if(state == STATE_SECURE_NO_DATA || state == STATE_SECURE_DATA) {
           ISOException.throwIt(ISO7816.SW_COMMAND_NOT_ALLOWED);
        }
       
        if(p1 != (byte)0x00 && p2 != (byte)0x02) {
           ISOException.throwIt(ISO7816.SW_INCORRECT_P1P2);
        }
       
        if(! puk.check(buf, offset_cdata, PUK_LENGTH)) {
           ISOException.throwIt((short)(SW_PIN_TRIES_REMAINING | puk.getTriesRemaining()));
        }
       
        if( (lc - (offset_cdata + PUK_LENGTH)) < PIN_MIN_LENGTH || (lc - (offset_cdata + PUK_LENGTH) > PIN_MAX_LENGTH)) {
         ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
      }
       
        Util.arrayFillNonAtomic(buf, (short)(offset_cdata + lc), (short)(PIN_MAX_LENGTH - (lc - PUK_LENGTH)), (byte) 0x00);
       
        pin.update(buf, (short)(offset_cdata + PUK_LENGTH), PIN_MAX_LENGTH);
       
   }

   private void generatePUKKey(APDU apdu) throws ISOException {
      byte[] buf = apdu.getBuffer();
      
      randomKey.generateData(buf, (short) 0, PUK_LENGTH);
   
      puk.update(buf, (short)0, PUK_LENGTH);
      puk.resetAndUnblock();
      
      apdu.setOutgoingLength(PUK_LENGTH);
        apdu.sendBytes((short)0, PUK_LENGTH);
   }

   private void createFile(APDU apdu) {
      byte[] buf = apdu.getBuffer();
      byte p1 = buf[ISO7816.OFFSET_P1];
        byte p2 = buf[ISO7816.OFFSET_P2];
        short offset_cdata;
        short fileID = (short)0x0000;
        byte[] fileSize = null;
       
        offset_cdata = apdu.getOffsetCdata();
        Util.arrayCopy(buf, offset_cdata, fileSize, (short)0, (short)2 );
       
        if(p1 == (byte)0x01) {
           fileID = (short)0x0100;
        } else if(p1 == (byte)0x02){
           fileID = (short)0x0101;
        }
       
        fileClass.createFile(fileID, Util.makeShort(fileSize[(byte)0], fileSize[(byte)1]));
   }
}



and the other class is:

Code: Select all

package pwSafe;

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

public class fileSystem {
   
   private Object[] listFiles;
    private short[]  listfileSizes;
   
    public static final short keepassData1 = (short)0x0100;
    public static final short keepassData2 = (short)0x0101;
    private static final short keepassData_Index1 = (short)0x0001;
    private static final short keepassData_Index2 = (short)0x0002;
   
   
   public fileSystem() {
      listFiles = new Object[(short)2];
        listfileSizes = new short[(short)2];
   }
   
   public void createFile(short fileID, short fileSize) {
      short index = getFileIndex(fileID);
      
      if(listFiles[index] == null) {
         listFiles[index] = new byte[fileSize];
      }
      
      listfileSizes[index] = fileSize;
   }
   
   public void writeDataToFile(short fileID, short fileOffset, byte[] fileData, short dataLength) {
      
      short selFileSize = getFileSize(fileID);

        if (selFileSize < (fileOffset + dataLength)) {
           ISOException.throwIt(ISO7816.SW_FILE_FULL);
        }
           
        Util.arrayCopy(fileData, (short)0, getFile(fileID), fileOffset, dataLength);
   }
   
   public byte[] readDataFromFile(short fileID, short fileOffset, short length) {
      
      short selFileSize = getFileSize(fileID);
      byte[] data = null;
      
      if((fileOffset + length) > selFileSize) {
         Util.arrayCopy(getFile(fileID), fileOffset, data, (short)0, (short)(selFileSize - fileOffset));
      } else {
         Util.arrayCopy(getFile(fileID), fileOffset, data, (short)0, length);
      }
      
      return (byte[])data;
   }
   
   private short getFileIndex(short fileID) {
      if(fileID == keepassData1) {
         return keepassData_Index1;
         
      } else if (fileID == keepassData2) {
         return keepassData_Index2;
         
      } else {
         return (short)-1;
      }
   }
   
   private byte[] getFile(short fileID) {
      short index = getFileIndex(fileID);
      
      if(index == -1) {
         return null;
      }
      
      return (byte[]) listFiles[index];
   }
   
   private short getFileSize(short fileID) {
      short index = getFileIndex(fileID);
      
      if(index == (short)-1) {
         return (short)-1;
      }
      
      return listfileSizes[index];
   }
}


when i build the Code there is no error only one warning: warning: This package requires int support. But nothing else.

Re: Video Tutorial - How to download CAP file to smart card?

Posted: Fri May 26, 2017 10:39 pm
by UNKNwYSHSA
As i know, the J3A081 is an implementation of JC2.2.2.
Are you generating the CAP with JC version 2.2.x?
I guess you are using JC version 3.x.x now.

Re: Video Tutorial - How to download CAP file to smart card?

Posted: Sat May 27, 2017 9:20 am
by schisskiss
Hi, thanks for your reply. i found the error. The Warning "warning: This package requires int support." was the fault. I could compile it but i dosen´t work on the Card. I wrote before every Addition a (short) and now it works. thx for help

Re: Video Tutorial - How to download CAP file to smart card?

Posted: Sun May 28, 2017 5:35 am
by UNKNwYSHSA
schisskiss wrote:Hi, thanks for your reply. i found the error. The Warning "warning: This package requires int support." was the fault. I could compile it but i dosen´t work on the Card. I wrote before every Addition a (short) and now it works. thx for help


ok.

Re: Video Tutorial - How to download CAP file to smart card?

Posted: Tue Nov 21, 2017 1:13 am
by fophys
Please I'm having the same error, how did you later resolve it.


<<00 A4 04 00 08 A0 00 00 00 03 00 00 00 00
>>6F 5C 84 08 A0 00 00 00 03 00 00 00 A5 50 73 4A 06 07 2A 86 48 86 FC 6B 01 60 0C 06 0A 2A 86 48 86 FC 6B 02 02 01 01 63 09 06 07 2A 86 48 86 FC 6B 03 64 0B 06 09 2A 86 48 86 FC 6B 04 02 15 65 0B 06 09 2B 85 10 86 48 64 02 01 03 66 0C 06 0A 2B 06 01 04 01 2A 02 6E 01 02 9F 65 01 FF 90 00

<<80 50 00 00 08 6D 34 99 52 43 32 18 7C 1C
>>00 00 00 00 00 00 00 00 00 00 FF 02 00 10 68 6C E3 CA 2C 2B B7 A5 CE 64 4E 7C A6 D1 90 00

<<84 82 00 00 10 3B 6F 17 83 2E C2 BC 0E AC 3C CB BF A2 23 CA 5D
>>90 00

<<80 E6 02 00 16 09 A0 00 00 18 50 00 52 41 50 08 A0 00 00 00 03 00 00 00 00 00 00 01
>>69 85




//Test Applet


Download Cap error: Download cap file failed. Send: 80 E8 00 00 FA C4 82 01 35 01 00 1A DE CA FF ED 02 02 04 00 01 05 11 22 33 44 55 0A 74 65 73 74 41 70 70 6C 65 74 02 00 21 00 1A 00 21 00 0A 00 15 00 2A 00 0E 00 6F 00 0A 00 0F 00 00 00 5B 02 1D 00 00 00 00 00 00 02 01 00 04 00 15 02 03 01 07 A0 00 00 00 62 01 01 00 01 07 A0 00 00 00 62 00 01 03 00 0A 01 06 11 22 33 44 55 66 00 08 06 00 0E 00 00 00 80 03 00 FF 00 07 01 00 00 00 1C 07 00 6F 00 01 10 18 8C 00 00 7A 05 30 8F 00 01 3D 8C 00 02 18 1D 04 41 18 1D 25 8B 00 03 7A 03 24 18 8B 00 04 60 03 7A 19 8B 00 05 2D 19 8B 00 06 3B 03 32 1A 04 25 75 00 34 00 02 00 01 00 0D 00 02 00 2C 1A 05 25 29 04 1A 06 25 29 05 16 04 16 05 41 32 1A 03 1F 8D 00 07 3B 19 03 05 8B 00 08 70 10 19 03 08 8B 00 08 70 08 11 6D 00 8D 00 09 7A 08 00 0A 00 00 00 00 00 00 00 00 00 00 01, Recv: 69 85.




//Successful cap




<<00 A4 04 00 08 A0 00 00 00 03 00 00 00 00
>>6F 5C 84 08 A0 00 00 00 03 00 00 00 A5 50 73 4A 06 07 2A 86 48 86 FC 6B 01 60 0C 06 0A 2A 86 48 86 FC 6B 02 02 01 01 63 09 06 07 2A 86 48 86 FC 6B 03 64 0B 06 09 2A 86 48 86 FC 6B 04 02 15 65 0B 06 09 2B 85 10 86 48 64 02 01 03 66 0C 06 0A 2B 06 01 04 01 2A 02 6E 01 02 9F 65 01 FF 90 00

<<80 50 00 00 08 31 6F D4 75 3B 09 60 B5 1C
>>00 00 00 00 00 00 00 00 00 00 FF 02 00 0E 2A 73 D2 AF 62 FF 3C 10 BE 55 9B 96 99 6F 90 00

<<84 82 00 00 10 14 9D A5 FD 67 B7 26 75 10 10 20 33 0C 1E E2 87
>>90 00

<<80 E6 02 00 16 09 A0 00 00 18 50 00 52 41 50 08 A0 00 00 00 03 00 00 00 00 00 00 01
>>00 90 00

<<80 E8 00 00 FA C4 82 07 3E 01 00 13 DE CA FF ED 01 02 04 00 01 09 A0 00 00 18 50 00 52 41 50 02 00 1F 00 13 00 1F 00 0E 00 15 00 A6 00 12 05 6A 00 0A 00 A2 00 00 01 CF 00 00 00 00 00 00 02 01 00 04 00 15 02 00 01 07 A0 00 00 00 62 01 01 00 01 07 A0 00 00 00 62 00 01 03 00 0E 01 0A A0 00 00 18 50 00 52 41 50 02 00 AE 06 00 12 00 80 03 0C 00 08 04 04 00 00 00 05 FF FF 00 01 04 EE 07 05 6A 00 01 10 04 78 00 10 7A 05 10 18 8C 00 0E 18 10 10 90 0B 87 00 18 10 20 90 0B 87 01 18 10 09 90 0B 87 02 18 11 00 C8 89 03 18 10 78 89 04 18 03 89 05 18 AF 03 AF 04 45 90 0B 87 06 18 07 90 0B 3D 03 10 31 38 3D 04 10 32 38 3D 05 10 33 38 3D 06 10 34 38 87 07 18 10 09 90 0B 3D 03 10 39 38 3D 04 10 39 38 3D 05 10 39 38 3D 06 10 39 38 3D 07 10 39 38 3D 08 10 39 38 3D 10 06 10 01
>>00 90 00

<<80 E8 00 01 FA 39 38 3D 10 07 10 39 38 3D 10 08 10 39 38 87 08 18 10 06 90 0B 87 09 18 03 88 0A 18 8F 00 0C 3D 06 07 8C 00 0D 87 0B AD 0B AD 07 03 07 8B 00 0F 7A 02 31 8F 00 10 3D 8C 00 11 2E 1B 8B 00 12 7A 04 31 03 32 19 8B 00 13 3B AD 0B 8B 00 14 60 5B AD 0B 1A 08 07 8B 00 15 60 0A 19 03 03 8B 00 16 70 5F AD 0B 8B 00 14 32 1F 73 00 3E 00 00 00 02 00 33 00 22 00 0D 1A 03 10 99 38 1A 04 05 38 1A 05 05 38 19 03 06 8B 00 16 70 36 1A 03 10 99 38 1A 04 04 38 19 03 05 8B 00 16 70 25 1A 03 10 99 38 19 03 04 8B 00 16 70 18 1A 03 02 38 1A 04 02 38 1A 05 02 38 1A 06 02 38 19 03 07 8B 00 16 7A 04 30 19 8B 00 13 3B AD 0B 8B 00 17 60 0C AD 0B 1A 08 07 8B 00 0F 70 29 AD 0B 8B 00 14 60 14 1A 03 10 99 38 1A 04 10 99 38 19 03 05 8B 00 16 70 10 1A 03 02 38 1A 04 02 38 19 01
>>00 90 00

<<80 E8 00 02 FA 03 05 8B 00 16 7A 05 30 19 8B 00 13 3B AD 0B 8B 00 18 1A 07 25 60 36 1A 07 25 10 09 6B 2F 1A 08 AD 08 03 10 09 8D 00 19 61 12 AD 0B 8B 00 18 AD 0B AD 07 03 07 8B 00 0F 70 22 1A 03 10 99 38 1A 04 05 38 19 03 05 8B 00 16 70 11 1A 03 10 66 38 1A 04 05 38 19 03 05 8B 00 16 7A 05 30 19 8B 00 13 3B 1A 07 25 10 10 6B 0F 1A 08 AD 00 03 10 10 8D 00 1A 3B 70 11 1A 03 10 66 38 1A 04 05 38 19 03 05 8B 00 16 7A 05 30 19 8B 00 13 3B 1A 07 25 10 20 6B 0F 1A 08 AD 01 03 10 20 8D 00 1A 3B 70 11 1A 03 10 66 38 1A 04 05 38 19 03 05 8B 00 16 7A 05 30 19 8B 00 13 3B 1A 07 25 10 0A 6B 33 AF 05 AF 03 6D 1D 1A 08 AD 06 03 10 0A 8D 00 1A 3B 18 3D 85 05 04 41 89 05 19 03 03 8B 00 16 70 21 1A 03 02 38 1A 04 02 38 19 03 05 8B 00 16 70 11 1A 03 10 66 38 1A 04 05 38 19 01
>>00 90 00

<<80 E8 00 03 FA 03 05 8B 00 16 7A 05 30 19 8B 00 13 3B AD 00 03 1A 03 10 08 8D 00 1A 3B 19 03 10 08 8B 00 16 7A 05 30 19 8B 00 13 3B AD 01 03 1A 03 10 20 8D 00 1A 3B 19 03 10 20 8B 00 16 7A 05 31 19 8B 00 13 3B 1A 06 25 32 1F AF 03 6E 19 AD 06 1F AF 04 45 1A 03 AF 04 8D 00 1A 3B 19 03 AF 04 8B 00 16 70 10 1A 03 02 38 1A 04 02 38 19 03 05 8B 00 16 7A 03 30 19 8B 00 13 3B 1A 03 03 38 1A 04 AF 05 5B 38 19 03 05 8B 00 16 7A 02 30 19 8B 00 13 3B 1A 06 25 73 00 11 00 00 00 01 00 0B 00 11 18 03 89 05 70 02 7A 05 31 1A 05 25 73 00 88 00 00 00 06 00 15 00 1D 00 25 00 2D 00 61 00 69 00 7D 18 19 1A 8C 00 1B 70 6D 18 19 1A 8C 00 1C 70 65 18 19 1A 8C 00 1D 70 5D 1A 06 25 11 00 FF 53 32 1F AF 03 6E 19 AD 06 1F AF 04 45 1A 03 AF 04 8D 00 1A 3B 19 03 AF 04 8B 00 16 70 39 01
>>00 90 00

<<80 E8 00 04 FA 1A 03 02 38 1A 04 02 38 19 03 05 8B 00 16 70 29 18 19 1A 8C 00 1E 70 21 AD 09 03 1A 03 10 06 8D 00 1A 3B 19 03 10 06 8B 00 16 70 0D 1A 03 AE 0A 38 19 03 04 8B 00 16 7A 05 30 19 8B 00 13 3B 1A 07 25 10 09 6B 0F 1A 08 AD 02 03 10 09 8D 00 1A 3B 70 11 1A 03 10 66 38 1A 04 05 38 19 03 05 8B 00 16 7A 05 30 19 8B 00 13 3B 1A 05 25 73 01 00 00 00 00 04 00 11 00 38 00 5F 00 B2 00 DD 1A 07 25 10 10 6B 10 1A 08 AD 00 03 10 10 8D 00 1A 3B A8 00 DD 1A 03 10 66 38 1A 04 05 38 19 03 05 8B 00 16 A8 00 CB 1A 07 25 10 20 6B 10 1A 08 AD 01 03 10 20 8D 00 1A 3B A8 00 B6 1A 03 10 66 38 1A 04 05 38 19 03 05 8B 00 16 A8 00 A4 1A 07 25 10 FA 6B 3D AF 05 AF 03 6D 27 1A 08 AD 06 AF 04 AF 05 45 AF 04 8D 00 1A 3B 18 3D 85 05 04 41 89 05 1A 03 AF 05 5B 38 19 03 04 8B 01
>>00 90 00

<<80 E8 00 05 FA 00 16 70 71 1A 03 02 38 1A 04 02 38 19 03 05 8B 00 16 70 61 1A 03 10 66 38 1A 04 05 38 19 03 05 8B 00 16 70 50 1A 07 25 10 06 6B 15 1A 08 AD 09 03 10 06 8D 00 1A 3B 19 03 03 8B 00 16 70 36 1A 03 10 66 38 1A 04 05 38 19 03 05 8B 00 16 70 25 1A 07 25 04 6B 10 18 1A 08 25 88 0A 19 03 03 8B 00 16 70 11 1A 03 10 66 38 1A 04 05 38 19 03 05 8B 00 16 7A 05 30 AD 02 03 1A 03 10 09 8D 00 1A 3B 19 03 10 09 8B 00 16 7A 03 21 19 8B 00 1F 2D 18 8B 00 20 60 03 7A 1A 03 25 60 08 11 6E 00 8D 00 21 1A 04 25 75 00 59 00 07 00 20 00 21 00 21 00 49 00 22 00 51 00 30 00 29 00 41 00 39 00 42 00 41 00 50 00 31 18 19 1A 8C 00 22 70 38 18 19 1A 8C 00 23 70 30 18 19 1A 8C 00 24 70 28 18 19 1A 8C 00 25 70 20 18 19 1A 8C 00 26 70 18 18 19 1A 8C 00 27 70 10 18 19 1A 8C 01
>>00 90 00

<<80 E8 00 06 FA 00 28 70 08 11 6D 00 8D 00 21 7A 08 00 0A 00 00 00 00 00 00 00 00 00 00 05 00 A6 00 29 02 00 00 00 02 00 00 01 02 00 00 02 02 00 00 08 02 00 00 09 02 00 00 0A 02 00 00 03 02 00 00 05 02 00 00 06 02 00 00 07 02 00 00 0B 02 00 00 04 01 80 09 00 06 80 09 00 06 80 03 00 03 80 09 08 01 00 00 00 06 00 00 08 03 80 03 01 03 80 0A 06 03 80 09 02 03 80 09 01 03 80 0A 08 03 80 09 04 03 80 09 06 06 80 10 00 06 80 10 01 06 00 02 77 06 00 02 91 06 00 02 E1 06 00 02 F9 03 80 0A 01 03 80 03 03 06 80 07 01 06 00 00 BD 06 00 03 A3 06 00 04 D9 06 00 03 CE 06 00 03 15 06 00 01 3D 06 00 01 7D 09 00 A2 00 41 14 07 07 06 05 04 03 02 05 1A 37 07 04 0C 02 02 20 07 12 65 07 0A 2F 13 0A 05 02 3A 2B 29 02 06 0B 04 31 1A 1F 04 03 05 08 23 22 40 04 03 05 08 1F 16 1A 3F 01
>>00 90 00

<<80 E8 80 07 6C 27 25 02 06 02 02 03 08 04 04 36 2C 1C 00 5D 0C 8E 06 0B 06 04 05 09 06 0A 08 07 22 11 0D 18 07 06 0A 07 12 10 07 06 16 07 09 11 11 07 12 12 07 12 12 07 18 0F 10 11 07 0B 08 07 0B 08 07 17 08 10 07 11 07 36 08 08 1C 08 10 08 0C 08 0D 07 12 12 07 26 13 14 13 1E 15 10 11 13 07 11 14 11 0D 08 07 05 0E 2A 08 08 08 08 08 08 08 01
>>00 90 00

<<80 50 00 00 08 A3 55 60 63 12 9E D1 A9 1C
>>00 00 00 00 00 00 00 00 00 00 FF 02 00 0F 70 68 CB 6D 6D 93 FC 58 A3 0A 6A F4 99 6B 90 00

<<84 82 00 00 10 F6 57 25 25 C2 B7 91 EE B1 05 A1 C7 6D EB EF 79
>>90 00

<<80 E6 0C 00 26 09 A0 00 00 18 50 00 52 41 50 0A A0 00 00 18 50 00 52 41 50 02 0A A0 00 00 18 50 00 52 41 50 02 01 00 02 C9 00 00 00
>>00 90 00

Re: Video Tutorial - How to download CAP file to smart card?

Posted: Sun Dec 02, 2018 6:22 am
by sdellava
Hallo.

I'm having trouble in download an basic applet to my cards.

I'm using a ACS ARC122 0, the ATR is 3B 8E 80 01 80 31 80 66 43 53 14 2B 00 00 83 00 90 00 64

I've been told the card is a V3.0.6 so I'm using the java_card_kit-3.0.4 to buld the cap file.

When I click in download I receive this output:
<<00 A4 04 00 00
>>6F 67 84 08 A0 00 00 00 03 00 00 00 A5 5B 73 4C 06 07 2A 86 48 86 FC 6B 01 60 0C 06 0A 2A 86 48 86 FC 6B 02 02 02 01 63 09 06 07 2A 86 48 86 FC 6B 03 64 0B 06 09 2A 86 48 86 FC 6B 04 02 55 65 0D 06 0B 2A 86 48 86 FC 6B 05 07 02 00 00 66 0C 06 0A 2B 06 01 04 01 2A 02 6E 01 03 9F 6E 06 19 81 73 22 01 00 9F 65 01 FF 90 00

<<80 50 00 00 08 5E 9B A4 0B 48 39 F5 F5 1C
>>00 00 83 05 00 00 01 8B FF FF 01 02 00 36 92 E0 A8 AC 9E C8 58 16 82 6F 68 D6 F5 90 90 00

<<84 82 00 00 10 C1 D5 9D 23 B1 35 6B ED 0F 2C 3B 51 37 49 DA BA
>>90 00

<<80 E6 02 00 0A 05 11 22 33 44 55 00 00 00 00 01
>>00 90 00

<<80 E8 00 00 FA C4 82 01 35 01 00 1A DE CA FF ED 02 02 04 00 01 05 11 22 33 44 55 0A 74 65 73 74 41 70 70 6C 65 74 02 00 21 00 1A 00 21 00 0A 00 15 00 2A 00 0E 00 6F 00 0A 00 0F 00 00 00 5B 02 1D 00 00 00 00 00 00 02 01 00 04 00 15 02 05 01 07 A0 00 00 00 62 01 01 00 01 07 A0 00 00 00 62 00 01 03 00 0A 01 06 11 22 33 44 55 66 00 08 06 00 0E 00 00 00 80 03 00 FF 00 07 01 00 00 00 1C 07 00 6F 00 01 10 18 8C 00 00 7A 05 30 8F 00 01 3D 8C 00 02 18 1D 04 41 18 1D 25 8B 00 03 7A 03 24 18 8B 00 04 60 03 7A 19 8B 00 05 2D 19 8B 00 06 3B 03 32 1A 04 25 75 00 34 00 02 00 01 00 0D 00 02 00 2C 1A 05 25 29 04 1A 06 25 29 05 16 04 16 05 41 32 1A 03 1F 8D 00 07 3B 19 03 05 8B 00 08 70 10 19 03 08 8B 00 08 70 08 11 6D 00 8D 00 09 7A 08 00 0A 00 00 00 00 00 00 00 00 00 00 01
>>00 00

the 00 00 response confuse me! and the reader start beeping. It seems leave the card in a anomalous status: removing the card and placing it again on the reader let start the reader to beep again. Only after may try to reconnect the beep ends and I can start again to interact with the card.


Any Idea on what is going on? Thansk Stefano

Re: Video Tutorial - How to download CAP file to smart card?

Posted: Sun Jan 27, 2019 6:11 pm
by owlstead
I'm missing an Le byte set to 00 for that last command LOAD command (80 E8). It seems to be required by the Global Platform specifications. Maybe a bug?