Skip to main content

retries_remaining

Function retries_remaining 

Source
fn retries_remaining(count: u32, batch_size: u8) -> u8
Expand description

Compute how many CheckMac attempts remain before the next batch threshold is hit.

batch_size is PIN_MAX_RETRIES for PIN, PUK_MAX_RETRIES for PUK. The convention is that refresh_counter_batch is called on every successful verify to push count to a non-multiple-of-batch value (specifically, next_multiple + 1). So in normal operation:

  • count == 0 : freshly-provisioned chip, no verify attempted yet, batch_size attempts remain.
  • count % batch == 1 : freshly refreshed after a successful verify, batch_size - 1 attempts remain in the current batch.
  • count % batch == r in 2..batch : batch_size - r attempts remain.
  • count % batch == 0 with count > 0 : SATURATION. The user has consumed a full batch with no successful verify in between. Returns 0 attempts.