1

I am trying to load an applet which utilizes the javacardx.framework.math.BigNumber class. When I attempt to load the generated cap file onto the card, I encounter the following result:

Applet loading failed. Are you sure the CAP file (JC version, packages) is compatible with your card?
pro.javacard.gp.GPException: LOAD failed SW: 6985
    at pro.javacard.gp.GPException.check(GPException.java:66)
    at pro.javacard.gp.GlobalPlatform.loadCapFile(GlobalPlatform.java:598)
    at pro.javacard.gp.GlobalPlatform.loadCapFile(GlobalPlatform.java:556)
    at pro.javacard.gp.GPTool.main(GPTool.java:503)

If I remove the references to the BigNumber API, the applet can be loaded onto the card. The reference is a simple call to the BigNumber constructor. BigNumber counter = new BigNumber((short) 4);

I am using JCDK 2.2.2. My card information is as follows:

***** CARD DATA
GlobalPlatform card
Version: 2.1.1
TAG3: 1.2.840.114283.3
SCP version: SCP_01_05
TAG5: 1.3.656.840.100.2.1.3
TAG6: 1.3.6.1.4.1.42.2.110.1.2

I have java 7 install locally and I build my javacard applet using the following line: javac -g -d classes -source 1.5 -target 1.5 -classpath $JC_HOME/lib/api_16.jar src/applet/*.java. I am using the GlobalPlatformPro to install my cap files.

Has anyone experienced this before?

cmanning
  • 225
  • 3
  • 11
  • Where did you call the constructor in your code? – Maarten Bodewes Apr 14 '16 at 20:49
  • @MaartenBodewes, in a static function which is sometimes executed while processing an APDUs. – cmanning Apr 14 '16 at 21:15
  • Hmm, that's not it then. Note that the convertor and version of your Java Card implementation should be identical. Otherwise changes in the API might trigger this result; the linking is performed by the convertor, the Java Card implementation doesn't perform class or method lookup by name (no dynamic binding, in other words). – Maarten Bodewes Apr 14 '16 at 22:52
  • @MaartenBodewes Thanks for your advice. Are you suggesting I use 1.3 as my source and target to match the converter which is distributed with JCDK2.2.2? I have attempted this as well and experienced the same result. – cmanning Apr 14 '16 at 23:31
  • No the Java Card SDK and Java Card version needs to match precisely. In the worst case the Java Card implementation isn't completely correct, although that should have resulted in an incompatible Java Card during testing. But lets not go there yet. Of course, as I cannot see the code, I can only guess. – Maarten Bodewes Apr 14 '16 at 23:34
  • 3
    Maybe the card doesn't implemented the BigNumber library? – Ebrahim Ghasemi Apr 15 '16 at 05:26
  • @Abraham That's a very big probability. But regardless the API itself *should* be present, and therefore the bindings should be there. OK, should have mentioned directly that even if it loads, the BigNum functionality wouldn't work. I'll talk to the representative at work if it should fail at load or runtime. – Maarten Bodewes Apr 15 '16 at 07:58
  • I think as well that the optional BigNumber package is not implemented on the card. However, I usually get a WRONGDATA 0x6A80(JCOP cards), but this return code might be vendor specific and not specified – Paul Bastian Apr 15 '16 at 09:51
  • @Abraham is there a way I can determine if the library is implemented or not on my card? – cmanning Apr 15 '16 at 12:17
  • you can read the documentation provided by your card vendor – Paul Bastian Apr 15 '16 at 12:20
  • Thanks @PaulBastian. I assumed Gemalto's IDCore 30 would support every API in Java Card 2.2.2 given this [document](http://gemapprpx.gemalto.com:81/products/top_javacard/download/IDCore30_Product_Datasheet_June13.pdf). I will go read more product documentation. – cmanning Apr 15 '16 at 13:26
  • 2
    Even the smart card flagship products don't support every package – Paul Bastian Apr 15 '16 at 13:58
  • I am still reading up on the documentation. I haven't found anything conclusive, but I have not given up. I have played around with my card and applet some more and have discovered I unable to use any class in a package with an extended name, like `javacard.framework.service` or `javacardx.framework.util`. Packages with longer names come with longer AIDs according to [this question](http://stackoverflow.com/questions/25031338/how-to-get-javacard-version-on-card). I am not sure if this matters, I just wanted to raise this as an observation. – cmanning Apr 15 '16 at 14:42

0 Answers0