Kleidos API Search

In development. It changes without notice.

Topic

Record Repositories

The store of each kind of record: logins, one-time-code secrets and saved networks, with the names of the groups and the order of the lists.

Files

file src/vault/credential_order.h
Sparse label algebra for the record-owned custom list order.
file src/vault/credential_repository.h
The credential record: one fixed size, encrypt-then-MAC, in the log.
file src/vault/credential_sort.h
Favorite-first + manual-order sorting for the device credential lists.
file src/vault/group_table.h
Single encrypted group-name table (groups.bin).
file src/vault/totp_repository.h
The TOTP record: one entry of the record log, encrypt-then-MAC.
file src/vault/wifi_repository.h
Self-contained, encrypt-then-MAC WiFi/NTP config store (wifi.bin).

Classes

struct kleidos::vault::ReorderBuffers
Caller-owned working arrays of planReorder. More about kleidos::vault::ReorderBuffers
struct kleidos::vault::ReorderPlanStats
What a plan cost, so a caller can report it and a test can measure it. More about kleidos::vault::ReorderPlanStats
struct kleidos::vault::TotpData
An optional TOTP embedded in a credential (storage only). More about kleidos::vault::TotpData
struct kleidos::vault::CredentialRecord
A single credential's plaintext fields (bounded, heap-free). More about kleidos::vault::CredentialRecord
class kleidos::vault::CredentialSlotPresence
Presence of every credential slot, resolved once. More about kleidos::vault::CredentialSlotPresence
class kleidos::vault::CredentialRepository
Reads, writes and deletes the credential records of the record log. More about kleidos::vault::CredentialRepository
struct kleidos::vault::GroupRow
One group-name row (id in 1..kMaxGroups + bounded display name). More about kleidos::vault::GroupRow
class kleidos::vault::GroupTable
The encrypted group-name table on LittleFS. More about kleidos::vault::GroupTable
struct kleidos::vault::TotpRecord
A single TOTP entry's plaintext fields (bounded, heap-free). More about kleidos::vault::TotpRecord
class kleidos::vault::TotpSlotPresence
One walk's answer to "which TOTP slots hold a record". More about kleidos::vault::TotpSlotPresence
class kleidos::vault::TotpRepository
Self-contained TOTP record CRUD over the log. More about kleidos::vault::TotpRepository
struct kleidos::vault::WifiNetworkRecord
A single saved WiFi network (bounded, heap-free). More about kleidos::vault::WifiNetworkRecord
struct kleidos::vault::WifiStoreData
The whole decrypted wifi.bin payload (bounded, heap-free). More about kleidos::vault::WifiStoreData
class kleidos::vault::WifiRepository
Self-contained WiFi/NTP config file CRUD on LittleFS. More about kleidos::vault::WifiRepository

Typedefs

usingkleidos::vault::CredentialSlotMask
usingkleidos::vault::TotpSlotMask
Presence of every TOTP slot, one bit per slot.
usingkleidos::vault::NtpServerText
One user-configured NTP server (a literal dotted-quad IPv4 string).

Enumerations

enum class kleidos::vault::GroupTableRemoval : uint8_t { kleidos::vault::GroupTableRemoval::Removed , kleidos::vault::GroupTableRemoval::Absent , kleidos::vault::GroupTableRemoval::Failed }
What a whole-table removal actually established. More about kleidos::vault::GroupTableRemoval

Functions

