0

I am trying to install an applet on a JavaCard using GlobalPlatformPro, however keep getting the error code 6985 - conditions of use not satisfied. I have done some research and found that this could mean the card is locked?

Installing an applet is the first thing I tried to do when I got this error so I haven't (at least purposefully) locked it myself.

When listing all the applets on the card my applet is there, but listed as 'LOADED' and not 'SELECTABLE' which I believe it should be.

Is there a way I can inlock the card? Or is this another issue?

LozCodes
  • 109
  • 8

1 Answers1

4

Your card is not locked. If the card is locked you cannot list the applets anymore. The mutual authentication would also fail, only "selection of the application with the Final Application privilege." according to GP 2.3.1 is possible.

If the applet could get loaded but not installed, i.e. the loading succeeded and the package is on the card but the instantiation failed, this means usually that an exception was thrown in the constructor or the install method. Debug your code by removing code until the installation works to find the erroneous code line. It could also be that an applet with the same instance AID is already on the card.

k_o_
  • 5,143
  • 1
  • 34
  • 43
  • Thank you for getting back to me! I have manged to get the same applet installed and running on a different type of javacard so I don't think there is an error in the code in the install method. I have tried creating another test applet with a different AID to any already on the card and still get the same error. – LozCodes Mar 24 '22 at 14:20
  • @LozCodes Please still try to debug the applet, the error seems to be card specific. Use a very easy applet, e.g. an Hello World applet Binary: https://github.com/sigma/globalplatform/blob/master/gpshell/helloworld.cap Code: https://github.com/sigma/globalplatform/tree/master/helloworldapplet Does this get installed? – k_o_ Mar 24 '22 at 18:47
  • @LozCodes Maybe you are using an API or an API version which is not supported by the card. Are you using ETSI related APIs for menus and proactive commands? Some cards also do not like static or final classifiers for some variables or maybe you are allocating an array and the card does not have enough memory left. – k_o_ Mar 24 '22 at 18:50
  • I get the same error when trying to install that hello world applet. The install method in my applet is exactly the same as the hello world applet. When running global platform pro -debug this is the first command that gets and error: A>> T=1 (4+0010) 84F24002 0A 4F00388842F7FE5439BC 00 A<< (0000+2) (65ms) 6A88 I don't have any static or final variables - how can I tell which API version I am using? – LozCodes Mar 25 '22 at 14:09
  • @LozCodes But the hello world applet package is installed, only not instantiated? Can you add some logic to the constructor or `install` method, e.g. `ISOException.throwIt(0x6f00)`? Is this exception then thrown? If even this is not reached then try to modify the installation parameters: data space limit, non volatile code space limit, volatile code space limit = code size, all used persistent memory, RAM usage. At least try to set the data space limit to some higher value, e.g. 5000 which is much more than the applet size and give non volatile code space limit the size 1000. – k_o_ Mar 25 '22 at 20:04
  • I manged to find a stray static variable that I hadn't realised I was using, and managed to get it installed. I still couldn't get the HelloWorld applet installed, but think that might be to do with it having the same AID as anther applet. Thank you very much fro your help. Is there any specific reason some cards don't like static or final variables, or is that best asked in another question? – LozCodes Mar 29 '22 at 15:35
  • @LozCodes Aksing this question why a static variable is causing problems needs to be addressed to the card vendor. It is a bug in the JavaCard runtime. I also had this in the past, usually with older cards. I don't know if there is a certification test before a Java Card can be called Java Card, maybe this is also a self certification otherwise I would not expect this issue to be existing in productive cards. – k_o_ Mar 29 '22 at 19:43
  • I will contact the vendor and ask - thank you for your help! – LozCodes Mar 31 '22 at 11:37