9 Nov 2010

Uncaught exception and Status Word (SW) 6F00

Okay, you have developed applet and trying to load to smart card (hereafter I'll call it SIM Card as it is one of particular usage of Smart Card). But on last INSTALL AND MAKE SELECTABLE APDU you've received 6F00 Status Word (SW). 6F00 SW is not documented by any standard and generally means something wrong with the card. But based on my own experience most of the time it isn't card issue.

So what could be reason of 6F00?

Answer is very simple. Uncaught exception in your constructor or in install() method.

Below an example:

import sim.toolkit.*;
import javacard.framework.*;

public class DummyApplet extends javacard.framework.Applet implements
        ToolkitInterface, ToolkitConstants {
    private static byte[] RAM_Buffer; 

     * Constructor of the applet
    public DummyApplet() {
        register(bArray, (short) (bOffset + 1), (byte) bArray[bOffset]);


     * Method called by the JCRE at the installation of the applet
     * @param bArray the byte array containing the AID bytes
     * @param bOffset the start of AID bytes in bArray
     * @param bLength the length of the AID bytes in bArray
    public static void install(byte[] bArray, short bOffset, byte bLength) {
        // Create the Java SIM toolkit applet
        DummyApplet dummyApplet = new DummyApplet();
        // Register this applet
        dummyApplet.register(bArray, (short) (bOffset + 1),
                (byte) bArray[bOffset]);

        short offsetCI = (short) (bOffset + bArray[bOffset] + 1);
        short paramIdx = (short) (offsetCI + bArray[offsetCI] + 1);
        short bufLength = Util.getShort(bArray, paramIdx);         

        RAM_Buffer = JCSystem.makeTransientByteArray(bufLength, JCSystem.CLEAR_ON_RESET);

Of course this is really dummy applet but it shows typical JavaCard developers mistake. You have to remember that transient memory (RAM) is very limited on SIM Card and your applet is not alone. Some other applets could already took some part of memory. And probability of getting SystemException.NO_TRANSIENT_SPACE on the line:

RAM_Buffer = JCSystem.makeTransientByteArray(bufLength, JCSystem.CLEAR_ON_RESET);

is very high.

Conclusion: You have to try/catch exceptions in constructor and install() method. If you are allocating some memory buffers check available memory before.


Sajith Vijesekara said...

hi thanks your post.i want to know how to get free available Memory in java card.

Nodir Gulyamov said...

Starting from JavaCard 2.2 you have getAvailableMemory method in JCSystem. You can use it to get available memory.

Sky said...

Hi Nodir,

Thanks for your article that helps me to understand more about my APDU errors (Unknown APDU 2PAY.SYS.DDF01) ended up with APDU 6F00. I've done Amex and Visa certification testing. Now I am on China Union Pay.

I get this APDU error most of the time while running CUP tests. the tests run without the errors intermittently only. It's as if it matters which USB port I used. But, it's unclear what the real cause for this error. I also suspect that maybe missing A000000333010101 & A000000333010102 in developer's firmware code maybe causing this? Currently, our developer said we only need "A0000003330101".

But the exact same Proxicard works perfectly when the reader is loaded with MasterCard or Amex configurations that include their own AID's each respectively.

I'd be grateful if you could advise me how to debug next.

Thanks very much.

ProxiCARD is ready to dialog with a
proximity passport reader...

(Press any key to stop ProxiCARD)

[Unknown APDU]

PCD: 00 A4 04 00 0E 32 50 41 59 2E 53 59 53 2E 44 44
46 30 31 00 (20 bytes)

PICC: 6F 00 (2 bytes)

[Unknown APDU]
PCD: 00 A4 04 00 07 A0 00 00 00 04 10 10 00 (13 bytes)
PICC: 6F 00 (2 bytes)

[Unknown APDU]
PCD: 00 A4 04 00 07 A0 00 00 00 04 30 60 00 (13 bytes)
PICC: 6F 00 (2 bytes)


Sky said...

Hi Nodir,

Thank you so much for your article that is very helpful to me.

I've posted my question just a while ago, it went without posting it. I hope that you have receive my inquiry.

I've found this site mentioning about 6F00 APDU response code.


6F 00 Command aborted - more exact diagnosis not possible (e.g., operating system error).

Nodir Gulyamov said...

hi Sky,
I've got notifications about your comments only yesterday.

It is hard to say without knowing your setup, I can give you only some clues.
When applet selected execution passed to its process method. If something wrong happens during "processing of select" in process() method applet can throw exception.
It is also worth to try to select CardManager before selecting any applet.

Hope it will help.