constexpr uint16_tkleidos::vault::orderStrideFor (uint16_t slots)
The gap a seeded run leaves between consecutive ranks.
constexpr uint16_tkleidos::vault::orderSeedLabel (uint16_t rank)
The label of rank rank in a freshly seeded run (0-based).
constexpr uint16_tkleidos::vault::orderAfter (uint16_t highWater)
The label a newly created record takes, given the highest one in use.
constexpr boolkleidos::vault::orderMidpoint (uint16_t lower, uint16_t upper, uint16_t &out)
The label strictly between two neighboring labels, if there is one.
constexpr uint32_tkleidos::vault::orderPlanWorstCaseMs (uint16_t rows, uint16_t writes)
constexpr boolkleidos::vault::orderPlanFitsOneRequest (const ReorderPlanStats &stats)
ReorderPlanStatskleidos::vault::planReorder (ReorderBuffers &buffers, uint16_t count)
Turn a requested ranking into the record writes that realize it, as few as the stored labels allow.
ReorderPlanStatskleidos::vault::planReseed (ReorderBuffers &buffers, uint16_t count)
Spread a ranking over the whole label space again, row by row.
constexpr boolkleidos::vault::credentialMaskHas (const CredentialSlotMask &mask, uint16_t id)
Read a slot's bit out of a CredentialSlotMask.
boolkleidos::vault::credentialListedBefore (const CredentialEntry &a, const CredentialEntry &b)
Strict ordering predicate: must a be listed above b?
voidkleidos::vault::sortCredentialEntries (CredentialEntry *entries, uint16_t count)
Stable in-place sort of a loaded credential list.
constexpr boolkleidos::vault::totpMaskHas (const TotpSlotMask &mask, uint8_t id)
True when mask marks slot id present.

Variables

