Ihdina
Ihdina

Reputation: 1730

Call different applet in javacard

I have 2 applets in java card. 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.

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. How to do it? Thanks.

Upvotes: 0

Views: 458

Answers (1)

Sergei Danielian
Sergei Danielian

Reputation: 5015

Ihdina.
Since the JC platform has pretty sophisticated features aimed at ramping up the platform security (i.e. Firewall Protection, Context Switching), you have a limited number of capabilities to do what you want.

enter image description here

Note: one should designate the ability to invoke an API from another applet as the ability to exchange data between applets. The former is possible with the usage of the Shareable interface. The latter is more complicated.

1st Option: 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. The feature that allows doing that is called Extended CAP file format. An applet instance can freely access objects belonging to another applet instance that resides in any package in the same Java Card CAP File. Note: this is only possible starting from JC 3.1.

2nd Option: Array View
A very nice feature available in JC 3.1 as well. Array Views are views to existing arrays which show potentially read-only array slices.

3rd Option: GlobalArray
The only way to implement inter-applet communication on older platforms (like mine, which is of 3.0.4 version). 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.

Basically, there are many more features to consider, including RE Privileges, RE Entry Point Objects, etc. But what was given above should be enough.

P.S. 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.

Upvotes: 1

Related Questions