In development. It changes without notice.
Topic
Admin Portal Rules
The decisions the portal's routes take, with no server behind them.
Whether a session's token is good, what an idle session is told, whether a restore may start, how a field of a CSV or of a code is read, and how much a backup may hold. They are tested on a computer.
- See also
- Wi-Fi Admin Portal
Files | |
| file | src/ |
| Implementation of the admin-portal pure security-decision logic. | |
| file | src/ |
| Pure security-decision logic for the admin portal (auth gatekeeper). | |
| file | src/ |
| Pure logic for the authority the admin portal answers at (host-testable). | |
| file | src/ |
| Worst-case size of this device's own backup, from the schema itself. | |
| file | src/ |
| Pure id-batch validation and staging for the credential delete batch. | |
| file | src/ |
| What reading one request header found: a value, no header, or one the portal could not read (host-testable). | |
| file | src/ |
| Pure logic for the admin portal idle (timeout) endpoint. | |
| file | src/ |
| Pure request/item validation for the normalized merge-import endpoint. | |
| file | src/ |
| Pure shaping of the firmware-status read-out (host-testable). | |
| file | src/ |
| Which new PIN lengths the portal's secret change takes on each kind of board, and the refusal it answers otherwise (host-testable). | |
| file | src/ |
| Pure refusal logic for the vault-restore endpoints (host-testable). | |
| file | src/ |
| Which edits of a stored record destroy a secret the device cannot give back. | |
| file | src/ |
| Pure, host-testable logic behind the admin portal's device-information API. | |
| file | src/ |
| Pure formatting of the RTC-health read-out (host-testable). | |
| file | src/ |
| Pure decision + formatting logic behind the admin portal TOTP endpoints. | |
| file | src/ |
| RFC 4180 CSV credential line parser, extracted for testability. | |
| file | src/ |
| Pure columnar JSON encoder for the telemetry history response. | |
| file | src/ |
| Pure parser for the shared embedded-TOTP wire contract. | |
Namespaces | |
| namespace | kleidos:: |
| The portal secret change's PIN-length rule, per kind of board. | |
Typedefs | |
| using | kleidos:: |
| using | kleidos:: |
| Resolves a registry index to a channel name (kleidos:: | |
| using | kleidos:: |
| Destination for one completed chunk of body text. | |
Functions | |
| bool | kleidos:: |
| Decide whether a request is within its per-IP rate limit, updating the slots. | |
| bool | kleidos:: |
Constant-time validity check for an X-Session-Token header value. | |
| bool | kleidos:: |
| Validate an HTTP Basic-Auth header value against the derived OTA password. | |
| void | kleidos:: |
Write byteCount bytes as lowercase hex into dst (NUL-terminated). | |
| constexpr bool | kleidos:: |
| Whether the portal has an address it can name in an absolute URL. | |
| constexpr bool | kleidos:: |
Case-insensitive compare of a Host value against one authority. | |
| constexpr bool | kleidos:: |
Whether a Host value names the client's own loopback. | |
| constexpr bool | kleidos:: |
Whether a request's Host authority is one the portal answers at. | |
| constexpr const char * | kleidos:: |
| Where a request is redirected to reach the panel. | |
| constexpr HeaderRead | kleidos:: |
| Classify a header by whether the transport reports it and how long its value is. | |
| constexpr IdleResponse | kleidos:: |
| Evaluate the admin-portal idle timer. | |
| size_t | kleidos:: |
| The length a truncation check is told for a bound text member. | |
| bool | kleidos:: |
| bool | kleidos:: |
| uint32_t | kleidos:: |
| uint16_t | kleidos:: |
| void | kleidos:: |
| A custom field from its bound entry, and its truncation checks. | |
| const char * | kleidos:: |
| Judge the size of the items array of POST /api/import/items. | |
| const char * | kleidos:: |
| Decode and validate one normalized item. | |
| bool | kleidos:: |
| A custom entry closed: kept while the record has room for it. | |
| bool | kleidos:: |
| A urls entry arrived: an empty one is not one; the first ones the record holds are kept, the rest dropped. | |
| bool | kleidos:: |
| A history entry closed: one with no password records nothing; the first ones the record holds are kept. | |
| bool | kleidos:: |
| An item closed: handed on with its arrays, which are then forgotten. | |
| constexpr bool | kleidos:: |
| Whether the running image is still on rollback trial. | |
| constexpr const char * | kleidos:: |
| One-word stage of the last/current OTA attempt for the status row. | |
| constexpr const char * | kleidos:: |
The refusal for a pin_length surface does not take. | |
| constexpr bool | kleidos:: |
Whether a requested pin_length is one surface takes. | |
| constexpr bool | kleidos:: |
Whether surface can collect a new passphrase (a body without pin_length). | |
| constexpr security:: | kleidos:: |
| The kind the new secret is recorded as: the one the body asked for. | |
| constexpr size_t | kleidos:: |
Length of the secrets frame at the start of data. | |
| constexpr bool | kleidos:: |
| Whether a secrets frame opens with the lead-in: bodycap:: | |
| constexpr Refusal | kleidos:: |
| The size check a restore request takes before a byte of it is read. | |
| constexpr Refusal | kleidos:: |
| The shape check on the unlock secret the frame carried. | |
| constexpr Refusal | kleidos:: |
| Run the size and secret-shape checks for a restore request. | |
| constexpr uint16_t | kleidos:: |
| HTTP status code for a refusal. | |
| constexpr const char * | kleidos:: |
| JSON error body for a refusal. | |
| constexpr Outcome | kleidos:: |
| Translate a vault restore result into the client-facing outcome. | |
| constexpr uint16_t | kleidos:: |
| HTTP status code for a finished restore. | |
| constexpr const char * | kleidos:: |
| JSON response body for a finished restore. | |
| bool | kleidos:: |
| Whether a kFillHeader value says "go on". | |
| const char * | kleidos:: |
| JSON body for a finished restore, with the counts the owner is told. | |
| constexpr bool | kleidos:: |
| Whether an edit loses the stored seed. | |
| bool | kleidos:: |
Whether writing next over a single-string pool entry loses it. | |
| template<typename NextValues> | |
| bool | kleidos:: |
| Whether a new custom-field set loses a stored hidden value. | |
| constexpr BuildFlavor | kleidos:: |
| Resolve the build flavor from the four build-time predicates. | |
| constexpr const char * | kleidos:: |
| Stable wire token for a build flavor. | |
| constexpr const char * | kleidos:: |
| Stable wire token for a register-map bus kind. | |
| constexpr AudioOutputLabel | kleidos:: |
| Name the audio output a board carries, and whether this firmware drives it. | |
| constexpr ChipProbe | kleidos:: |
| Turn a register-map lookup result into a core-crossing observation. | |
| constexpr ChipProbe | kleidos:: |
| Turn a driver's own presence probe into a core-crossing observation. | |
| constexpr void | kleidos:: |
| Apply a sampled observation to a compile-time inventory row. | |
| void | kleidos:: |
| Render the alarm state as one human-readable line. | |
| constexpr const char * | kleidos:: |
| One-word countdown-timer state. | |
| Route | kleidos:: |
| Match a request URL against the dynamic TOTP route shapes. | |
| bool | kleidos:: |
True when url is a live-code route the SPA polls on a timer. | |
| constexpr int | kleidos:: |
| Decide the HTTP status of a live-code request. | |
| constexpr const char * | kleidos:: |
| The :: | |
| WriteParams | kleidos:: |
Read and judge the digits and period of a TOTP write body. | |
| std::string | kleidos:: |
| Render a code as its fixed-width, zero-padded decimal string. | |
| std::string | kleidos:: |
| Build the GET /api/totp/:id metadata body. | |
| std::string | kleidos:: |
| Build a live-code body for either code route. | |
| bool | kleidos:: |
True when ch is a CSV line-trimming character (space, tab, CR, LF). | |
| void | kleidos:: |
| Handle one character inside a quoted CSV field (RFC 4180 §2.7). | |
| bool | kleidos:: |
| Parse one CSV line into a Credential (name, user, pass, url) using RFC 4180 quoting. | |
| size_t | kleidos:: |
Smallest decimation stride that keeps sampleCount within maxEmitted. | |
| size_t | kleidos:: |
Buffer size to allocate for a body holding sampleCount samples. | |
| EncodeResult | kleidos:: |
Encode a ring snapshot as the GET /api/telemetry body. | |
| EncodeResult | kleidos:: |
Emit the GET /api/telemetry body through a chunk sink. | |
| bool | kleidos:: |
| Map a wire algorithm name to its stored value (forwards to TotpGenerator). | |
| constexpr const char * | kleidos:: |
| The wire name of a stored algorithm value. | |
| void | kleidos:: |
| Decode XX escapes of a URI component (forwards to TotpGenerator). | |
| bool | kleidos:: |
Whether text begins with otpauth:// (forwards to TotpGenerator). | |
| const char * | kleidos:: |
Parse an otpauth:// URI into entry. | |
| FieldParse | kleidos:: |
| Decode the optional "totp" field of a credential-write body. | |
Variables | |
| constexpr const char * | kleidos:: |
| Target a request is given when the portal has no address to name in a URL. | |
| constexpr const char * | kleidos:: |
| Scheme and separator of the absolute URL redirectTarget builds. | |
| constexpr const char * | kleidos:: |
| Dotted quad a forwarder on the client's own machine is reached at. | |
| constexpr const char * | kleidos:: |
| Name that same forwarder is reached by. | |
| constexpr size_t | kleidos:: |
| Worst-case JSON expansion of one stored byte (\uXXXX for control bytes). | |
| constexpr size_t | kleidos:: |
| Base64 length of a maximum raw TOTP secret (4 chars per 3 bytes, rounded up). | |
| constexpr size_t | kleidos:: |
| constexpr size_t | kleidos:: |
| constexpr size_t | kleidos:: |
| constexpr size_t | kleidos:: |
| constexpr size_t | kleidos:: |
| Worst-case serialized size of one standalone-TOTP row. | |
| constexpr size_t | kleidos:: |
| constexpr size_t | kleidos:: |
| constexpr size_t | kleidos:: |
Body cap for POST /api/restore — the largest plaintext backup any board writes: as many records as the biggest board has slots, each at its schema maximum, under the longest meta any board's backup carries. | |
| constexpr size_t | kleidos:: |
| constexpr size_t | kleidos:: |
| Largest accepted items array per request; bigger imports arrive batched. | |
| constexpr size_t | kleidos:: |
| constexpr uint8_t | kleidos:: |
| constexpr const char * | kleidos:: |
| Missing/empty array. | |
| constexpr const char * | kleidos:: |
| Batch cap hit. | |
| constexpr const char * | kleidos:: |
| Empty name. | |
| constexpr const char * | kleidos:: |
| Passwordless without opt-in. | |
| constexpr const char * | kleidos:: |
| No free slot for this item. | |
| constexpr const char * | kleidos:: |
| Vault write failed. | |
| constexpr uint32_t | kleidos:: |
| constexpr size_t | kleidos:: |
| Index of label in kCustomMembers. | |
| constexpr size_t | kleidos:: |
| Index of value in kCustomMembers. | |
| constexpr json::Member | kleidos:: |
| The members of one custom entry. | |
|
constexpr json:: | kleidos:: |
| The table of one custom entry. | |
| constexpr std::array< const char *, kMaxCustomFields > | kleidos:: |
| The static report token of each of the twelve custom fields. | |
| constexpr size_t | kleidos:: |
| Index of pass in kHistoryMembers. | |
| constexpr json::Member | kleidos:: |
| The members of one history entry. | |
|
constexpr json:: | kleidos:: |
| The table of one history entry. | |
| constexpr size_t | kleidos:: |
| constexpr json::Member | kleidos:: |
| The members of one item. | |
|
constexpr json:: | kleidos:: |
| The table of one item. | |
| constexpr size_t | kleidos:: |
| Index of items in kImportMembers. | |
| constexpr json::Member | kleidos:: |
| The members of the request. | |
|
constexpr json:: | kleidos:: |
| The table of the request. | |
| constexpr std::array< const char *, 3 > | kleidos:: |
| constexpr const char * | kleidos:: |
| constexpr size_t | kleidos:: |
| The most bytes a restore body's secrets frame may take. | |
| constexpr const char * | kleidos:: |
| The request header that answers a DoesNotFit refusal with "go on": the value 1 restores the backup's entries in its own order until the device is full and leaves the rest out (OverCapacity:: | |
| constexpr size_t | kleidos:: |
| Bytes a finished restore's body may take with its counts appended: the longest static body plus three count objects of ten-digit numbers. | |
| constexpr size_t | kleidos:: |
| Longest alarm text: "monthly day 31, weekday 6 at 23:59" + terminator. | |
| constexpr int | kleidos:: |
| Request served. | |
| constexpr int | kleidos:: |
| Malformed body or illegal field value. | |
| constexpr int | kleidos:: |
| No such slot, or the slot has no secret. | |
| constexpr int | kleidos:: |
| URL matched, method did not. | |
| constexpr int | kleidos:: |
| The TOTP gate refused a code. | |
| constexpr int | kleidos:: |
| Declared body exceeds the cap. | |
| constexpr int | kleidos:: |
| Vault mount / save failure. | |
| constexpr int | kleidos:: |
| Body buffer could not be allocated. | |
| constexpr const char * | kleidos:: |
| Body paired with :: | |
| constexpr const char * | kleidos:: |
| constexpr const char * | kleidos:: |
| constexpr const char * | kleidos:: |
| constexpr const char * | kleidos:: |
| Body paired with :: | |
| constexpr const char * | kleidos:: |
Body paired with ::digits other than 6 or 8. | |
| constexpr const char * | kleidos:: |
Body paired with ::period other than 30 or 60. | |
| constexpr const char * | kleidos:: |
Body paired with ::algorithm other than SHA-1 or SHA-256. | |
| constexpr size_t | kleidos:: |
| constexpr size_t | kleidos:: |
| Total byte budget for the response body (also the buffer the caller allocates). | |
| constexpr size_t | kleidos:: |
| Planning estimate for one emitted sample: time delta + value, both with commas. | |
| constexpr size_t | kleidos:: |
| Allowance for the scalar header, the channel-name array, and series scaffolding. | |
| constexpr size_t | kleidos:: |
| Largest number of samples the budget admits (see the file-header arithmetic). | |
| constexpr uint8_t | kleidos:: |
| Stride doublings attempted before giving up on fitting the budget. | |
| constexpr uint8_t | kleidos:: |
| HMAC-SHA1, RFC 6238 default. | |
| constexpr uint8_t | kleidos:: |
| HMAC-SHA256. | |
| constexpr size_t | kleidos:: |
| constexpr size_t | kleidos:: |
| constexpr size_t | kleidos:: |
| Room for the longest algorithm name and more; a longer one is refused. | |
| constexpr size_t | kleidos:: |
| Index of each member in kTotpBodyMembers. | |
| constexpr size_t | kleidos:: |
| account. | |
| constexpr size_t | kleidos:: |
| algorithm. | |
| constexpr size_t | kleidos:: |
| digits. | |
| constexpr size_t | kleidos:: |
| period. | |
| constexpr int64_t | kleidos:: |
| constexpr json::Member | kleidos:: |
| The members of the "totp" object. | |
|
constexpr json:: | kleidos:: |
| The nested table of the "totp" object. | |
Typedef Documentation
ChunkSink #
Destination for one completed chunk of body text.
- Parameters
-
Name Direction Meaning ctx in Opaque caller context. data in Chunk bytes; not NUL-terminated. length in Number of bytes in data.
- Return values
-
Value Meaning true Chunk accepted; emission continues. false Sink failed (e.g. the peer disconnected); emission stops and the result is reported as unusable.
ItemFn #
Called as each item closes, with what it held.
- Parameters
-
Name Direction Meaning user in The pass's user pointer. item in, out The bound item. bound in What it held. arrays in Its array entries.
- Returns
- False to stop the bind.
Enumeration Type Documentation
BatchIdError #
BuildFlavor #
Which of the five kinds of build produced the running firmware.
The base open build, the debug build, the open release build, the hardened build, and the hardened build's bench twin with Flash Encryption in development mode.
FieldAction #
HeaderRead #
ImportItemMember #
Index of each member in the item table, as the report and presence checks name them.
Outcome #
What the device tells the client about a FINISHED restore attempt.
The gate above decides whether a restore may start; this decides what the client is told once one has run. The failures are not interchangeable: a rejected backup leaves the vault exactly as it was, while the two partial answers have already replaced it with a strict subset of the backup. Answering either of those with the first ("invalid backup", 400) is both the wrong reason and a dangerous understatement — the owner is not told that their vault changed, so they never learn the backup file is the whole copy.
The two partial answers carry the same fact about the vault and opposite advice about what to do next, which is why they are separate outcomes rather than one with two sentences:
- PartiallyWritten — the DEVICE did not manage to write what the file carried. Sending the same file again can complete the vault, so that is what the owner is told.
- PartiallyRefused — the device wrote everything it accepted, and the entries that are missing are ones this build does not read. Nothing failed here, and sending the same file again produces the same vault and the same answer. Telling this owner to "restore it again" sends them round a loop with no exit.
Refusal #
Outcome of the cheap pre-verification checks on a restore request.
RouteKind #
URL shapes the dynamic TOTP dispatcher understands.
SeedWrite #
What an edit does to the embedded seed.
| Enumerator | |
|---|---|
| Keep | The seed stays (field absent, or a parameters-only object). |
| Detach | An explicit "totp": null. |
| NewSecret | The body carries a secret that replaces whatever is stored. |
Function Documentation
algorithmFromString() #
Map a wire algorithm name to its stored value (forwards to TotpGenerator).
- Parameters
-
Name Direction Meaning text in NUL-terminated name: SHA1 / SHA-1 / SHA256 / SHA-256, any case. out out Receives ::kAlgSha1 or ::kAlgSha256 on success.
- Return values
-
Value Meaning true Recognized name. false Unknown name; outuntouched.
algorithmName() #
The wire name of a stored algorithm value.
- Parameters
-
Name Direction Meaning algorithm in ::kAlgSha1 or ::kAlgSha256; any other value reads as SHA-1, the value an unknown stored id is clamped to.
- Returns
"SHA256"for ::kAlgSha256, otherwise"SHA1".
appendCsvQuotedChar() #
Handle one character inside a quoted CSV field (RFC 4180 §2.7).
A doubled "" escape emits one literal " and advances index past both. A lone " closes the quoted region.
- Parameters
-
Name Direction Meaning ch in Current character. line in Start of the CSV line buffer. length in Length of the line buffer in bytes. index in, out Current position within the line; may advance by 1 on a "" escape. row out Accumulator receiving the unescaped character. inQuote out Set to false when the closing " is consumed.
applyChipProbe() #
Apply a sampled observation to a compile-time inventory row.
Only ever adds information: present is left untouched, so a chip whose driver has no register map (or has not run yet) still reports the board's fitted hardware. An observed row gains probeKnown and a real probed value; a registered map additionally overrides bus and, for bus-addressed chips, address with the values the driver actually talks to. An unobserved probe leaves the row exactly as the caller built it, so a part that proves its own presence by other means (PSRAM, a mounted card) keeps the probe result it already set.
- Parameters
-
Name Direction Meaning row in, out Row to enrich in place. probe in Observation sampled by chipProbeFrom.
bodyBufferBytes() #
Buffer size to allocate for a body holding sampleCount samples.
The budget is the ceiling, not the allocation: a poll against an idle or barely-filled ring should not cost a full 12 KB on the Core-0 HTTP task while the WiFi AP holds most of the heap. This right-sizes to the estimate plus half again, so a run of unusually wide values still fits without forcing a needless decimation retry, and clamps to ::
- Parameters
-
Name Direction Meaning sampleCount in Samples the body will carry.
- Returns
- Bytes to allocate, including the NUL slot.
boundLen() #
The length a truncation check is told for a bound text member.
A text member binds into a field one byte past its vault column, clamping a longer one; the binder marks it overflowed. A check needs only to know that it was longer than the column, so an overflowed member reports one past it.
- Parameters
-
Name Direction Meaning bound in What the object held. index in The member's index in its table. text in The bound text. capacity in The vault's column for the member.
- Returns
- The text's length, or
capacity+ 1 when it overflowed.
buildCodeJson() #
Build a live-code body for either code route.
The body is a validity window, not a snapshot: it carries the code together with the seconds left in its time step, so the page draws the countdown from its own timer and refetches once per period. A page that had to poll for the countdown would spend 60 of the 80 requests the per-IP limiter allows in a 60-second window on one open panel.
The countdown field is named remaining_s (seconds) to match the rest of the admin API's _s duration suffix.
- Parameters
-
Name Direction Meaning id in Slot id (TOTP slot, or credential slot for the embedded route). code in Raw code value from the generator. digits in Stored digit count (clamped on the way out). period in Stored time step (clamped on the way out). remaining in Seconds left in the current step; capped at the clamped period.
- Returns
- The serialized JSON object.
buildFlavorName() #
Stable wire token for a build flavor.
- Parameters
-
Name Direction Meaning flavor in Flavor to name.
- Returns
- NUL-terminated lowercase token ("debug", "secure-dev", "secure", "release", "dev"); never
nullptr.
buildMetadataJson() #
Build the GET /api/totp/:id metadata body.
The name is unvalidated free text (a quote, a backslash or a control byte would break a hand-rolled body and let the caller inject JSON structure), so it is serialized through the JSON writer's escaping.
- Parameters
-
Name Direction Meaning id in Slot id. name in Display name; nullptris treated as empty.digits in Stored digit count (clamped on the way out). period in Stored time step (clamped on the way out). algorithm in Stored HMAC hash, reported by its wire name. hasSecret in Whether the record carries a usable secret.
- Returns
- The serialized JSON object. Never contains the secret itself.
busKindName() #
Stable wire token for a register-map bus kind.
- Parameters
-
Name Direction Meaning bus in Bus kind from a chip's register map.
- Returns
- NUL-terminated lowercase token; never
nullptr.
checkRestoreRequest() #
Run the size and secret-shape checks for a restore request.
Ordering is deliberate: the size refusal comes first (free), then the secret shape (free), and only a Refusal::None result may reach the PBKDF2 verify — a locked-out or absent-secret request never costs a derivation.
- Parameters
-
Name Direction Meaning bodyLen in Declared request body length in bytes. bodyCap in The honest backup bound, the biggest backup of any board (see admin_ backup_ limits.h). secretLen in Length of the presented unlock secret (0 = absent). secretCap in Maximum unlock-secret length the vault accepts.
- Returns
- The first refusal that applies, or Refusal::None.
checkRestoreSecret() #
The shape check on the unlock secret the frame carried.
- Parameters
-
Name Direction Meaning secretLen in Length of the presented unlock secret (0 = absent). secretCap in Maximum unlock-secret length the vault accepts.
- Returns
- The secret's refusal, or Refusal::None.
checkRestoreSize() #
The size check a restore request takes before a byte of it is read.
- Parameters
-
Name Direction Meaning bodyLen in Declared request body length in bytes. bodyCap in The honest backup bound (see admin_ backup_ limits.h); the frame's own bound is added to it here.
- Returns
- Refusal::
BodyTooLarge or Refusal::None.
chipProbeFrom() #
Turn a register-map lookup result into a core-crossing observation.
Call on the core that owns the registry, with the result of looking the row's chip up; map is nullptr when the registry holds no entry, which is a result ("not registered"), not a failure.
- Parameters
-
Name Direction Meaning map in Registered map for the row's chip, or nullptr when none.
- Returns
- The observation to publish for the other core.
classifyRead() #
Classify a header by whether the transport reports it and how long its value is.
Only a header the transport reports as not carried is absent: one sent empty is a value (an empty one), and one the transport could not answer for is unreadable. A value fits only with room for its NUL, so a value of slotBytes characters or more is unreadable.
- Parameters
-
Name Meaning presence Whether the transport reports the header. valueLength The value's length in bytes, as the transport reports it. slotBytes Bytes of the slot the value is read into, NUL included.
- Returns
Absentonly for a header not carried;Valuewhen it fits;Unreadableotherwise.
countdownLabel() #
One-word countdown-timer state.
The BM8563 exposes the timer-enable bit but not a readable remaining count, so the honest vocabulary is armed/off — plus "unreadable" when the register read itself failed.
- Parameters
-
Name Direction Meaning readOk in The TE bit was read successfully. running in The TE bit (valid only when readOk).
- Returns
"armed","off", or"unreadable".
customFieldOf() #
A custom field from its bound entry, and its truncation checks.
- Parameters
-
Name Direction Meaning kept in The entry. token in Its static report token. truncated in, out The report. field out Receives the field.
decideCodeStatus() #
Decide the HTTP status of a live-code request.
The TOTP gate is the first term by design: the handler asks it BEFORE it mounts the vault, so a refused code costs no vault I/O and can never be derived from a time base the gate did not pass.
- Parameters
-
Name Direction Meaning gate in The TOTP gate's verdict. entryFound in True when the slot decrypted into an entry. hasSecret in True when that entry carries a non-empty secret.
- Returns
- ::
kStatusClockUntrusted for any refused verdict, :: kStatusNotFound, or ::kStatusOk.
decideIdleResponse() #
Evaluate the admin-portal idle timer.
Side-effect free, header-only. The web client polls GET /api/idle every 10 s; the response drives the warning banner and the eventual auto-shutdown.
- Parameters
-
Name Meaning elapsedMs Milliseconds since last observed client activity. timeoutMs Total idle timeout (e.g. 5 min = 300000 ms). warningThresholdMs Milliseconds before timeout at which to arm the banner.
- Returns
- Remaining seconds and whether the web client should show the warning banner.
- See also
- IdleResponse
decideRateLimit() #
Decide whether a request is within its per-IP rate limit, updating the slots.
One pure function over the slot array: a request from a tracked client is judged by that client's sliding windows; a request from a new client claims a free slot, or a slot whose client has been quiet long enough that its windows no longer count anything (two full windows since its last window opened).
A slot whose client still has requests in its windows is never handed to another client. Taking it would start the newcomer with an empty budget, so a client that rotates through more addresses than there are slots would never be limited. While every slot is live, a new client is refused instead, until one of them goes quiet.
- Parameters
-
Name Direction Meaning entries in, out Slot array (mutated in place). count in Number of slots in entries.clientIp in Requesting client IPv4 (network order); 0 for a peer the server could not read. nowMs in Monotonic time of the request in milliseconds. isBootstrap in True for /api/init(the bootstrap family).cfg in Limits and window length.
- Return values
-
Value Meaning true Request is allowed (slot updated/ claimed accordingly). false Request exceeds its client's limit, or it comes from a new client while every slot is live; slots unchanged.
decimationStride() #
Smallest decimation stride that keeps sampleCount within maxEmitted.
- Parameters
-
Name Direction Meaning sampleCount in Samples available. maxEmitted in Largest number of samples the budget admits.
- Returns
- Stride in ticks; always >= 1, and 1 whenever everything already fits.
describeAudioOutput() #
Name the audio output a board carries, and whether this firmware drives it.
The label follows the board's audio output kind, which names the part: a buzzer is driven by PWM on a GPIO; a speaker sits behind an I2S amplifier, directly or behind a codec. Which board has which is on The boards. A part the firmware leaves alone (AUDIO_ 0) is still listed, marked as not driven.
- Parameters
-
Name Direction Meaning kind in The board's audio output ( device::).kAudioOutput driven in True when this firmware drives it ( device::).kAudioOutputDriven
- Returns
- The row's part name and bus token; both nullptr when nothing is fitted.
driverProbe() #
Turn a driver's own presence probe into a core-crossing observation.
For parts that register no register map but whose driver (or resolving factory) proves presence itself — the IMU WHO_AM_I classification, the touch controller probe, the keyboard-controller probe. Only the "did it answer" half is known, so bus and address stay unset and applyChipProbe leaves the row's variant-declared wiring untouched.
- Parameters
-
Name Direction Meaning responded in True when the driver's probe verified the chip.
- Returns
- The observation to publish for the other core.
encodeTelemetryBody() #
Encode a ring snapshot as the GET /api/telemetry body.
Picks a stride from the budget, writes the body, and — should it still not fit — retries at successively coarser strides. The buffer is never overrun and a partially written body is never reported as usable.
- Parameters
-
Name Direction Meaning in in Run state and oldest-first ring snapshot. out out Destination buffer. outCapacity in Size of outin bytes, including the NUL slot.
- Returns
- Body length, applied stride, and whether the body may be sent.
fillRequested() #
Whether a kFillHeader value says "go on".
Only the exact value 1, the one the API reference documents: the answer replaces the vault and leaves entries out, so a value that merely reads as true somewhere (yes, true, on, 1) is not taken as the owner's choice.
- Parameters
-
Name Direction Meaning value in The header's value; null when the request carries none.
- Return values
-
Value Meaning true Fill in the backup's order. false Refuse with the counts.
flagsOf() #
The behavior flags as an int-or-0 read saw them, narrowed to the column.
- Parameters
-
Name Direction Meaning value in The bound integer.
- Returns
- The 16-bit flags.
formatAlarm() #
Render the alarm state as one human-readable line.
Disabled fields are wildcards on the chip, so the text names only the enabled ones: "daily 07:30" (time only), "monthly day 12 at 07:30", "weekday 3 at 07:30", or "not armed" when nothing matches (that is how the HAL disarms it). A failed register read reports "unreadable" rather than a fabricated "not armed".
- Parameters
-
Name Direction Meaning alarm in Decoded alarm registers. out out Destination text buffer. cap in Capacity of out(use kAlarmTextCap).
formatCode() #
Render a code as its fixed-width, zero-padded decimal string.
The JSON body's spelling of kleidos::
- Parameters
-
Name Direction Meaning code in Raw code value. digits in Requested width; clamped by kleidos:: totp:: clampDigits.
- Returns
- The padded decimal string, exactly clampDigits(digits) characters.
formatOutcomeBody() #
JSON body for a finished restore, with the counts the owner is told.
The static body of outcomeBody, and — on the two outcomes where the numbers ARE the answer, and on every partial one that left an entry out — the counts beside it: what the backup holds (held), what this device stores (capacity) and, once a restore filled the device, what it left out (left_out). A client offers the choice from them: the admin portal, where the owner picks which entries to bring over, or the same restore again with kFillHeader, which takes the first ones in the backup's order.
- Parameters
-
Name Direction Meaning outcome in The outcome to map. tally in The restore's counts. out out Buffer for the body, at least kOutcomeBodyCap bytes to never truncate. cap in Bytes of out; at least 1.
- Returns
out, NUL-terminated: the body with its counts, or the static body alone when the counts do not apply or would not fit.
frameLength() #
Length of the secrets frame at the start of data.
- Parameters
-
Name Direction Meaning data in Bytes the body opens with. len in Bytes at data.
- Returns
- The frame's length including its line feed, or 0 when no line feed is among the first
lenbytes.
gateRefusalJson() #
The ::
Each refusal carries its own machine reason (the gate's wire spelling, kleidos::) and its own hint, so the page says what is wrong and what fixes it from inside the portal: on a board without an RTC chip only a precise set counts, and the portal's "Set from this browser" is one, where a time typed by hand is not.
- Parameters
-
Name Direction Meaning gate in The TOTP gate's verdict (a passing one gets the clock-unset body; no handler sends it). hasRtc in The board keeps the time in a battery-backed RTC.
- Returns
- A static JSON body.
hasLeadIn() #
Whether a secrets frame opens with the lead-in: bodycap::
The secrets come after the lead-in, never among the body's first bytes. A frame that does not open with the lead-in counts as no frame, so a client that leaves it out is refused before any verify and learns to send it, whatever it sends next.
- Parameters
-
Name Direction Meaning data in The frame's bytes. len in Its length.
- Returns
- True when the first kLeadIn bytes are all spaces and something follows them.
hasNamedAddress() #
Whether the portal has an address it can name in an absolute URL.
- Parameters
-
Name Meaning address The address the transport reports.
- Return values
-
Value Meaning true There is one to print. false The transport reports none (absent or empty).
hiddenValueLost() #
Whether a new custom-field set loses a stored hidden value.
A present custom array replaces the whole set. Each stored hidden value must still be the value of some field of the new set; its label, its kind and whether it stays hidden are metadata and may change.
- Template Parameters
-
Name Meaning NextValues A view of the new set: size() and value( i ) answering a NUL-terminated string (never nullptr).
- Parameters
-
Name Direction Meaning stored in The record's pool before the edit. next in The set the body writes.
- Return values
-
Value Meaning true A stored hidden value is not in next.false Every stored hidden value survives.
hostAuthorityMatches() #
Case-insensitive compare of a Host value against one authority.
Tolerates an optional ":<port>" suffix on the header value, so "192.168.4.1:80" matches "192.168.4.1". An absent or empty expected authority matches nothing: a transport with no address to report must admit no request on the strength of it.
- Parameters
-
Name Meaning host The header value. expected The authority to compare it with.
- Return values
-
Value Meaning true hostnamesexpected, with or without a port.false It names something else, or either side is absent or empty.
hostIsAllowed() #
Whether a request's Host authority is one the portal answers at.
A rebound page carries the attacker's own host name in Host (a page cannot forge it), so refusing anything but our own authorities blocks it. A missing header is no rebind vector — HTTP/1.0 and command-line clients send none — and is allowed. A header that is present but could not be read is refused: a browser always sends one, and a page chooses its own name's length, so a name too long for the header slot (192 characters or more, DNS allows 253) would otherwise pass as "no header". A header sent empty names no authority and is refused.
- Parameters
-
Name Meaning read What the read of Hostfound.host The header value when readisValue, else nullptr.apIp The address the link serves, as its interface reports it; an absent or empty one admits no request by address. apName The captive host name the SoftAP's DNS answers with. linkAccepts The transport's own verdict on host; a debug link compares the address it was given, which it never reports.
- Return values
-
Value Meaning true Serve the request. false The authority is someone else's, or could not be read.
isCsvTrimChar() #
True when ch is a CSV line-trimming character (space, tab, CR, LF).
- Parameters
-
Name Direction Meaning ch in Candidate character.
- Returns
- true when
chis one of space, tab, CR or LF.
isLoopbackAuthority() #
Whether a Host value names the client's own loopback.
A harness that cannot reach the portal's network directly forwards a loopback port to it, so the browser or client it drives presents a loopback authority for a portal that is elsewhere. Only a transport that admits one named peer anyway accepts this.
- Parameters
-
Name Meaning host The header value.
- Return values
-
Value Meaning true It names 127.0.0.1orlocalhost, with or without a port.false Anything else.
isOtpauthUri() #
Whether text begins with otpauth:// (forwards to TotpGenerator).
- Parameters
-
Name Direction Meaning text in NUL-terminated candidate, may be null.
- Returns
- true when
textstarts with the scheme, in any case.
isPolledCodeRoute() #
True when url is a live-code route the SPA polls on a timer.
The polled routes carry AuthPolicy:: a once-per-second poll under the idle-refreshing AuthPolicy:: would reset the admin idle clock forever and hold the WiFi radio up for as long as the page stays open.
- Parameters
-
Name Direction Meaning url in Request URL, already stripped of its query string. maxTotp in TOTP slot capacity. maxCredentials in Credential slot capacity.
- Return values
-
Value Meaning true urlis /api/totp/:id/code or /api/credentials/:id/totp/code.false Any other URL.
isSessionTokenValid() #
Constant-time validity check for an X-Session-Token header value.
Returns true only when the session has not expired, a token was supplied, its length is exactly expectedLen, and it matches expectedToken byte for byte. The comparison is constant-time once the lengths agree.
- Parameters
-
Name Direction Meaning nowMs in Current monotonic time in milliseconds. createdMs in Time the session token was issued. timeoutMs in Idle timeout; the session is expired once nowMs-createdMsexceeds it (unsigned semantics).providedToken in Token from the request header, or nullptrif absent.providedLen in Length of providedTokenin bytes.expectedToken in The live session token (NUL-terminated). expectedLen in Expected token length (e.g. 32 hex chars).
- Return values
-
Value Meaning true Token is present, unexpired, correctly sized, and matches. false Otherwise.
matchRoute() #
Match a request URL against the dynamic TOTP route shapes.
Rejects (returns ::
- Parameters
-
Name Direction Meaning url in Request URL, already stripped of its query string. maxTotp in TOTP slot capacity (exclusive upper bound on the id). maxCredentials in Credential slot capacity (exclusive upper bound).
- Returns
- The matched route, or a ::
RouteKind:: None route.
newSecretKind() #
The kind the new secret is recorded as: the one the body asked for.
Passed to the secret change explicitly, never carried from the record: a PIN vault changed to a passphrase (or the reverse) on the touch keypad must open on the layer that types the new secret.
- Parameters
-
Name Direction Meaning pinLengthGiven in The body carried pin_length.
- Returns
Pinwhen it did, elsePassphrase.
outcomeBody() #
JSON response body for a finished restore.
Both partial bodies carry vault_ so a client can branch on the fact rather than on prose, and say plainly that the vault was changed — the backup file is still the whole copy. They also carry retry_, because "keep the file and restore it again" is right for one of them and a loop with no exit for the other, and a client must be able to tell which without parsing English.
- Parameters
-
Name Direction Meaning outcome in The outcome to map.
- Returns
- A static JSON body; never
nullptr.
outcomeFor() #
Translate a vault restore result into the client-facing outcome.
- Parameters
-
Name Direction Meaning status in Result of kleidos::.vault:: backup:: importAll
- Returns
- The matching Outcome.
outcomeStatus() #
HTTP status code for a finished restore.
Four distinct codes, so a client that reads nothing but the status line still branches correctly: 200 restored, 400 refused with the vault untouched, 500 for a device failure, 422 for a file this device could only partly represent.
422 rather than 500 for the last one is the deliberate part. 500 is this file's promise that the DEVICE failed, and for a refused entry nothing did: every write landed and the device is healthy, so a 500 would send the owner (and any log reader) hunting a fault that is not there. It is also not a 2xx, although the request was processed: the vault was replaced by something other than what the file describes, and a portal that reads 2xx as success would congratulate the owner on a restore that silently dropped entries. 422 "Unprocessable Content" is exactly the remaining case — the request was well-formed and authorized, and its content could not be fully acted upon.
- Parameters
-
Name Direction Meaning outcome in The outcome to map.
- Returns
- 200 when restored, 400 when the backup was rejected (the client sent something this device cannot read), 500 when a write failed part-way (the request was fine; the DEVICE failed, and destructively), 422 when the vault was replaced and entries outside this device's record grammar were dropped, or the device filled up and the backup's last entries were left out (nothing failed; the file is what it is).
overflowed() #
True when member index of bound was clamped.
- Parameters
-
Name Direction Meaning bound in What the object held. index in The member.
- Returns
- Whether its text was longer than its field.
parseCsvCredentialLine() #
Parse one CSV line into a Credential (name, user, pass, url) using RFC 4180 quoting.
Leading and trailing whitespace / CR / LF are stripped before tokenising. An empty line or a line whose first (name) field is empty returns false. Extra columns beyond the fourth are silently discarded.
- Parameters
-
Name Direction Meaning line in Start of the CSV line (need not be NUL-terminated). length in Length of the line in bytes. credential out Receives the parsed fields; zero-initialized on entry.
- Return values
-
Value Meaning true At least the name field was non-empty; credential is populated. false Empty line or empty name field; credential is unmodified.
- Warning
- SECURITY: parses user-uploaded CSV. The caller MUST zeroize
credential.pass(and the other fields) after use.
parseImportItem() #
Decode and validate one normalized item.
Field semantics: name is mandatory; user/url/notes default to empty; over-long text fields are clamped to the vault's field capacities and reported. A missing or empty pass is refused per-item unless generateMissing is set, in which case ParsedImportItem::
- Parameters
-
Name Direction Meaning item in, out The bound item; its TOTP secret text is wiped once decoded (web:: totpfield:: parseTotpField). bound in What the item object held. arrays in Its custom, urls and history entries. generateMissing in The request-level generation opt-in. out out Receives the decoded item; wiped first.
- Returns
- nullptr when the item is importable, else a static per-item refusal text (the batch continues — one bad row never sinks the request).
parseOtpauthUri() #
Parse an otpauth:// URI into entry.
Fields the caller already populated win over the URI: a JSON request that named the entry keeps that name even when the link carries an issuer.
- Parameters
-
Name Direction Meaning uri in NUL-terminated URI. entry in, out Receives secret, digits, period, algorithm; name and account only when still empty.
- Return values
-
Value Meaning nullptr Parsed. !nullptr Static refusal text.
parseTotpField() #
Decode the optional "totp" field of a credential-write body.
Implements the shared wire contract: an omitted field preserves the stored TOTP, an explicit null detaches it, and an object sets it. Inside the object, secret accepts base32 or a full otpauth:// URI (URI parameters win over the sibling digits/period/algorithm fields). An object with no (or an empty) secret keeps the stored secret when one exists and adjusts only the parameters. A member of the wrong JSON type never reaches here: the binder refuses the body.
- Parameters
-
Name Direction Meaning member in, out The "totp" member as bound; its secret text is wiped once decoded. hasStoredSecret in Whether a stored TOTP secret exists to fall back on when the object omits secret. entry in, out Pre-filled by the caller with the stored TOTP (or defaults); updated in place on Set.
- Returns
- Decision + optional static error text (see FieldParse).
- Warning
- SECURITY: the caller wipes
entry.
passphraseAccepted() #
Whether surface can collect a new passphrase (a body without pin_length).
The secret the portal sets must be one the board's own entry can type again: a keyboard and the touch keypad's letter layer can, a dial cannot.
- Parameters
-
Name Direction Meaning surface in The board's entry surface.
- Returns
- false on the dial.
percentDecode() #
Decode XX escapes of a URI component (forwards to TotpGenerator).
- Parameters
-
Name Direction Meaning in in Component start (not necessarily NUL-terminated). inLen in Component length in bytes. out out Receives the decoded text, always NUL-terminated. outCap in Capacity of outin bytes, including the NUL.
pinLengthAccepted() #
Whether a requested pin_length is one surface takes.
- Parameters
-
Name Direction Meaning surface in The board's entry surface. requested in The decoded field (any int; negative or past a byte refuses).
- Returns
- true when
security::takespin_ policy:: newPinLengthAllowed requestedonsurface.
pinLengthRefusal() #
The refusal for a pin_length surface does not take.
- Parameters
-
Name Direction Meaning surface in The board's entry surface.
- Returns
- A JSON body naming the lengths
surfacetakes.
present() #
True when member index of bound is in the object, even as null.
- Parameters
-
Name Direction Meaning bound in What the object held. index in The member.
- Returns
- Whether the key was there.
readWriteParams() #
Read and judge the digits and period of a TOTP write body.
Writes are strict: a present field must be a JSON integer that is 6 or 8 (digits) or 30 or 60 (period), and anything else (a string such as "8", a fraction, a boolean, a null, an array, an object) is refused with the same ::
- Parameters
-
Name Direction Meaning body in The write body. len in Its bytes.
- Returns
- The two fields, their presence and the refusal body, if any.
redirectTarget() #
Where a request is redirected to reach the panel.
Absolute while the portal has an address to name, because the request that needs the redirect most is a captive-portal probe for some other host entirely, and a relative target would resolve against that host rather than against us. With no address to name — or no room to write one — the target is kSelfPath, which resolves against whatever authority the client used.
- Parameters
-
Name Direction Meaning out out Buffer the absolute URL is written into. capacity Bytes available in out, NUL included.address The address the transport reports.
- Returns
outholdinghttp://<address>/, or kSelfPath.
refusalBody() #
JSON error body for a refusal.
- Parameters
-
Name Direction Meaning refusal in The refusal to map.
- Returns
- A static JSON body naming what the client must fix;
nullptrfor Refusal::None.
refusalStatus() #
HTTP status code for a refusal.
- Parameters
-
Name Direction Meaning refusal in The refusal to map.
- Returns
- 413 for the size refusal, 400 for the secret-shape refusals, 200 for Refusal::None (the caller proceeds; nothing is sent).
rollbackPending() #
Whether the running image is still on rollback trial.
Only PendingVerify means the bootloader would revert on the next reset; every other state — including Undefined on builds without rollback bookkeeping — reads as confirmed, because claiming a pending rollback that does not exist would tell the owner their firmware is on trial when it is not.
- Parameters
-
Name Direction Meaning state in Running-partition OTA state from the platform facade.
- Return values
-
Value Meaning true The image boots on trial; an unconfirmed reset rolls back. false The image is confirmed (or the state is not tracked).
seedLost() #
Whether an edit loses the stored seed.
- Parameters
-
Name Direction Meaning storedSeed in The record holds a seed now. write in What the body does to it.
- Return values
-
Value Meaning true A stored seed is detached or replaced. false Nothing stored, or the seed stays.
selectBuildFlavor() #
Resolve the build flavor from the four build-time predicates.
The order is most-specific-first and is load-bearing: a hardened build also sets the release flag, and its bench twin also sets the hardened flag, so a ladder that tested release before secure would report "release" on hardened firmware. The web page raises its "you are running a debug build" warning off this value, so the Debug arm has to win over everything else as well.
- Parameters
-
Name Direction Meaning debugBuild in True when the serial-console debug build flag is set. secureDev in True when the bench DEV-mode secure flag is set. secure in True when the hardened secure flag is set. release in True when the open-production release flag is set.
- Returns
- The most specific flavor the predicates describe.
stageLabel() #
One-word stage of the last/current OTA attempt for the status row.
- Parameters
-
Name Direction Meaning attempt in Live upload state.
- Returns
"idle"(nothing attempted),"uploading"(streaming now),"success"or"failed"(finished). A finished attempt wins over a stale active flag so a torn snapshot never reports both.
streamTelemetryBody() #
Emit the GET /api/telemetry body through a chunk sink.
Same bytes as ::sink as scratch fills, so the caller's memory cost is scratchBytes regardless of how much history the body carries. Because a flushed chunk cannot be recalled, the stride is settled by a dry run first and the body is written exactly once.
- Parameters
-
Name Direction Meaning in in Run state and oldest-first ring snapshot. scratch out Rolling window the sink is fed from. scratchBytes in Size of scratchin bytes, including the NUL slot.sink in Chunk destination. sinkCtx in Opaque context handed back to sink.
- Returns
- Total body length, applied stride, and whether the whole body reached the sink.
stringLost() #
Whether writing next over a single-string pool entry loses it.
Nothing stored is not a loss (adding is not destroying); the same text written back is not a loss either.
- Parameters
-
Name Direction Meaning stored in The record's pool before the edit. type in A single-string entry type (notes, recovery codes). next in The text the body writes; nullptr reads as empty.
- Return values
-
Value Meaning true A stored, non-empty value would be replaced or removed. false Nothing is lost.
takeCustom() #
A custom entry closed: kept while the record has room for it.
- Parameters
-
Name Direction Meaning user in The ImportPass. element in The entry's CustomBody. bound in Which of its members it carried.
- Returns
- Always true: a surplus entry is dropped, never refused.
takeHistory() #
A history entry closed: one with no password records nothing; the first ones the record holds are kept.
- Parameters
-
Name Direction Meaning user in The ImportPass. element in The entry's HistoryBody. bound in Which of its members it carried.
- Returns
- Always true.
takeItem() #
An item closed: handed on with its arrays, which are then forgotten.
- Parameters
-
Name Direction Meaning user in The ImportPass. element in The item's ImportItemBody. bound in Which of its members it carried.
- Returns
- What the pass's item hook returned; true when it only counts.
takeUrl() #
A urls entry arrived: an empty one is not one; the first ones the record holds are kept, the rest dropped.
- Parameters
-
Name Direction Meaning user in The ImportPass. entry in The entry's text.
- Returns
- Always true.
toHexLower() #
Write byteCount bytes as lowercase hex into dst (NUL-terminated).
- Parameters
-
Name Direction Meaning dst out Destination buffer; needs byteCount*2+1bytes.bytes in Source bytes. byteCount in Number of bytes to format.
unsignedOrZero() #
value read as a field of 32 unsigned bits: out of that width it reads 0, as a default-or-value read always did.
- Parameters
-
Name Direction Meaning value in The bound integer.
- Returns
- The field's value.
validateItemCount() #
Judge the size of the items array of POST /api/import/items.
- Parameters
-
Name Direction Meaning count in Entries the array held (0 when absent or null).
- Returns
- nullptr when it is importable, else a static refusal text (the whole request is answered 400 — nothing was imported yet).
verifyBasicAuth() #
Validate an HTTP Basic-Auth header value against the derived OTA password.
Expects authHeaderValue shaped "Basic base64(\"admin:<password>\")". Decoding, the username comparison and the password comparison are all length-validated and constant-time. The decoded scratch buffer is zeroized before returning.
- Parameters
-
Name Direction Meaning authHeaderValue in The raw Authorizationheader value, ornullptr.expectedPassword in NUL-terminated expected password; must be non-empty.
- Return values
-
Value Meaning true Header is present, well-formed, user is "admin", password matches.false Otherwise.
- Warning
- SECURITY: a false positive lets an attacker on the admin WiFi push arbitrary firmware. Keep the comparisons constant-time.
Variable Documentation
kAccountFieldBytes #
Room for the account label past its stored column, so a longer one is cut to the column as the stored copy cuts it, and reported.
kBackupCarriedMetaB64MaxBytes #
Longest meta string a restore here reads, from any board: the element budget the restore holds every member of the document to. A backup carries the meta of the board that WROTE it, whose generation tables are sized by that board's capacities, so a bound taken from this board's own record would refuse a backup from a bigger board that fits here record for record.
kBackupCredentialMaxBytes #
Worst-case serialized size of one credential row: the four fixed text fields at their caps plus the WHOLE pool budget (notes, custom fields, recovery codes, extra URLs, SSO provider and history share it), every byte escaped, embedded TOTP present. (kBackupCredFixedOverhead already carries the base64 TOTP secret.)
kBackupCredFixedOverhead #
Ceiling for one credential row's fixed JSON scaffolding: its key names with quotes/
kBackupEnvelopeFixedOverhead #
Envelope scaffolding outside the arrays: version, the four top-level keys, braces/
kBackupMetaB64Bytes #
Base64 length of the exported meta record (its size scales with the generation tables, i.e. with this board's slot capacities).
kBackupTotpFixedOverhead #
Counted ceiling for one standalone-TOTP row's fixed JSON scaffolding (6 keys, braces, numeric maxima, quoted algorithm) — 110 counted, rounded up.
kClockNotSyncedJson #
Body paired with ::
kClockUnsetJson #
Body paired with ::
kClockUnsetPreciseJson #
Body paired with ::
kCodeBodyReserve #
Room for the longest live-code body, reserved once so the string that holds the code never grows into a fresh block and frees the old one unwiped.
kColumnSlack #
Room a staged text keeps past the record column it is copied into. The binder clamps on whole code points; the record cuts by bytes, as it always has. One code point of room (at most four bytes) means the staged head is always longer than the column, so the record's byte cut, not the binder's, decides where a long name, user, password or URL ends.
kFrameCap #
The most bytes a restore body's secrets frame may take.
A restore body is the frame and then the backup. The frame is one line: the blank lead-in (bodycap::current and, on the encrypted route, the backup passphrase as passphrase, and a line feed. JSON text cannot hold a raw line feed, so the first one ends the frame. The bound holds the lead-in and both secrets at their caps with every character escaped as a six-byte \uXXXX sequence, with room to spare.
kGeneratedPassLen #
Length of an on-device generated password for a passwordless item: the one a CSV import by card mints (kleidos::
kImportBodyCap #
Request-body cap in bytes (32 normalized items fit comfortably), after the page's blank lead-in.
kMaxArrayEntries #
Most entries an array of the import or the credential save may carry: the body caps bound them long before, and what is past what a record holds is dropped or refused by the route, never by the binder.
kPassphraseRefusal #
The body of the refusal for a new passphrase on a board that dials its PIN: a dial collects digits only, so the vault could never be opened again.
kPinLengthRefusal #
The body of the refusal for a pin_length this surface does not take, in security:: order.
kRestoreBodyCapBytes #
Body cap for POST /api/restore — the largest plaintext backup any board writes: as many records as the biggest board has slots, each at its schema maximum, under the longest meta any board's backup carries.
A backup bigger than this device is not refused for its size: the restore takes its first entries in its own order and counts the rest (backup::
That is 12,394,162 bytes (about 11.82 MiB) on every board, computed by the compiler from the field constants and the largest slot counts of any board (500 credentials and 50 one-time codes), so raising either moves it.
kRestoreEncryptedBodyCapBytes #
Body cap for POST /api/restore/encrypted — the plaintext bound wrapped in the .kexp envelope (header, one framed and tagged chunk per 4 KB of plaintext, PKCS#7 padding up to one AES block).
kSecretFieldBytes #
Room for a base32 secret or a whole otpauth:// URI; a longer text refuses the body.
kTotpBodySecret #
Index of each member in kTotpBodyMembers.
secret.
kWideIntBound #
Wide enough for any integer a client sends: a value out of a field's width is judged by the field, never refused as a body.