Question

How to get java card version from card? Is there any way how to get version of JC from the card. Or should I try to install applets with specific for each JC version options.

Was it helpful?

Solution

The only full-proof way to determine JavaCard API versions supported by a "white" smart card is to build a separate CAP file for each JavaCard version.

I suggest you make each CAP contain just a single simple class extending javacard.framework.Applet. You may want to be able to actually install your simple applet and actually exchange APDUs with it just to make sure it actually works; as far as I know Java Card virtual machine implementations are allowed to upload CAP files even if not all imports are resolved, but should fail if you try to actually use the APIs.

Once a CAP file is generated you can verify it actually links to the intended JavaCard API package by parsing the COMPONENT_Import component in your generated CAP file. The CAP file format is described in the JavaCard Virtual Machine Specification and the field you want is the package_info for your imported JavaCard package.

I've comprised a list of AID - package_version_major.package_version_minor (package_name) information. The list may be incomplete.

Java Card 2.1.1: A0000000620201 - 1.1 (javacardx.crypto)

Java Card 2.1.1: A0000000620101 - 1.0 (javacard.framework)

Java Card 2.1.1: A0000000620001 - 1.0 (java.lang)

Java Card 2.1.1: A0000000620102 - 1.1 (javacard.security)

Java Card 2.2.1: A0000000620201 - 1.2 (javacardx.crypto)

Java Card 2.2.1: A0000000620101 - 1.2 (javacard.framework)

Java Card 2.2.1: A0000000620002 - 1.0 (java.io)

Java Card 2.2.1: A0000000620001 - 1.0 (java.lang)

Java Card 2.2.1: A0000000620003 - 1.0 (java.rmi)

Java Card 2.2.1: A0000000620102 - 1.2 (javacard.security)

Java Card 2.2.1: A000000062010101 - 1.0 (javacard.framework.service)

Java Card 2.2.2: A0000000620209 - 1.0 (javacardx.apdu)

Java Card 2.2.2: A0000000620202 - 1.2 (javacardx.biometry)

Java Card 2.2.2: A0000000620201 - 1.3 (javacardx.crypto)

Java Card 2.2.2: A0000000620203 - 1.0 (javacardx.external)

Java Card 2.2.2: A0000000620101 - 1.3 (javacard.framework)

Java Card 2.2.2: A0000000620002 - 1.0 (java.io)

Java Card 2.2.2: A0000000620001 - 1.0 (java.lang)

Java Card 2.2.2: A000000062020802 - 1.0 (javacardx.framework.math)

Java Card 2.2.2: A0000000620003 - 1.0 (java.rmi)

Java Card 2.2.2: A0000000620102 - 1.3 (javacard.security)

Java Card 2.2.2: A000000062010101 - 1.0 (javacard.framework.service)

Java Card 2.2.2: A000000062020803 - 1.0 (javacardx.framework.tlv)

Java Card 2.2.2: A000000062020801 - 1.0 (javacardx.framework.util)

Java Card 3.0.1: A0000000620209 - 1.0 (javacardx.apdu)

Java Card 3.0.1: A0000000620202 - 1.2 (javacardx.biometry)

Java Card 3.0.1: A0000000620201 - 1.4 (javacardx.crypto)

Java Card 3.0.1: A0000000620203 - 1.0 (javacardx.external)

Java Card 3.0.1: A0000000620101 - 1.4 (javacard.framework)

Java Card 3.0.1: A00000006202080101 - 1.0 (javacardx.framework.util.intx)

Java Card 3.0.1: A0000000620002 - 1.0 (java.io)

Java Card 3.0.1: A0000000620001 - 1.0 (java.lang)

Java Card 3.0.1: A000000062020802 - 1.0 (javacardx.framework.math)

Java Card 3.0.1: A0000000620003 - 1.0 (java.rmi)

Java Card 3.0.1: A0000000620102 - 1.4 (javacard.security)

Java Card 3.0.1: A000000062010101 - 1.0 (javacard.framework.service)

Java Card 3.0.1: A000000062020803 - 1.0 (javacardx.framework.tlv)

Java Card 3.0.1: A000000062020801 - 1.0 (javacardx.framework.util)

Java Card 3.0.4: A0000000620209 - 1.0 (javacardx.apdu)

Java Card 3.0.4: A0000000620202 - 1.2 (javacardx.biometry)

Java Card 3.0.4: A0000000620201 - 1.4 (javacardx.crypto)

Java Card 3.0.4: A0000000620203 - 1.0 (javacardx.external)

Java Card 3.0.4: A0000000620101 - 1.5 (javacard.framework)

Java Card 3.0.4: A00000006202080101 - 1.0 (javacardx.framework.util.intx)

Java Card 3.0.4: A0000000620002 - 1.0 (java.io)

Java Card 3.0.4: A0000000620001 - 1.0 (java.lang)

Java Card 3.0.4: A000000062020802 - 1.0 (javacardx.framework.math)

Java Card 3.0.4: A0000000620003 - 1.0 (java.rmi)

Java Card 3.0.4: A0000000620102 - 1.5 (javacard.security)

Java Card 3.0.4: A000000062010101 - 1.0 (javacard.framework.service)

Java Card 3.0.4: A000000062020804 - 1.0 (javacardx.framework.string)

Java Card 3.0.4: A000000062020803 - 1.0 (javacardx.framework.tlv)

Java Card 3.0.4: A000000062020801 - 1.0 (javacardx.framework.util)

Considering above information allow me to point out that the answer from Michael Roland is slightly misleading. Calling JCSystem.getVersion() does not help to determine whether a Java Card version is supported; if you got to the point where you can actually call the API then you are already sure the version is supported.

OTHER TIPS

I'll be bold and advice some way around the issue. If you can load applets you normally also have access to the Global Platform card manager. The card manager should support a command APDU called GET CPLC (DATA). This returns the Card Production Life Cycle data, which includes identifiers for the chip manufacturer (there is a limited number of those), OS manufacturer and version information.

Armed with this information, you should be able to ask the creator of the OS for more information, such as which version is exactly supported, Global Platform support, additional libraries etc. Of course it depends a bit on who and where you are if they actually deem you worthy of support.

A small issue is that Visa seems to maintain the mapping of the identifiers to actual companies. I haven't found a definite list on the internet just yet, but the more common ones seem to be known.

short version = JCSystem.getVersion();

The method getVersion() returns the major and minor version of the Java Card API (each part in one byte). There is no method to distinguish between sub-versions (e.g. between 2.2.1 and 2.2.2).

Only knowing that your chip contains a Java Card runtime environment, there is no means to query more specific information from the chip. (Some chips might expose more specific information though.) In general you should obtain such information from the manufacturer/your supplier.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top