Javacard - power loss during garbage collection

2019-01-23 09:13发布

问题:

I noticed some very strange behaviour on my smartcards (NXP J2E145, J3A081, J3C145 with an Omnikey 5121 reader): A power loss right after calling JavaCard method

JCSystem.requestObjectDeletion()

can damage the card: after about 10% of such power cuts the ATR command is very slow (1000ms) and I get no response to any other APDUs (applet selection, card manager authentication etc.).

I know that the behavior of requestObjectDeletion() depends on the vendor specific implementation, so my question is quite wide and open...

Is garbage collecting processed "usually" in a single transaction?

Is there any "official" recommendation NOT to call requestObjectDeletion() in case of a possible power loss?

Do you have any similar experience with cards by NXP?

EDIT:

  • JCSystem.isObjectDeletionSupported() == true on all my smartcards.
  • When trying to connect to the card manager applet of a damaged card, the JCOP shell in Eclipse IDE reports this:

    ATR: 3BFB9600008131FE454F4450204D41502053414D3E

    ATR: T = 1
    jcshell: Unknown problems with terminal. Last terminal error: The request could not be performed because of an I/O device error.

回答1:

Well I think it might be an implementation bug. In general, garbage collection is usually never needed and never used on smartcards. You should avoided it under any circumstances by good applet design. Because that way you never run into memory problems, which are bad for a smartcard thats installed once in its lifetime and shall be useable for the rest of its lifecycle. Garbage Collection just takes too long anyway and maybe thatswhy the card system programmer didn't expect it to happen outside a safe environment.