appletsmartcardjavacardglobalplatform

How can I make a javacard appet which is not possible to be multi instance


I want to create a javacard applet which could not be installed more than once at the same time. It means if I instantiate applet once, It could not be possible to install another instance of that applet. However, if I delete the first instance, it should be possible to reinstall it.


Solution

  • If the package AID is always the same the installations should fail during the loading process automatically.

    If the package and instance AIDs are using some pattern like an increasing last digit you could use JCSystem.lookupAID and try to iterate over the possible AIDs and fail if another instance is found.

    If you are taking into account that the AIDs are flexible you are out of luck on standard smart cards, what you need then is a global kind of data unique for all applets. When using an UICC e.g you could create a file in the file system and if your applet is part of the MNO's security domain you can check this file for existence.

    Maybe you also protect the installation process, e.g. by using a personalization process. After the installation a personalization server has to approve the applet. The applet could use some random token and if this is not known by the personalization server the applet will never unlock some features to make it useful. This approach should always work.