As mentioned in JavaCard 2.2 APIs documents here, selectingApplet()
is a method that is used by the applet process()
method to distinguish the SELECT APDU command which selected this applet, from all other SELECT APDU commands which may relate to file or internal applet state selection and it returns true if this applet is being selected.
My question is that Why we need this method? and even more general : Why the selected applet need to receive SELECT-applet commands? I think the only entity that need to know SELECT-applet APDUs is JCRE.
I suggest the below scenario :
- JCRE receive the APDU command from the CAD
- Check it to see if it is a SELECT APDU command or not.
- If it is not a SELECT APDU command, It sends the received APDU to the
process()
method of selected Applet. and the selected applet interpret and execute it (using switches and if expressions and no need to useselectingApplet()
method) - if it is a SELECT APDU command, check the length of the Data Field of the command to see if it is a SELECT File or it is a SELECT Applet.
- if it is SELECT File command, JCRE send it to the
process()
method of selected applet again. but if it is a SELECT Applet coomand, JCRE invokedeselet()
method of currently selected applet and then invokeselect()
method of the new requested applet. and after receivingTrue
, make it selected and wait for next APDU command.(and even no need to send the previousSELECT-Applet
APDU command toprocess()
method of this new selected applet)
What is wrong with the above implementation? and what is the advantages of current implementation in JC 2.2 (that sends all the receive APDUs to the process()
method of currently selected applet and the selectingApplet()
distinguish different SELECT commands)
I think the current implementation providing a vulnerability! if a programmer implement his/her applet in a way that its process()
method writes all of received APDUs in EEPROM, the he/she can retrieve AID of some other installed applets on the card. is this right?