Skip to content

PINs & lockout

The badge has two independent PIN systems with different lockout behaviour. Confusing them is the most common source of “did I just brick my badge?” worries, so this page keeps them strictly apart.

  • The badge PIN unlocks the device UI and the serial console. Its lockout is a temporary rate limit that recovers automatically.
  • The OpenPGP card PINs (PW1 / PW3) follow smartcard semantics: their retry counters are persistent and reaching zero is terminal until reset.

All PINs are managed by PinManager and stored, signed, in secure-element R-Memory slot 0 (see Secure element & key generation).

PropertyValueSource
Length4-8 digits, digits onlyPinManager.h BADGE_PIN_MIN/MAX; PinManager.cpp
Default123456PinManager.h DEFAULT_BADGE_PIN
Stored asLEFT(SHA256(PIN), 16)PinManager.cpp computeBadgeHash
Max attempts3 (MAX_RETRIES)PinManager.h
Comparisonconstant-time-stylePinManager.cpp compareHash

The badge PIN does not use a persistent attempt counter on the chip. Only a binary “locked” flag is stored in R-Memory; the retry count lives in RAM. The behaviour is a self-recovering rate limit:

  1. On boot the firmware grants one attempt (or zero if the locked flag was set) and starts a recovery timer.
  2. A correct PIN restores the counter to 3 and clears any lock.
  3. A wrong PIN decrements the counter. When it hits zero, the locked flag is set and the recovery timer (re)starts.
  4. After the 60-second recovery window expires, the counter is restored to 3 and the locked flag is cleared automatically.

The serial console reuses the same badge PIN and the same lockout state: an exhausted badge PIN blocks AUTH over serial for the recovery window, and the console reports the remaining seconds.

Set or change it from the badge’s PIN settings. A new badge PIN must satisfy the 4-8 digit rule and, if a duress PIN is armed, must differ from it.

When the badge is used as an OpenPGP smartcard over USB CCID, it presents the two standard OpenPGP PINs. These are separate from the badge PIN, with their own values and their own counters.

PINRoleMin lengthMax lengthDefaultMax attempts
PW1User PIN (sign/decrypt/authenticate)6161234563
PW3Admin PIN (card management)816123456783

Both are hashed with OpenPGP iterated + salted S2K over SHA-256 (default 100000 iterations) with a per-PIN random salt, as required by the OpenPGP card KDF-DO (see ADR-0004).

PW1 and PW3 use smartcard semantics: the retry counter is decremented and persisted synchronously before the comparison, so a power-cycle in the middle of a verify cannot resurrect an attempt. When a counter reaches zero, that PIN is blocked.

  • A blocked PW1 can be unblocked by the admin (PW3) via the OpenPGP RESET RETRY COUNTER command, or by the Resetting Code path.
  • A blocked PW3 is terminal: there is no host command that resets the admin PIN’s counter on the card. Recovering an admin-locked card means wiping the device and re-initialising.

The OpenPGP card protocol itself (CCID transport, APDUs, status words) is covered in the developer protocol docs.

Badge PINOpenPGP PW1OpenPGP PW3
Scopedevice UI + serialOpenPGP card userOpenPGP card admin
Length4-86-168-16
CounterRAM, self-recoveringpersistent, terminalpersistent, terminal
After max attempts60 s recovery, then restoredblocked until PW3/RC resetblocked, wipe to recover