In development. It changes without notice.
Topic
Security
The lockout after wrong secrets, which lasts through a sleep or a cut in power, the log of security events, and the rule for a new secret.
- The lockout (BruteForceGuard) counts a wrong PIN or passphrase before it is derived. From the fourth failure in a row the board waits 30 s between tries, from the seventh 300 s, and the tenth is a factory reset (Change of Owner & Resets). The count is in NVS. On a board whose clock can be trusted the end of a wait is a time; on the others it is measured from the start of the board, so a restart begins the wait again.
- The log (AuditLog) keeps the last 16 events in NVS, with one CSV form for the SD card and the portal.
- The rule for a new secret says, for each kind of entry, how long it may be, and which kind this board has (Unlock Entry).
The vault and every screen read the guard; nothing here reads the vault.
Files | |
| file | src/ |
| Single CSV wire shape for audit-log exports. | |
| file | src/ |
| Circular buffer of 16 security events persisted in NVS. | |
| file | src/ |
| The entry surface this board sets a new unlock secret on. | |
| file | src/ |
| Counts wrong secrets and locks out the unlock, longer as they repeat. | |
| file | src/ |
| Single source of truth for unlock-secret length policy and for the character class of a numeric PIN. | |
Classes | |
| struct | kleidos:: |
| Single audit entry — 6 bytes on the wire. More about kleidos:: | |
| class | kleidos:: |
| Append-only circular log of AuditEvent records persisted in NVS. More about kleidos:: | |
| class | kleidos:: |
| The unlock's attempt counter, its lockout windows and its wipe threshold. More about kleidos:: | |
| struct | kleidos:: |
| The shortest and the longest new PIN a surface with a range takes. More about kleidos:: | |
Functions | |
| size_t | kleidos:: |
| Format one audit entry as a CSV row: timestamp,EVENT_ | |
| const char * | kleidos:: |
| Stable wire name for an audit event. | |
| void | kleidos:: |
| Native-only seam to inject a deterministic device secret. | |
| void | kleidos:: |
| Native-only seam to clear the in-RAM volatile-lock arm point. | |
| uint32_t | kleidos:: |
| Native-only seam: lockout refusals reported since the last reset. | |
| constexpr bool | kleidos:: |
Whether n is one of the allowed lengths of a dialed PIN. | |
| constexpr bool | kleidos:: |
Whether s holds the character class of a numeric PIN: at least one byte, and every byte an ASCII digit. | |
| constexpr uint8_t | kleidos:: |
How many more digits a PIN being chosen needs to reach an allowed length: the next of kPinLengthOptions at or above n. | |
| constexpr uint8_t | kleidos:: |
Position of n in kPinLengthOptions, for a picker that preselects a length. | |
| constexpr uint8_t | kleidos:: |
| Coerce a (possibly stale / out-of-range) PIN length to a valid one. | |
| constexpr SecretKind | kleidos:: |
| Coerce a raw persisted byte to a known secret kind. | |
| constexpr PinMethod | kleidos:: |
| Coerce a raw persisted byte to a known method. | |
| constexpr bool | kleidos:: |
Whether a free-length PIN of n digits is in range. | |
| constexpr std::span< const uint8_t > | kleidos:: |
The lengths a new PIN may take on surface, where it offers a list. | |
| constexpr PinRange | kleidos:: |
The range of lengths a new PIN may take on surface. | |
| constexpr bool | kleidos:: |
Whether a new PIN of n digits may be set on surface. | |
| constexpr uint8_t | kleidos:: |
The PIN length a vault records for a new PIN of typedDigits set on surface. | |
| constexpr uint8_t | kleidos:: |
Coerce a recorded PIN length to one surface can collect. | |
| constexpr uint8_t | kleidos:: |
| How many more digits a free-length PIN being set needs before OK answers. | |
| constexpr bool | kleidos:: |
Whether a new passphrase of n characters may be set. | |
| constexpr bool | kleidos:: |
Whether a new secret of kind and n characters may be set on surface: the floor every surface that sets a secret checks. | |
Variables | |
| constexpr const char * | kleidos:: |
| CSV header line shared by every audit export surface. | |
| constexpr size_t | kleidos:: |
| constexpr SetSurface | kleidos:: |
| This board's entry surface for a new secret. | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr std::array< uint8_t, 3 > | kleidos:: |
| The allowed lengths of a dialed PIN, offered by the change-PIN length picker. | |
| constexpr SecretKind | kleidos:: |
| Secret kind of a vault provisioned before the kind was recorded. | |
| constexpr PinMethod | kleidos:: |
| The method a fresh device dials with, and the one Reset Settings restores. | |
| constexpr uint8_t | kleidos:: |
| Number of methods a picker offers. | |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| Shortest passphrase an encrypted backup accepts (the envelope's floor). | |
Enumeration Type Documentation
AuditEvent #
Security-relevant event categories recorded by the audit log.
| Enumerator | |
|---|---|
| PinOk | Successful unlock (PIN or passphrase). |
| PinFail | Failed unlock attempt (a wrong PIN or passphrase). |
| VaultWipe | Vault wiped (manual or brute-force lockout). |
| BleType | Credential typed over BLE HID. |
| OtaUpdate | OTA firmware update applied. |
| AdminLogin | Admin portal login. |
| BondsForgotten | Every paired host de-bonded at once. Recoverable by re-pairing, but a pairing is what lets the device type into a machine, so all of them disappearing at once is exactly what a non-repudiation record is for. Appended, never renumbered: the value is what a stored entry holds. |
| VaultExport | A full copy of the vault was written to removable media — the raw SD set or the passphrase-sealed envelope. The vault on flash is unchanged, which is exactly why it needs a record: nothing else on the device shows that every credential left it, and the export runs from three surfaces (the admin portal, both on-device vault menus, the debug console). |
| VaultRekey | The vault key was rotated and the previous one destroyed. Every record on flash was rewritten, and anything the rotation could not read was skipped and is now unreadable for good — which is why the retirement, and not the opening of the rotation, is the moment worth recording. |
| VaultCleared | The vault was emptied under the same secret (the vault-only wipe): every credential, one-time code and saved network went, the secret, the pairings and the access-point identity stayed. Recorded after the secret was proven and before the first byte is erased. Apart from |
AuditTime #
When an entry's time is read.
A timestamp of 0 is the log's "no time" (see AuditEntry::
| Enumerator | |
|---|---|
| Now | Read the trusted clock now; 0 when none runs. |
| Later | Do not read the clock: the entry is written with no time, and AuditLog:: |
PinMethod #
How a board whose unlock is a timed hold of one key dials each digit.
Input only: both methods enter the same PIN under the same key and the same brute-force counter. Persisted as one stored byte, so the enumerator values are part of the stored representation — append, never renumber.
SecretKind #
Which kind of unlock secret a vault was provisioned with.
On the touch boards a PIN and a passphrase are both typed on the same on-screen keyboard, so the board alone does not say which one opens the vault: the vault records the kind it was provisioned with, and the unlock surface then opens on the matching keyboard layer. The owner picks the kind with the keypad's ABC / 123 switch when creating the vault. The boards that dial record a PIN, and the boards with a keyboard a passphrase. The enumerator values are part of the persisted representation: append, never renumber.
| Enumerator | |
|---|---|
| Pin | Numeric PIN, dialed or tapped on the touch keypad. |
| Passphrase | Free-length passphrase in [kPassphraseMin, kPassphraseMax]. |
SetSurface #
Which entry surface a board sets a new unlock secret on.
It decides which new PIN lengths the board takes, wherever the secret is set: on the device, and through the portal's secret change on its behalf. A new passphrase takes [kPassphraseSetMin, kPassphraseMax] characters on every surface. The board's own value is kBoardSetSurface (board_
Function Documentation
auditEventName() #
Stable wire name for an audit event.
One table, for the admin portal and the SD export alike. With two — the portal answering WIPE / OTA / ADMIN while the SD export wrote VAULT_WIPE / OTA_UPDATE / ADMIN_LOGIN for the same three events — the same history read differently depending on where it was exported from.
- Parameters
-
Name Direction Meaning event in Stored event byte cast to AuditEvent.
- Returns
- The event name, or
"UNKNOWN"for a value this build does not know.
clampPinLength() #
Coerce a (possibly stale / out-of-range) PIN length to a valid one.
- Parameters
-
Name Direction Meaning n in Candidate PIN length.
- Returns
nwhen valid, elsekPinLengthDefault.
clampPinMethod() #
Coerce a raw persisted byte to a known method.
- Parameters
-
Name Direction Meaning raw in Stored byte.
- Returns
- The matching method, or
kPinMethodDefaultfor an unknown value.
clampSecretKind() #
Coerce a raw persisted byte to a known secret kind.
- Parameters
-
Name Direction Meaning raw in Stored discriminator byte.
- Returns
- The matching kind, or
kSecretKindDefaultfor an unknown value.
clampStoredPinLength() #
Coerce a recorded PIN length to one surface can collect.
The dial collects fixed lengths only: a free length or any unknown byte opens the default. The touch keypad collects every PIN free (type, then OK), so every byte reads kPinLengthFree there, a fixed 4, 6 or 8 from a vault made before free lengths among them: its length is ignored for entry, and the gate weighs the secret by the free range. A keyboard keeps 4, 6 and 8 fixed and reads anything else as free.
- Parameters
-
Name Direction Meaning surface in The board's entry surface. raw in The record's pinLengthbyte.
- Returns
- A length the surface's entry can be sized to.
digitsToFreePinMin() #
How many more digits a free-length PIN being set needs before OK answers.
- Parameters
-
Name Direction Meaning n in Digits entered so far.
- Returns
- 0 at or past
kFreePinMin, else the digits still missing.
digitsToNextPinLength() #
How many more digits a PIN being chosen needs to reach an allowed length: the next of kPinLengthOptions at or above n.
- Parameters
-
Name Direction Meaning n in Digits entered so far.
- Returns
- 0 when
nis already allowed (or past the longest option), else the digits still missing.
formatAuditCsvRow() #
Format one audit entry as a CSV row: timestamp,EVENT_
Event names come from auditEventName, so the CSV carries the same stable wire names as the JSON form of /api/audit. The fields are a number, an identifier from a fixed table, and a number — none can contain a comma or quote, so no RFC-4180 quoting is needed.
- Parameters
-
Name Direction Meaning entry in The stored audit entry. out out Destination buffer, NUL-terminated on success. cap in Capacity of outin bytes (>=kAuditCsvRowCapalways succeeds).
- Returns
- Bytes written excluding the NUL, or 0 when
outcannot hold the row (nothing usable is left inout).
freePinLengthAllowed() #
Whether a free-length PIN of n digits is in range.
- Parameters
-
Name Direction Meaning n in The PIN's length.
- Returns
- true when
nis in [kFreePinMin,kFreePinMax].
isDigitsOnly() #
Whether s holds the character class of a numeric PIN: at least one byte, and every byte an ASCII digit.
The length rule is isValidPinLength; this is the other half of what makes a secret a SecretKind::
- Parameters
-
Name Direction Meaning s in Bytes to inspect; need not be NUL-terminated at n.n in Number of bytes to inspect.
- Returns
- true when
nis non-zero and every byte is in'0'..'9'.
isValidPinLength() #
Whether n is one of the allowed lengths of a dialed PIN.
- Parameters
-
Name Direction Meaning n in Candidate PIN length.
- Returns
- true when
nis inkPinLengthOptions.
lockoutRefusalReports() #
Native-only seam: lockout refusals reported since the last reset.
BruteForceGuard::
- Returns
- Refusals that would have been logged since
resetLockState().
newPassphraseLengthAllowed() #
Whether a new passphrase of n characters may be set.
- Parameters
-
Name Direction Meaning n in The new passphrase's length.
- Returns
- true when
nis in [kPassphraseSetMin,kPassphraseMax].
newPinLengthAllowed() #
Whether a new PIN of n digits may be set on surface.
- Parameters
-
Name Direction Meaning surface in The board's entry surface. n in The new PIN's length.
- Returns
- true when
nis one of the dial's lengths on the dial, in the free range on the keypad; never on a keyboard.
newPinLengths() #
The lengths a new PIN may take on surface, where it offers a list.
- Parameters
-
Name Direction Meaning surface in The board's entry surface.
- Returns
- The dial's lengths, shortest first; empty on the keypad (which takes a range,
newPinRange) and on a keyboard (which sets no PIN).
newPinRange() #
The range of lengths a new PIN may take on surface.
- Parameters
-
Name Direction Meaning surface in The board's entry surface.
- Returns
- [
kFreePinMin,kFreePinMax] on the keypad; {0, 0} elsewhere.
newSecretAllowed() #
Whether a new secret of kind and n characters may be set on surface: the floor every surface that sets a secret checks.
- Parameters
-
Name Direction Meaning surface in The board's entry surface. kind in The kind of the new secret. n in Its length.
- Returns
- true when the secret meets the floor for its kind on
surface.
pinLengthOptionIndex() #
Position of n in kPinLengthOptions, for a picker that preselects a length.
- Parameters
-
Name Direction Meaning n in A PIN length.
- Returns
- The index of
n, or the index ofkPinLengthDefaultwhennis not one of the options.
recordedPinLength() #
The PIN length a vault records for a new PIN of typedDigits set on surface.
The keypad records kPinLengthFree: the real number of digits is stored nowhere, so the pre-unlock read (unauthenticated) shows no length and the entry offers none to stop at. The dial records the length it collects, which is already on its glass. A keyboard sets a passphrase, whose record carries the default (nothing reads it).
- Parameters
-
Name Direction Meaning surface in The board's entry surface. typedDigits in The new PIN's length (checked by newSecretAllowed).
- Returns
- The byte the record's
pinLengthtakes.
resetLockState() #
Native-only seam to clear the in-RAM volatile-lock arm point.
The volatile-clock cooldown keeps its monotonic arm timestamp in RAM (it has the same lifetime as the monotonic source: both are lost on reboot / deep sleep). Tests call this to model a reboot — after it, a persisted lock has no in-RAM arm point, and the next read re-arms the whole persisted duration. It also forgets which lockout refusal was last reported, which is RAM too.
setDeviceSecretProvider() #
Native-only seam to inject a deterministic device secret.
The device-bound counter authentication keys its HMAC off the eFuse-HMAC / NVS-pepper device secret, which only exists on a board running the hardened build. On the host the backend is None (binding disabled), so this seam lets the host tests supply a fixed 32-byte secret and exercise the authenticate / fail-closed logic. When a provider is installed, binding is treated as enabled; passing nullptr disables it (plain-counter behavior).
- Parameters
-
Name Meaning provider Callback writing exactly 32 secret bytes to its argument and returning true on success, or nullptrto disable binding.
Variable Documentation
kAuditCsvRowCap #
Worst-case bytes for one formatted row including the NUL: 10-digit timestamp + the longest event name ("BONDS_
kFreePinMax #
The longest free-length PIN: the longest secret any entry collects. A literal, so the site reads it from this header.
kFreePinMin #
The shortest free-length PIN (the touch keypad): the default length of every board. A literal, so the site reads it from this header.
kPassphraseMax #
Keyboard passphrase: inclusive upper bound (also the largest unlock secret any modality can produce, so it sizes the validation buffers).
kPassphraseMin #
Keyboard passphrase: inclusive lower bound of a secret an entry tests (an unlock, the current secret). A vault set before the set floor rose keeps opening.
kPassphraseSetMin #
The shortest passphrase a new vault secret may be: wherever a passphrase is set (the keyboard boards, the touch keypad's ABC layer, the portal).
kPinLength #
The default dialed PIN length as a compile-time constant, for call sites that want a "typical" PIN length. Runtime code uses the active length.
kPinLengthDefault #
The length a new PIN takes where nobody chose one: the length every create surface preselects (setup's length page, the unlock screen over an absent vault) and the one a fresh vault records. Allowed on every surface that sets a PIN (newPinLengths). An existing vault's length is read from its meta, never from here.
kPinLengthFree #
A PIN length that is no number of digits: an entry field that does not stop at a length by itself and submits on its OK key only (a keyboard, and every PIN on the touch keypad).
kPinLengthMax #
Largest allowed length of a dialed PIN. Sizes the digit buffers so a runtime length change never reallocates; the whole buffer is always wiped.