LinkLossPolicy

What a read does when the link to the chip is lost: usually the document moved away from the phone. The platform read settings (Android NfcReadSettings, iOS CoreNfcReadSettings) default to Resume with 2 restarts; pass another policy there to change it.

For an ordinary app, keep Resume with 2 restarts. A slip of the document then costs a second of "hold it again", not a new start, and what the app gets is as reliable as one uninterrupted read (see Resume for why).

Whatever the policy, the read starts again only after a loss of the link itself, before the chip answered: NfcTagLost or NfcTimeout. It never starts again after the chip answered with a refusal (a wrong key, for example; see below for the one more try on the same link), after an error in the protected session, after a malformed file, or after the person, the app or the system ended the read. Each new start runs the access protocol again with the same key: the chip forgets its session keys when it loses power (ICAO Doc 9303 Part 11, section 9.8.5). The MRZ and the card access number are not blocked by tries (TR-03110 Part 1, section 2.3), so with maxRestarts 3 a read makes at most four access attempts through restarts, none of them after a refusal, as far as the read knows: the platform settings' command time limit also counts as a lost link, so a chip that answers a command after that limit has its answer dropped unread. When that late answer was a refusal of the key, the next start uses the same key again, within the restarts.

A loss before the attempt sent its first command that uses the key (BAC's EXTERNAL AUTHENTICATE, PACE's first GENERAL AUTHENTICATE) is outside every policy, End included: the chip was asked nothing about the key, so it uses no restart and starts no new attempt. The read reports ChipReadState.NoAnswerYet and tries the same document again, for a time the platform sets.

A chip that refuses the key on a later attempt ends the read with ChipReadEnding.KeyNotAccepted and nothing from earlier attempts: another document may have been placed on the phone, and the SDK cannot tell.

A refusal is not a lost link and uses no restart, under every policy. Only the first refusal of a read, before any try reached the command that uses the key, leads to one more try of the access protocol on the same link (ChipReadEnding.KeyNotAccepted gives the rule): so a read with maxRestarts 3 makes at most five authentication attempts with its key, and never more than one after a refusal.

May gain members in a later release: an exhaustive when over it then stops compiling until the new member is handled. An else branch keeps it compiling without handling the new member: that is your choice, and today the compiler warns that such an else is redundant.

Experimental: see ExperimentalTesseraChipApi.

Since

1.0.0

Inheritors

Types

Link copied to clipboard
object Companion

Constants for LinkLossPolicy.

Link copied to clipboard
data object End : LinkLossPolicy

End the read at the first lost link: ChipReadEnding.Partial with what was read when access had been granted, ChipReadEnding.Failed otherwise.

Link copied to clipboard
class ReadAgain(val maxRestarts: Int) : LinkLossPolicy

Start the whole read again, from the beginning, when the document is found again; at most maxRestarts times. Everything from the earlier attempt is dropped, so the result always comes from one uninterrupted chip session.

Link copied to clipboard
class Resume(val maxRestarts: Int) : LinkLossPolicy

Continue the read where it stopped when the document is found again; at most maxRestarts times in a row that make no progress. A lost link after an attempt that read more bytes of the data groups than the attempts before it (counting the bytes kept, and a data group cut off) uses no restart, so a read that keeps getting somewhere is not ended by the limit; the platform's total time limit still ends it (Android NfcReadSettings.totalTimeLimitMillis; on iPhone the system session's own limit).

Properties

Link copied to clipboard
abstract val maxRestarts: Int

The most times a read may start again after a lost link: 0 for End.