'How to modify an ATR of a JavaCard j2a040

I am trying to change the ATR of a Java Smartcard (JCOP) J2A040. I researched through the manuals and cannot find a definite answer. There are programs like PyResMan that successfully change it, however, I cannot figure out a way to change it through python.

I am researching smartcard integration and need to understand how one can go about changing the ATR. I know that is has something to do with APDU, however, I cannot figure it out.

If anyone has any answers, please let me know.



Solution 1:[1]

It is possible to change it from an Applet itself or possibly from the vendor initialization process of the chip. The Global Platform specifications allow you to set it through a static call to GPSystem within the GP on-card API:

public static boolean setATRHistBytes (byte[] buffer, short bOffset, byte bLength)

This method sets the historical bytes contained in the ATR (Answer To Reset). The sequence of bytes will be set on a subsequent power-up or reset. Only the “default selected” Application may invoke this method. The Card Manager locates the AID of the selected Application in the GlobalPlatform Registry and determines if the Application has the required privilege.

As you can see this only changes the historical bytes which are part of the ATR. The other settings are chip-specific and can therefore normally only be set during initialization of the (Java Card) operating system implementation.

For JCOP that can be by writing specific byte values to persistent memory (separate locations for cold and warm reset if that's still the same). Please contact your representative to get the necessary documentation and authentication material.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Maarten Bodewes