简体   繁体   English

在javacard中选择applet时,是否可以返回一些数据以及状态字9000?

[英]is it possible to return some data along with the status word 9000 on selecting an applet in javacard?

i was wondering if i could send back some data from the javacard applet when it is selected. 我想知道我是否可以在选择时从javacard applet发回一些数据。

since select() method returns a boolean value i don't know how to return data bytes from it. 因为select()方法返回一个布尔值,我不知道如何从它返回数据字节。

can anyone help me with this? 谁能帮我这个? i want the applet to return a simple byte array along with the status word 9000 (which is default for success), when i send the select command to the card. 我希望applet返回一个简单的字节数组以及状态字9000(这是成功的默认值),当我将select命令发送到卡时。

ie, when i send the following command 即,当我发送以下命令

00A4040006010203040506 00A4040006010203040506

i want a response like, 我想要一个像,

010203049000 010203049000

(first four bytes are the data returned from the applet) TIA. (前四个字节是从applet返回的数据)TIA。 thanks in advance.. 提前致谢..

I guess you do the "good practice" of "if selectingApplet() then return" in process? 我猜你做“如果选择Applet()然后返回”的“良好实践”? You need to process the incoming APDU instead of simple return. 您需要处理传入的APDU而不是简单的返回。

You can return data to select the normal way, but be careful to return 0x9000 if the select was successful. 您可以返回数据以选择正常方式,但如果选择成功,请小心返回0x9000。

Yes it is possible to return data during applet selection. 是的,可以在applet选择期间返回数据。

The select() method is normally called by the platform during applet selection. select()方法通常在applet选择期间由平台调用。 You can do some logic inside this method and return true if you want your applet to be selected or false if not. 你可以在这个方法中做一些逻辑,如果你想要你的applet被选中则返回true否则返回false After calling this method, if your applet was successfully selected, the platform will then call the APDU.process method where you can handle the Select command like any other APDU commands in your applet. 调用此方法后,如果成功选择了applet,则平台将调用APDU.process方法,您可以像applet中的任何其他APDU命令一样处理Select命令。

However, your command APDU should indicate an Le field if you want a response data. 但是,如果需要响应数据,则命令APDU应指示Le字段。 You can change your command APDU to 00 A4 04 00 06 01 02 03 04 05 06 00 to return all the response data available. 您可以将命令APDU更改为00 A4 04 00 06 01 02 03 04 05 06 00以返回所有可用的响应数据。

As for returning 9000 , just make sure to exit the APDU.process method without throwing an exception or you can throw an ISOException with 9000 value. 至于返回9000 ,只需确保退出APDU.process方法而不抛出异常,或者可以抛出具有9000值的ISOException I prefer the former. 我更喜欢前者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM