Page 1 of 1

Applet load failed when include BETLV objects

Posted: Tue Feb 28, 2017 2:24 pm
by franco
Hi, i'm using JCIDE to create a javacard 2.2.2 applet, but when includ a BERTLV object (Constructed o primitive, BERTLV o BERTag) the load to J3A040 card fail.

A>> T=0 (4+0031) 84E60200 1F 0A4B4F57414C534B49303108A0000000030000000000008B0ACDCD29C408FD
A<< (0001+2) (110ms) 00 9000
A>> T=0 (4+0255) 84E80000 FF C482055C01001EDECAFFED02020400010A4B4F57414C534B493031096D66696C65735F3033020021001E0021000F00200106000E02B7005600B20000022408F500100008003403010004002003030107A0000000620101000108A000000062020803000107A000000062000103000F010B4B4F57414C534B49303100023306000E00000080031A00190701000002410702B70102868007028F00380541188C0026191E25290416046108188B003C700C18191E044116048B001C188C0020188C00221808058D002587001818AD018C001A87021818AD038C001A87041818AD058C001A87061818AD078C001A87081818AD097B001D058C5BA8DC96600DB358
A<< (0000+2) (968ms) 6A80
pro.javacard.gp.GPException: LOAD failed SW: 6A80
at pro.javacard.gp.GPException.check(GPException.java:66)
at pro.javacard.gp.GlobalPlatform.loadCapFile(GlobalPlatform.java:667)
at pro.javacard.gp.GlobalPlatform.loadCapFile(GlobalPlatform.java:625)
at pro.javacard.gp.GPTool.main(GPTool.java:524)

Does anyone know what is the cause and how can I fix it?

Re: Applet load failed when include BETLV objects

Posted: Tue Feb 28, 2017 10:44 pm
by UNKNwYSHSA
I write one simple applet to try. All CAP who import package javacardx.framework.tlv can't be loaded to the card. It means this package is not implemented in j2a040 card. Applet code:

Code: Select all

package testPackageTlv;

import javacard.framework.*;
import javacardx.framework.tlv.*;

public class testPackageTlv extends Applet
{

   public static void install(byte[] bArray, short bOffset, byte bLength)
   {
      new testPackageTlv().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
   }

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

      byte[] buf = apdu.getBuffer();
      switch (buf[ISO7816.OFFSET_INS])
      {
      case (byte)0x00:
         TLVException.throwIt(TLVException.INVALID_PARAM);
         break;
      default:
         ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
      }
   }

}

Re: Applet load failed when include BETLV objects

Posted: Wed Mar 01, 2017 12:36 pm
by franco
Hi UNKNwYSHSA, thanks for your reply. I try with J3D081 and MDj24 too, and both fail. Is there any model that has support for TLV objects?

Re: Applet load failed when include BETLV objects

Posted: Thu Mar 02, 2017 2:34 am
by UNKNwYSHSA
I don't know which card implement this function.
You can implement TLV construct/parse function in your applet.

Re: Applet load failed when include BETLV objects

Posted: Thu Mar 02, 2017 11:38 am
by franco
thanks for the suggestion UNKNwYSHSA, i think that could create a class for manage the static data, storing the arrays with TLV format.

Re: Applet load failed when include BETLV objects

Posted: Thu Mar 02, 2017 9:37 pm
by tay00000
Note that for Java, anything with javax or javacardx means it is an extension package of the ordinary java or javacard and is NOT MANDATORY to be implemented by the vendor who writes the JavaCard Operating System and VM firmware.

Do always be very careful when using javax or javacardx extensions as they do not 100% guarantee support across every Java or JavaCard VM implementation. It is best to write one's own libraries (i.e. TLV) whenever possible to prevent such problems from happening.