Our Online Store have the new products: RFID antenna board. Currently it can work with JC10M24R and JCOP4 card chips.
Compared with normal cards, the antenna board module has a smaller size and fixed holes, which is easy to integrate in the IOT(Internet Of Things) project.

Failed to SELECT tha applet

Algorithm School

Moderator: UNKNwYSHSA

User avatar
Marshaldll
Posts: 13
Joined: Thu Jun 11, 2015 2:53 am
Points :32
Contact:

Failed to SELECT tha applet

Post by Marshaldll » Wed Oct 14, 2015 6:12 am

Here is the DES encryption code which i found from the web.

Code: Select all

package DES_Encry;

import javacard.framework.*;
import javacard.security.*;
import javacardx.crypto.*;

public class DES extends Applet
{
     DESKey deskey;
     Cipher cipherCBC;
     final short dataOffset = (short) ISO7816.OFFSET_CDATA;
     static byte[] TrippleDESKey = {(byte) 0x38, (byte) 0x12, (byte) 0xA4,
          (byte) 0x19, (byte) 0xC6, (byte) 0x3B, (byte) 0xE7, (byte) 0x71, (byte) 0x00, (byte) 0x12, (byte) 0x00,
          (byte) 0x19, (byte) 0x80, (byte) 0x3B, (byte) 0xE7, (byte) 0x71, (byte) 0x01, (byte) 0x12, (byte) 0x01,
          (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0xE7, (byte) 0x71};

     // constructor,
     // initialization
     
     private DES(byte bArray[], short bOffset, byte bLength)
     {
          try {
             deskey = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES, KeyBuilder.LENGTH_DES3_3KEY, false);
             cipherCBC = Cipher.getInstance(Cipher.ALG_DES_CBC_NOPAD, false);
          }
          catch (CryptoException e) {
             ISOException.throwIt((short) ((short) 0x9000 + e.getReason()));
          }

          if (bArray[bOffset] == 0)
          {
               register();
          }
          else
          {
               register(bArray, (short)(bOffset+1), bArray[bOffset]);
          }
     }
     
     
   public static void install(byte[] bArray, short bOffset, byte bLength)
   {
      new DES(bArray, bOffset, bLength);
      //new DES().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
   }

   public void process(APDU apdu)
   {
      if (selectingApplet())
      {
         return;
      }

      byte[] buf = apdu.getBuffer();
      doTrippeDES(apdu);
   }
   
    private void doTrippeDES(APDU apdu)
     {
          byte a[] = apdu.getBuffer();

          short incomingLength = (short) (apdu.setIncomingAndReceive());
          if (incomingLength != 24) ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);

          deskey.setKey(TrippleDESKey, (short)0);
          cipherCBC.init(deskey, Cipher.MODE_ENCRYPT,new byte[]{0,0,0,0,0,0,0,0},(short)0,(short)8);
          cipherCBC.doFinal(a, (short) dataOffset, incomingLength, a, (short) (dataOffset + 24));
          cipherCBC.init(deskey, Cipher.MODE_DECRYPT,new byte[]{0,0,0,0,0,0,0,0},(short)0,(short)8);
          cipherCBC.doFinal(a, (short) (dataOffset + 24), incomingLength, a, (short) (dataOffset + 48));

          apdu.setOutgoing();
          apdu.setOutgoingLength((short) 72);
          apdu.sendBytesLong(a, (short) dataOffset, (short) 72);
     }

}


This applet-AID: 0x44 0x45 0x53 0x00 0x0E 0x01
SELECT command: 00 A4 04 00 06 44 45 53 00 0E 01 7F
My question is :when i send SELECT command to it, it returns "69 99" ?
What is wrong with this applet or my operation ?

rena2019
Posts: 68
Joined: Thu Aug 20, 2015 4:16 pm
Points :1790
Contact:

Re: Failed to SELECT tha applet

Post by rena2019 » Fri Oct 16, 2015 7:27 am

what was the SW of the installation of the applet? I think your applet has not succesfully installed/registered. This could be the reason why it can not be selected (SW_APPLET_SELECT_FAILED = 0x6999)

User avatar
Marshaldll
Posts: 13
Joined: Thu Jun 11, 2015 2:53 am
Points :32
Contact:

Re: Failed to SELECT tha applet

Post by Marshaldll » Fri Oct 16, 2015 10:53 pm

rena2019 wrote:what was the SW of the installation of the applet? I think your applet has not succesfully installed/registered. This could be the reason why it can not be selected (SW_APPLET_SELECT_FAILED = 0x6999)


The SW of the installation of the applet is "90 00", which means the applet has been installed successfully.
What a strange issue.
Any other ideas pls ?

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 15 guests

JavaCard OS : Disclaimer