smartcardjavacardjcop

Can an APDU command be executed *inside* the Java Card Applet?


We know that Applet.process() method is calling "between" APDU request and its APDU response, i.e. it can read some incomiung APDU and send some outgoing as a response.

But, can Applet send its own APDU command and get the response? I.e.:

public void process(APDU apdu)
{
...
APDU resp = SomeAPI.someMethod("00A40101FF...");
...
}

Solution

  • But, can Applet send its own APDU command and get the response?

    The plain answer is NO, you cannot send an APDU for another applet since you does not have access to the command dispatcher. But there is a way to do it, read below.

    public void process(APDU apdu)
    {
    ...
    APDU resp = SomeAPI.someMethod("00A40101FF...");
    ...
    }
    

    Anything like this is not possible in java card applet (till latest version 3.0.5u) because here you are storing a reference of APDU object, which a Temporary JCRE Entry Point Objects and its reference cannot be stored.

    Now, to achieve the functionality you want. Use a shareable interface object. Obviously, you need to modify the target applet (which you want to call) here. Calling an applet via shareable object will do the context switching for you and you can return to your applet after it.

    Refer http://www.oracle.com/technetwork/java/javacard/specs-jsp-136430.html