JAVACARD2.2中的selectingApplet()方法的功能是什么 [英] What is the functionality of selectingApplet() method in JAVACARD2.2

查看:214
本文介绍了JAVACARD2.2中的selectingApplet()方法的功能是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如JavaCard 2.2 API文档所述此处selectingApplet()是applet process()方法用来将选择了此applet的 SELECT APDU命令与所有其他 SELECT 区别开来的方法可能与文件或内部小程序状态选择有关的APDU命令,如果选择了该小程序,它将返回true.

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.

我的问题是我们为什么需要这种方法?,甚至更笼统:为什么选定的applet需要接收SELECT-applet命令?我认为唯一的实体需要知道 SELECT -applet APDU是 JCRE .

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.

我建议以下情况:

  1. JCRE CAD
  2. 接收APDU命令
  3. 检查它是否是SELECT APDU命令.
  4. 如果不是 SELECT APDU命令,它将接收到的APDU发送到所选Applet的process()方法.并且所选的applet解释并执行它(使用开关以及if表达式,而无需使用selectingApplet()方法)
  5. 如果它是 SELECT APDU命令,请检查命令的数据字段的长度,以查看它是 SELECT文件还是选择小程序.
  6. 如果它是 SELECT File 命令,则 JCRE 会将其再次发送到所选applet的process()方法.但是如果它是 SELECT Applet 库,则 JCRE 调用当前所选applet的deselet()方法,然后调用新请求的applet的select()方法.并在接收到True之后,将其选中并等待下一个APDU命令.(甚至无需将先前的SELECT-Applet APDU命令发送到此新选择的applet的process()方法中)
  1. JCRE receive the APDU command from the CAD
  2. Check it to see if it is a SELECT APDU command or not.
  3. 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 use selectingApplet() method)
  4. 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.
  5. 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 invoke deselet() method of currently selected applet and then invoke select() method of the new requested applet. and after receiving True, make it selected and wait for next APDU command.(and even no need to send the previous SELECT-Applet APDU command to process() method of this new selected applet)

上述实现有什么问题?以及JC 2.2中当前实现的优点(将所有接收的APDU发送到当前所选applet的process()方法和selectingApplet()区分不同的 SELECT 命令)

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)

我认为当前的实现方式存在漏洞!如果程序员以其process()方法将所有接收到的 APDU 写入 EEPROM 的方式实现他/她的applet,则他/她可以检索其他已安装程序的AID卡上的小程序.这是正确的吗?

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?

推荐答案

您可以使用SELECT来区分ATR(全局平台选项)之后的默认选择和SELECT之下的常规选择.换句话说,区分是在MF还是在应用程序DF中.在两种情况下都将调用方法select().

You can use SELECT to distinguish between default selection after an ATR (a Global Platform option) and normal selection though SELECT. In other words, distinguish between being in the MF or application DF. The method select() will be called in both cases.

此外,P104不同的SELECT可能会将(FCI/FCP)数据返回到终端.运行时不知道返回什么,因为这是特定于应用程序的.

Furthermore, SELECT where P1 is different from 04 may return (FCI/FCP) data to the terminal. The runtime would not know what to return, as that is application specific.

selectingApplet()非常有用,因为您可以立即看到使用此方法实际上选择了(重新)Applet.如果重新选择了该applet,则可能要进行一些内部整理,但是您当然不希望返回指示错误的状态字.错误将表明APDU发生故障,这与运行时选择了applet的事实不一致.

selectingApplet() is very useful as you can immediately see that the Applet actually got (re-)selected with this method. If the applet gets reselected you may want to do some internal housekeeping, but you certainly don't want to return a status word indicating an error. An error would indicate that the APDU failed and this is inconsistent with the fact that the applet was selected by the runtime.

这篇关于JAVACARD2.2中的selectingApplet()方法的功能是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