constexpr uint16_tkleidos::vault::kOrderMin
Lowest label a record may carry.
constexpr uint16_tkleidos::vault::kOrderMax
Highest label a record may carry (::kCredOrderUnset is one above it).
constexpr uint16_tkleidos::vault::kOrderStride
Gap between consecutive ranks of a seeded run on THIS build.
constexpr uint16_tkleidos::vault::kOrderRenumberMaxRows
constexpr uint32_tkleidos::vault::kOrderWriteWorstCaseMs
constexpr uint32_tkleidos::vault::kOrderRowReadWorstCaseMs
constexpr uint16_tkleidos::vault::kOrderNoRank
Rank index meaning "no predecessor" inside the planner's link table.
constexpr uint32_tkleidos::vault::kOrderBoundedPlanWorstCaseMs
constexpr uint16_tkleidos::vault::kMaxCredentialSlots
Maximum number of credential slots.
constexpr uint16_tkleidos::vault::kLargestBoardCredentialSlots
constexpr uint16_tkleidos::vault::kFleetMaxCredentialSlots
constexpr uint16_tkleidos::vault::kInvalidSlot
The "no credential slot" sentinel of every board (never a valid slot id).
constexpr size_tkleidos::vault::kCredNameLen
Max credential name length.
constexpr size_tkleidos::vault::kCredUserLen
Max username length.
constexpr size_tkleidos::vault::kCredPassLen
Max password length.
constexpr size_tkleidos::vault::kCredUrlLen
Max primary-URL length.
constexpr size_tkleidos::vault::kCredTotpMaxSecretLen
Max raw embedded-TOTP secret length, in bytes (mirrors kTotpMaxSecretLen).
constexpr size_tkleidos::vault::kCredTotpAccountLen
Max embedded-TOTP account label length (mirrors kTotpAccountLen).
constexpr uint16_tkleidos::vault::kCredFlagAutoSubmit
constexpr uint16_tkleidos::vault::kCredFlagFavorite
CredentialRecord::flags: pinned to the top of the list.
constexpr uint16_tkleidos::vault::kCredFlagRePromptPin
CredentialRecord::flags: ask for the secret again before typing this one.
constexpr uint16_tkleidos::vault::kCredFlagArchived
CredentialRecord::flags: kept but out of the way — hidden from the default list.
constexpr uint16_tkleidos::vault::kCredFlagAuditExcluded
CredentialRecord::flags: left out of password-health reporting.
constexpr uint16_tkleidos::vault::kCredFlagWebOnly
CredentialRecord::flags: managed in the web panel only, never shown on the device.
constexpr uint8_tkleidos::vault::kCredGroupNone
CredentialRecord::group value meaning "no group".
constexpr uint16_tkleidos::vault::kCredOrderUnset
CredentialRecord::order value meaning "no explicit position in the list".
constexpr uint8_tkleidos::vault::kCredFormatVersion
Current credential-file format version.
constexpr size_tkleidos::vault::kCredVerOffset
Field offsets within a serialized credential record.
constexpr size_tkleidos::vault::kCredHeaderSize
Size of the fixed-length header (everything before the ciphertext).
constexpr size_tkleidos::vault::kCredMinFileSize
Smallest valid file: header + one AES block of ciphertext.
constexpr uint8_tkleidos::vault::kCredPlaintextVer
Record-schema version of the packed-binary credential plaintext.
constexpr size_tkleidos::vault::kCredTotpBlockBytes
constexpr size_tkleidos::vault::kCredFixedFieldBytes
constexpr size_tkleidos::vault::kCredMaxPlaintextSize
Plaintext every credential encodes to, padded with zeros to exactly this.
constexpr size_tkleidos::vault::kCredMaxCipherSize
Ciphertext size (AES-CBC adds one full PKCS#7 block to a block-aligned input).
constexpr size_tkleidos::vault::kCredMaxFileSize
Whole-envelope size — a constant, like everything else about a record.
constexpr uint8_tkleidos::vault::kMaxGroups
constexpr size_tkleidos::vault::kGroupNameLen
Max group-name length (one wire row is 1 id + 1 prefix + 24 name = 26 B).
constexpr const char *kleidos::vault::kGroupPath
Canonical group-table file path, spelled by vault_paths.h.
constexpr uint8_tkleidos::vault::kGroupFormatVersion
Current group-file format version.
constexpr size_tkleidos::vault::kGroupHeaderSize
Size of the fixed-length header (mirrors the other vault files).
constexpr size_tkleidos::vault::kGroupMinFileSize
Smallest valid file: header + one AES block of ciphertext.
constexpr uint8_tkleidos::vault::kGroupPlaintextVer
Record-schema version of the packed-binary group plaintext.
constexpr size_tkleidos::vault::kGroupRowMaxSize
Worst-case packed-binary size of one row: id(1) + name (1 + 24) = 26 bytes.
constexpr size_tkleidos::vault::kGroupHeaderPlaintext
Fixed plaintext header: plaintextVer(1) + rowCount(1).
constexpr size_tkleidos::vault::kGroupMaxPlaintextSize
Worst-case plaintext size (every group defined at the full name length).
constexpr size_tkleidos::vault::kGroupMaxCipherSize
Worst-case ciphertext size (one extra block for PKCS#7 padding).
constexpr size_tkleidos::vault::kGroupMaxFileSize
Worst-case whole-file size.
constexpr size_tkleidos::vault::kGroupDefinedMaskBytes
Bytes of the "this id still has a label" bitmap (bit k = id k+1).
constexpr uint8_tkleidos::vault::kMaxTotpSlots
Maximum number of TOTP slots.
constexpr uint8_tkleidos::vault::kInvalidTotpSlot
constexpr uint8_tkleidos::vault::kLargestBoardTotpSlots
constexpr uint8_tkleidos::vault::kFleetMaxTotpSlots
constexpr size_tkleidos::vault::kTotpNameLen
Max TOTP display-name length.
constexpr size_tkleidos::vault::kTotpMaxSecretLen
Max raw secret length, in bytes.
constexpr size_tkleidos::vault::kTotpAccountLen
Max account-label length.
constexpr uint8_tkleidos::vault::kTotpFormatVersion
Current TOTP-envelope format version.
constexpr size_tkleidos::vault::kTotpVerOffset
Field offsets within a serialized TOTP envelope.
constexpr size_tkleidos::vault::kTotpHeaderSize
Size of the fixed-length header (everything before the ciphertext).
constexpr size_tkleidos::vault::kTotpMinFileSize
Smallest valid file: header + one AES block of ciphertext.
constexpr uint8_tkleidos::vault::kTotpPlaintextVer
Record-schema version of the packed-binary TOTP plaintext.
constexpr size_tkleidos::vault::kTotpMaxPlaintextSize
constexpr size_tkleidos::vault::kTotpMaxCipherSize
Worst-case ciphertext size (one extra block for PKCS#7 padding).
constexpr size_tkleidos::vault::kTotpMaxFileSize
Worst-case whole-file size.
constexpr uint8_tkleidos::vault::kMaxWifiNetworks
Maximum number of saved WiFi networks.
constexpr size_tkleidos::vault::kWifiSsidLen
Max SSID length (802.11), in bytes.
constexpr size_tkleidos::vault::kWifiPskLen
Max WPA passphrase length, in bytes.
constexpr size_tkleidos::vault::kWifiPskMinLen
Minimum WPA passphrase length; a zero-length PSK means an open network.
constexpr uint8_tkleidos::vault::kMaxNtpServers
Maximum user-configured NTP server entries (mirrors the default table size).
constexpr size_tkleidos::vault::kNtpServerTextLen
Max NTP-server text length: a literal dotted-quad IPv4 ("255.255.255.255").
constexpr const char *kleidos::vault::kWifiPath
constexpr uint8_tkleidos::vault::kWifiFormatVersion
Current WiFi-file format version (shared envelope version byte).
constexpr size_tkleidos::vault::kWifiVerOffset
Field offsets within the serialized file (identical geometry to totp/index).
constexpr size_tkleidos::vault::kWifiHeaderSize
Size of the fixed-length header (everything before the ciphertext).
constexpr size_tkleidos::vault::kWifiMinFileSize
Smallest valid file: header + one AES block of ciphertext.
constexpr uint8_tkleidos::vault::kWifiPlaintextVer
constexpr size_tkleidos::vault::kWifiMaxPlaintextSize
constexpr size_tkleidos::vault::kWifiMaxCipherSize
Worst-case ciphertext size (one extra block for PKCS#7 padding).
constexpr size_tkleidos::vault::kWifiMaxFileSize
Worst-case whole-file size.

Back to the top

Typedef Documentation

CredentialSlotMask #

using kleidos::vault::CredentialSlotMask

One presence bit per credential slot, so a whole-vault answer costs one directory read instead of one lookup per declared slot.

TotpSlotMask #

using kleidos::vault::TotpSlotMask

Presence of every TOTP slot, one bit per slot.

Fixed width: ceil(kMaxTotpSlots / 8), so it is 32 bytes at the widest slot space the u8 id space allows and a handful at every shipped capacity. Small enough to live on the vault worker's stack at any capacity, which is the property that lets the whole scan be a value rather than an allocation.

It is DERIVED, never stored: it is filled by a scan of the log at the moment of use and discarded with the walk that asked for it, so it cannot become a second source of truth that disagrees with the records.

Back to the top

Enumeration Type Documentation

GroupTableRemoval #

enum class kleidos::vault::GroupTableRemoval : uint8_t

What a whole-table removal actually established.

Three-valued because the two ways a removal does not leave a file behind are different answers to the caller: "there was nothing to remove" is the ordinary fresh-device state, while "the removal did not take" means a table MAY still be on flash. A full-replace restore that folds them writes its labels on top of the previous ones and reports a replacement it did not make.

Enumerator
Removed 

A table was there and is now gone.

Absent 

There was no table to remove.

Failed 

The removal did not take; a table may still be on flash.

Back to the top

Function Documentation

credentialListedBefore() #

bool kleidos::vault::credentialListedBefore(const CredentialEntry & a, const CredentialEntry & b)
inline

Strict ordering predicate: must a be listed above b?

Favorites come first; inside each group the order label ranks rows ascending. An unranked row's label is kleidos::vault::kCredOrderUnset (0xFFFF), which sits immediately above the label space, so those rows sink below every explicitly ranked one without a special case — as do the standalone TOTP rows the list synthesizes at that same value. Rows that compare equal (same favorite flag, same label) are left in their original relative order by the stable sort.

Parameters
NameDirectionMeaning
ainCandidate for the higher list position.
binEntry compared against.
Return values
ValueMeaning
truea precedes b.
falsea does not precede b (equal ranks included).

credentialMaskHas() #

bool kleidos::vault::credentialMaskHas(const CredentialSlotMask & mask, uint16_t id)
constexpr

Read a slot's bit out of a CredentialSlotMask.

Parameters
NameDirectionMeaning
maskinMask filled by CredentialRepository::scanPresentSlots.
idinSlot id in [0, kMaxCredentialSlots).
Returns
Whether the slot's bit is set.

orderAfter() #

uint16_t kleidos::vault::orderAfter(uint16_t highWater)
constexpr

The label a newly created record takes, given the highest one in use.

Appends after the last ranked row. Saturates at ::kOrderMax rather than wrapping: a create must stay one record write, so exhausting the tail is handled by the next reorder's renumber, not by relabelling inside a save.

Parameters
NameDirectionMeaning
highWaterinHighest label currently in use (::kOrderMin when none).
Returns
The new record's label.

orderMidpoint() #

bool kleidos::vault::orderMidpoint(uint16_t lower, uint16_t upper, uint16_t & out)
constexpr

The label strictly between two neighboring labels, if there is one.

The two-label form of what planReorder does with runs: the planner spreads a whole run evenly across its free labels at once, so this is the primitive stated on its own for a caller placing a single row.

Parameters
NameDirectionMeaning
lowerinLabel of the row above the insertion point.
upperinLabel of the row below it.
outoutReceives the midpoint when one exists.
Return values
ValueMeaning
trueA free label exists and out holds it.
falseThe two labels are adjacent (or inverted): renumber instead.

orderPlanFitsOneRequest() #

bool kleidos::vault::orderPlanFitsOneRequest(const ReorderPlanStats & stats)
constexpr

Whether one REQUEST may carry this plan out.

The whole plan runs inside a single blocking call on the vault worker, so its wall clock is what the caller waits for. A plan above the cap is refused with nothing written rather than started: a client that gives up half way leaves the device writing a ranking nobody is reading, and the same ranking is then re-posted onto a list that has moved under it.

Parameters
NameDirectionMeaning
statsinWhat the plan costs.
Return values
ValueMeaning
trueThe request path may carry this plan out.
falseThe plan is wider than the cap and must be refused with nothing written.

orderPlanWorstCaseMs() #

uint32_t kleidos::vault::orderPlanWorstCaseMs(uint16_t rows, uint16_t writes)
constexpr

Milliseconds a plan over rows rows that writes writes records is bounded by: the whole-list read that every plan makes BEFORE its first write, plus the write loop. Charging the writes alone is what leaves a client abandoning a device that is still working.

Parameters
NameDirectionMeaning
rowsinRows the plan reads — every row the vault holds, whatever the ranking's length.
writesinRecords the plan writes.
Returns
The bound in milliseconds.

orderSeedLabel() #

uint16_t kleidos::vault::orderSeedLabel(uint16_t rank)
constexpr

The label of rank rank in a freshly seeded run (0-based).

Parameters
NameDirectionMeaning
rankin0-based position in the ranking.
Returns
(rank + 1) * kOrderStride, never ::kCredOrderUnset.

orderStrideFor() #

uint16_t kleidos::vault::orderStrideFor(uint16_t slots)
constexpr

The gap a seeded run leaves between consecutive ranks.

The largest power of two that keeps a full run of slots inside the lower half of the label space. Halving twice per capacity step is deliberate: the exponent is the number of repeated insertions at ONE fixed point that the midpoint rule absorbs before a renumber becomes necessary, and a power of two makes every midpoint exact.

Parameters
NameDirectionMeaning
slotsinCredential slot capacity of the build.
Returns
The stride, at least 1.

planReorder() #

ReorderPlanStats kleidos::vault::planReorder(ReorderBuffers & buffers, uint16_t count)
inline

Turn a requested ranking into the record writes that realize it, as few as the stored labels allow.

buffers.label arrives holding each rank's STORED label in requested rank order and leaves holding the label that rank must end up with; buffers.changed marks the ranks whose record has to be written.

The plan is computed in full before any of it is applied, so a rank whose label is revised twice here still costs ONE record write — the property that keeps a reorder inside the index's generation-lag repair window — and none at all when the second revision puts it back on the label it already carries.

Parameters
NameDirectionMeaning
buffersin, outWorking arrays; see ReorderBuffers.
countinRanks in the requested ranking (<= kMaxCredentialSlots).
Returns
What the plan cost; see ReorderPlanStats.

planReseed() #

ReorderPlanStats kleidos::vault::planReseed(ReorderBuffers & buffers, uint16_t count)
inline

Spread a ranking over the whole label space again, row by row.

planReorder writes as few records as the gaps allow, which is what a move wants and the opposite of what the maintenance action wants: posting the ranking the stored labels already realize keeps every row, writes nothing, and leaves the crowding that refused the move exactly where it was. This plans the LABELS instead — rank r takes orderSeedLabel(r), whatever it carried — so the gaps are back and ordinary moves cost one record again. A row already on its seed label costs no write.

Parameters
NameDirectionMeaning
buffersin, outWorking arrays; only label and changed are used.
countinRanks in the requested ranking (<= kMaxCredentialSlots).
Returns
What the plan cost; see ReorderPlanStats.

sortCredentialEntries() #

void kleidos::vault::sortCredentialEntries(CredentialEntry * entries, uint16_t count)
inline

Stable in-place sort of a loaded credential list.

Insertion sort keyed by credentialListedBefore. Chosen over std::stable_sort because it allocates nothing (the library stable sort may reach for a temporary buffer) and the list is small and already almost sorted on reload, where insertion sort is near-linear.

Parameters
NameDirectionMeaning
entriesin, outArray filled by VaultStore::loadIndex.
countinNumber of valid entries in entries.

totpMaskHas() #

bool kleidos::vault::totpMaskHas(const TotpSlotMask & mask, uint8_t id)
constexpr

True when mask marks slot id present.

Parameters
NameDirectionMeaning
maskinPresence mask from TotpRepository::scanPresentSlots.
idinSlot id; anything outside [0, kMaxTotpSlots) reads absent.
Returns
Whether the slot's record was seen by the scan that filled mask.

Back to the top

Variable Documentation

kCredFixedFieldBytes #

size_t kleidos::vault::kCredFixedFieldBytes
inlineconstexpr

The fixed part's size, as an auditable sum of its fields. Every string is stored at its FULL capacity behind a length prefix, so the sum is what the encoder emits for every record — that is what makes the plaintext size a constant and the capacity exact.

kCredFlagAutoSubmit #

uint16_t kleidos::vault::kCredFlagAutoSubmit
inlineconstexpr

CredentialRecord::flags: BLE combo typing appends ENTER after the password (auto-submit). Clear = the user submits the form manually.

kCredTotpBlockBytes #

size_t kleidos::vault::kCredTotpBlockBytes
inlineconstexpr

Bytes the embedded-TOTP block always occupies in the fixed part: secretLen(1) + secret(64) + digits(1) + period(2) + algorithm(1)

  • accountLen(1) + account(64)

. A zero secretLen means "no TOTP", so the block needs no presence byte of its own.

kFleetMaxCredentialSlots #

uint16_t kleidos::vault::kFleetMaxCredentialSlots
inlineconstexpr

The most credentials a backup from any board can hold: the biggest boards' slots, or this build's own where a capacity-probe build raises it past them. A restore takes a bigger backup's first entries and counts the rest (backup::OverCapacity), so what it must be ready to READ is bounded by this and never by its own slots.

kFleetMaxTotpSlots #

uint8_t kleidos::vault::kFleetMaxTotpSlots
inlineconstexpr

The most one-time codes a backup from any board can hold (see kFleetMaxCredentialSlots).

kInvalidTotpSlot #

uint8_t kleidos::vault::kInvalidTotpSlot
inlineconstexpr

The id no TOTP slot has on any board: slot ids stay uint8_t by design (capacity <= 255 on every board) and this one is kept free, so the cap stays below it. A backup naming it, or anything past it, names no slot anywhere.

kLargestBoardCredentialSlots #

uint16_t kleidos::vault::kLargestBoardCredentialSlots
inlineconstexpr

Credential slots on the boards with the largest vault: the largest capacity any board declares, and a build check holds it there (which board has which: The boards).

kLargestBoardTotpSlots #

uint8_t kleidos::vault::kLargestBoardTotpSlots
inlineconstexpr

One-time-code slots on the boards with the largest vault: the largest one-time-code capacity any board declares, and a build check holds it there.

kMaxGroups #

uint8_t kleidos::vault::kMaxGroups
inlineconstexpr

Maximum number of groups. Ids are 1..kMaxGroups; 0 = "no group". The wire format is count-prefixed, so this capacity can change without migration.

kOrderBoundedPlanWorstCaseMs #

uint32_t kleidos::vault::kOrderBoundedPlanWorstCaseMs
inlineconstexpr

Worst case of the widest plan the REQUEST path may carry out, over a vault filled to this build's capacity, in milliseconds.

kOrderRenumberMaxRows #

uint16_t kleidos::vault::kOrderRenumberMaxRows
inlineconstexpr

Rows a bounded renumber may re-space in one operation, and the write cap the REQUEST path holds a whole plan to: 64 record writes and at most 64 segment rewrites.

The planner itself is not bounded by this — when no window up to this many rows has room, it falls through to re-seeding the whole ranking, and a left-to-right sweep can also spread a run of any length between two kept labels. Both are correct and both are unbounded in the vault's size, so a caller serving a request compares ReorderPlanStats::writes against this and refuses a plan above it rather than starting a write loop no client's timeout can cover. The whole re-space is reachable on its own, as an explicit maintenance action with the time bound stated up front; it is planReseed and not this planner, because the fewest-writes plan for a ranking the labels already realize is no writes at all.

kOrderRowReadWorstCaseMs #

uint32_t kleidos::vault::kOrderRowReadWorstCaseMs
inlineconstexpr

Worst case of reading ONE row's stored label, in milliseconds.

Every plan reads the whole list before its first write, and that read is not flat: it is one index-segment decrypt per 32 rows while the segments are on flash, and one 4 KB record read and decrypt per credential when they are not — the state a restore's anchor leaves behind. The expensive form is the one a bound has to cover. No measurement of a bare record read exists on the current record, so it is charged at the widest figure that CONTAINS one: the ESP32 board's rotation step, 990 ms, which is a read and a decrypt plus an encrypt, an append and a commit. Loose, and loose in the safe direction — a client that waits too long costs a page a spinner, one that waits too little abandons a device mid-write.

kOrderWriteWorstCaseMs #

uint32_t kleidos::vault::kOrderWriteWorstCaseMs
inlineconstexpr

Worst case of one list-column record write, in milliseconds.

A column write is a read-modify-write of the record plus the index upsert. The bound is taken over every board rather than the fastest: a rotation step (read, decrypt, re-encrypt, append, commit — everything but the upsert) was measured at 988 ms per record on an ESP32-S3 board and 990 ms on an ESP32 one, and a create (encode, encrypt, append, commit AND upsert) at 316 ms and 420 ms. The upsert's own cost has not been measured apart, so it is charged at the whole create: 990 + 420, the slowest of each. Conservative by construction — the two figures share their append and their commit — which is the right direction for a bound a client's timeout is derived from. A capacity of 500 credentials runs on an ESP32 board too, so a bound taken from an ESP32-S3 alone would be one some board breaks. The figures are open builds'; a flash-encrypted vault has not been measured for this bound.

kTotpMaxPlaintextSize #

size_t kleidos::vault::kTotpMaxPlaintextSize
inlineconstexpr

Worst-case packed-binary plaintext size, as an auditable sum of the per-field maxima. Layout (see record_codec.h and the wire table in the .cpp): ver(1) + name (1 + 32) + secretLen(1) + secret(64) + digits(1) + period(2)

  • algorithm(1) + account (1 + 64) = 1 + 33 + 1 + 64 + 1 + 2 + 1 + 65 = 168 bytes.

kWifiMaxPlaintextSize #

size_t kleidos::vault::kWifiMaxPlaintextSize
inlineconstexpr

Worst-case packed-binary plaintext, as an auditable sum of per-field maxima: ver(1) + netCount(1) + kMaxWifiNetworks * ( (1 + 32) ssid + (1 + 63) psk )

  • srvCount(1) + kMaxNtpServers * (1 + 15) = 2 + 8 * 97 + 1 + 4 * 16 = 843 bytes.

kWifiPath #

const char* kleidos::vault::kWifiPath
inlineconstexpr

Canonical singleton path of the WiFi-network store, spelled by vault_paths.h.

kWifiPlaintextVer #

uint8_t kleidos::vault::kWifiPlaintextVer
inlineconstexpr

Record-schema version of the packed-binary plaintext (it carries the NTP server list; one version, no migration).

Back to the top