Page 1 of 1

Lock applet on card power transitions

Posted: Sun Oct 09, 2016 11:44 pm
by lefibr
Hello!

I want to make the applet be the locked state on card power transitions. I mean once the card loses power, the applet should be locked the next time it is powered. I have already looked at MultiSelectable and AppletEvent, but they all seem to trigger only when the applet is selected or deselected.

Anyone has the similar work experience before?

Re: Lock applet on card power transitions

Posted: Mon Oct 10, 2016 5:13 am
by Tarantino
As code can't be called after power is lost.

The simple method is to keep a magic in CLEAR_ON_RESET memory and always check for the presence of the magic cookie in either select() or process() and run your code if not.

Re: Lock applet on card power transitions

Posted: Mon Oct 10, 2016 5:20 am
by lefibr
If I use a magic with CLEAR_ON_RESET, won't this also be reset for an ATR?

Re: Lock applet on card power transitions

Posted: Mon Oct 10, 2016 5:52 am
by Tarantino
Yes, it would also respond to a warm reset.