SmInc
SmInc

Reputation: 235

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...");
...
}

Upvotes: 2

Views: 510

Answers (3)

ouamso
ouamso

Reputation: 31

No, it cannot.

You do not have access to the command dispatcher.

Upvotes: 2

hsg
hsg

Reputation: 656

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

Upvotes: 2

guidot
guidot

Reputation: 5333

I assume, that you are not intending to communicate with the target Applet via serial interface, but look for "execute the same functionality as you would do on receiving this APDU".

I have some doubts, whether such an interface exists and don't see the use case for these reasons:

  • In a javacard environment the applets are autonomous building blocks.
  • If you intend to call within the same Applet, there should be far more convenient possibilities.
  • If a different applet is targeted: the implied switch towards and backwards simply does not fit the APDU concept of one currently selected applet.

Upvotes: 1

Related Questions