简体   繁体   English

在javacard中调用不同的applet

[英]Call different applet in javacard

I have 2 applets in java card.我在 java 卡中有 2 个小程序。 The first applet functions as a loyalty card. 第一个小程序用作会员卡。 The second applet functions to store transactions. 第二个小程序用于存储交易。

I want to log the add balances/credit transaction and purchase transactions to eeprom using the second applet.我想使用第二个小程序将add balances/credit transactionpurchase transactions记录到eeprom

file_name: month
-----------------------------------
datetime | transaction code | amount
-----------------------------------

month:
01 = january
02 = february
ect..

datetime (7 bytes): 
dd MM yyyy HH mm ss  

transaction code (1 byte):
01 = purchase
02 = add balance

amount (4 bytes):
FF FF FF FF

---------------------------------------
example:
---------------------------------------

1. transaction add balance 100 in 01-02-2022 03:04:05 (dd-MM-yyyy HH:mm:ss)

file_name: 01
------------------------------------------------
datetime           | transaction code | amount
------------------------------------------------
01 02 07D2 030405        02            00000064

CLA = 80
INS = E0
P1  = 00
P2  = 00
LC  = 0C
DATA = 01 02 07 D2 03 04 05 02 00 00 00 64

I want send apdu 80 E0 00 00 0C 01 02 07 D2 03 04 05 02 00 00 00 64 to second applet from first applet .我想将 apdu 80 E0 00 00 0C 01 02 07 D2 03 04 05 02 00 00 00 64first applet发送到second applet程序。 How to do it?怎么做? Thanks.谢谢。

Ihdina .伊赫迪娜
Since the JC platform has pretty sophisticated features aimed at ramping up the platform security (ie Firewall Protection, Context Switching), you have a limited number of capabilities to do what you want.由于 JC 平台具有旨在提高平台安全性的相当复杂的功能(即防火墙保护、上下文切换),因此您可以做自己想做的事情的能力有限。

在此处输入图像描述

Note : one should designate the ability to invoke an API from another applet as the ability to exchange data between applets.注意:应将从另一个小程序调用 API 的能力指定为在小程序之间交换数据的能力。 The former is possible with the usage of the Shareable interface.前者可以通过使用Shareable接口实现。 The latter is more complicated.后者更复杂。

1st Option : one CAP file with two applets第一个选项one CAP file with two applets
To exchange data, you can put two applets into a single CAP file, thus avoiding the problem of working around the fences JC platform mounts.要交换数据,您可以将两个小程序放入一个 CAP 文件中,从而避免绕过 JC 平台安装的栅栏问题。 The feature that allows doing that is called Extended CAP file format .允许这样做的功能称为扩展 CAP 文件格式 An applet instance can freely access objects belonging to another applet instance that resides in any package in the same Java Card CAP File.一个小程序实例可以自由访问属于另一个小程序实例的对象,该小程序实例位于同一 Java 卡 CAP 文件中的任何 package 中。 Note: this is only possible starting from JC 3.1 .注意:这只能从JC 3.1开始。

2nd Option : Array View第二个选项Array View
A very nice feature available in JC 3.1 as well. JC 3.1中也提供了一个非常好的功能。 Array Views are views to existing arrays which show potentially read-only array slices. 数组视图是现有 arrays 的视图,它显示潜在的只读数组切片。

3rd Option : GlobalArray第三个选项GlobalArray
The only way to implement inter-applet communication on older platforms (like mine, which is of 3.0.4 version).在旧平台上实现小程序间通信的唯一方法(比如我的,是3.0.4版本)。 You create easily create an array and make it Global by using JCSystem.makeGlobalArray API. That's how APDU object is declared on the JC platform initially.您可以使用JCSystem.makeGlobalArray API 轻松创建一个数组并使其成为全局数组。这就是最初在 JC 平台上声明 APDU object 的方式。

Basically, there are many more features to consider, including RE Privileges, RE Entry Point Objects, etc. But what was given above should be enough.基本上,还有更多的特性需要考虑,包括 RE Privileges、RE Entry Point Objects 等。但是上面给出的应该足够了。

PS I use to post misc information in regards to the JavaCard platforms on my Twitter account , specifically, have more information about the Inter-Applet communication .附注:我曾经在我的 Twitter 帐户上发布关于 JavaCard 平台的杂项信息,特别是关于Inter-Applet 通信的更多信息。

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

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