Usually, when you power up a JavaCard smartcard and want to communicate with an applet, you must select the applet using its AID first.
Is there any way to have a "default applet" that is selected when the card is powered up?
What I really want to do is be able to send my application level APDUs immediately upon selecting the card and not need to go through the application selection process.
Is this possible? If so, how?
If your Java Card smartcard implements the Global Platform Card specification, it will typically allow you to define an applet that is implicitly selected on the basic logical channel upon reset. Thus, upon powering up (resetting) the card the applet would be selected by default and immediately receives all commands (except those handled by the runtime environment, such as selection of other applets, logical channel management, etc.).
You can set an applet as the default selected applet by giving it the "Default Selected" (GP 2.1.1 terminology) or "Card Reset" (GP 2.2 terminology) privilege. This is set by bit 3 in the (first) privilege byte. Only one application can have this privilege.
If you use, for instance, GlobalPlatformPro, you could use the options --default
(during installation) or --make-default <AID>
(for an existing applet) to set this privilege.
Note that you can distinguish between being default selected and selected by AID by capturing the SELECT APDU within the Applet#process
method. The best way is to call Applet.selectingApplet
to check if explicit selection by AID has taken place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With