In development. It changes without notice.
Topic
Pairing & Numeric Comparison
Who may pair, connect and receive keystrokes, and the prompt that compares six digits on both screens.
Pairing is LE Secure Connections only, with numeric comparison and a 16-byte encryption key. The six digits are shown by the board and by the other side, and the owner's answer on the board is what accepts the link. The prompt is held in one atomic value, so the screen's core never reads half of one.
Which central the board keeps once it connects is a rule of its own: with the pairing window open only one that is not bonded, and otherwise only a bonded one, or the one the send chose.
Files | |
| file | src/ |
| Which central the peripheral keeps once its link is up. | |
| file | src/ |
| Bond-eviction confirmation gate (full bond table — replace oldest?). | |
| file | src/ |
| Which of the host's stored records outlive a host sync: the sweep that removes what no bond owns. | |
| file | src/ |
| Pure HOGP link-security predicates: the bar a link meets, and a failed security start. | |
| file | src/ |
| LE Secure Connections Numeric Comparison prompt state, bound to its link and its number. | |
| file | src/ |
| Re-pairing confirmation gate: a bonded host pairs again only on the owner's Allow. | |
| file | src/ |
| What the host's keystore may keep: a key a numeric comparison confirmed, and no eviction. | |
Functions | |
| constexpr ConnectAdmission | kleidos:: |
| Whether, and why, the peripheral keeps a link a central just made. | |
| constexpr bool | kleidos:: |
| Whether the peripheral keeps a link a central just made. | |
| constexpr bool | kleidos:: |
| Whether a link gets the encryption-start deadline at its connection (finding C17). | |
| constexpr bool | kleidos:: |
| Whether a link that just encrypted may read as a host's. | |
| constexpr bool | kleidos:: |
| Whether a send can reach no host at all, so it ends at once. | |
| constexpr bool | kleidos:: |
| Whether a send may type into the live, authenticated link. | |
| void | kleidos:: |
| Native-only: clear state between tests. | |
| constexpr bool | kleidos:: |
| Whether two identity keys are equal, read in constant time. | |
| constexpr std::array< uint8_t, kIrkBytes > | kleidos:: |
| Turn an identity key between the keystore's byte order and a peer device record's. | |
| constexpr bool | kleidos:: |
Whether a stored record under bytes belongs to no kept bond. | |
| constexpr PeerRecordPlan | kleidos:: |
| Decide which peer device records stay, and which kept bonds need one. | |
| constexpr bool | kleidos:: |
| True when the live link satisfies the HOGP security bar. | |
| constexpr bool | kleidos:: |
| Whether the security the peripheral asks for at connection failed to start. | |
| constexpr bool | kleidos:: |
| Whether a link that had the encryption-start deadline is ended for missing it. | |
| constexpr uint64_t | kleidos:: |
| One link's encryption-start deadline, packed into one word. | |
| constexpr uint16_t | kleidos:: |
| The link a packed encryption-start deadline belongs to. | |
| constexpr uint32_t | kleidos:: |
| When a packed encryption-start deadline runs out. | |
| constexpr OwnAddress | kleidos:: |
| The own address the advertising uses after the privacy setup. | |
| Verdict | kleidos:: |
| How the last request armed was answered. | |
| Answer | kleidos:: |
Take the owner's answer to request, if it is still the request pending. | |
| void | kleidos:: |
| Native-only: clear state between tests. | |
| void | kleidos:: |
| Native-only: clear state between tests. | |
| constexpr bool | kleidos:: |
True when record is a key this firmware's pairing can produce. | |
| constexpr bool | kleidos:: |
True when peer is an identity a host can have. | |
| constexpr bool | kleidos:: |
| Whether a bond in the keystore holds a key a confirmed pairing left whole. | |
| constexpr bool | kleidos:: |
| Whether the records an unstored pairing may have left are deleted. | |
| constexpr bool | kleidos:: |
Whether a record of record's kind is kept only for an identity with a confirmed key. | |
| constexpr uint8_t | kleidos:: |
| The identity address type a record's address type names. | |
| constexpr bool | kleidos:: |
| Whether the host may go on after a store event. | |
Variables | |
| constexpr std::size_t | kleidos:: |
| Bytes of an identity resolving key. | |
| constexpr uint8_t | kleidos:: |
| constexpr int | kleidos:: |
| constexpr uint32_t | kleidos:: |
| constexpr uint64_t | kleidos:: |
| constexpr uint16_t | kleidos:: |
The connection handle no link has (NimBLE's BLE_). | |
| constexpr uint32_t | kleidos:: |
| How long, after a prompt that ended without an Allow, no new prompt is raised. | |
| constexpr uint8_t | kleidos:: |
| Address type of a public identity. | |
| constexpr uint8_t | kleidos:: |
| Address type of a random (static) identity. | |
| constexpr uint8_t | kleidos:: |
| The bit of an address type that says the identity is a random one. | |
Eviction confirmation: prompt lifecycle (Core 1 auth-drain) | |
| void | kleidos:: |
| Arm an eviction prompt for a candidate identity (current timestamp). | |
| void | kleidos:: |
| Arm an eviction prompt with an explicit request timestamp. | |
| void | kleidos:: |
| Discard any pending eviction prompt (deny). | |
Eviction confirmation: state queries (any task) | |
| bool | kleidos:: |
| True while a bond-eviction decision is awaited. | |
| bool | kleidos:: |
| Read the candidate identity awaiting an eviction decision. | |
Eviction confirmation: timeout helpers | |
| bool | kleidos:: |
| True if the prompt aged out relative to the current time. | |
| bool | kleidos:: |
Timeout check at an explicit nowMs. | |
Numeric comparison: prompt lifecycle (Core 0) | |
| void | kleidos:: |
Arm a Numeric Comparison prompt for connHandle with the current timestamp. | |
| void | kleidos:: |
| Arm a Numeric Comparison prompt with an explicit request timestamp. | |
| bool | kleidos:: |
Withdraw the request connHandle raised: its link ended or its encryption failed. | |
| void | kleidos:: |
| Withdraw any pending request (the host reset or the stack stopped). | |
Numeric comparison: state queries (any task) | |
| bool | kleidos:: |
| True while a Numeric Comparison decision is awaited. | |
| uint32_t | kleidos:: |
| Current 6-digit passkey, or 0 if no prompt is active. | |
| Snapshot | kleidos:: |
| Coherent copy of the prompt state. | |
| Ticket | kleidos:: |
| The request pending now, as an answer must name it. | |
| bool | kleidos:: |
True while request is the request pending now. | |
| uint16_t | kleidos:: |
The link request was armed for, while it is the last request armed. | |
| bool | kleidos:: |
True while the last request armed is generation generation on link connHandle. | |
| Verdict | kleidos:: |
How request was answered. | |
Numeric comparison: timeout helpers | |
| bool | kleidos:: |
| True if the prompt aged out relative to the current time. | |
| bool | kleidos:: |
Timeout check at an explicit nowMs. | |
| Ticket | kleidos:: |
| The request that aged out, read in the same load as its age. | |
| Ticket | kleidos:: |
timedOutTicket at an explicit nowMs. | |
Re-pair confirmation: prompt lifecycle (Core 0) | |
| bool | kleidos:: |
| Arm a re-pair confirmation prompt with the current timestamp. | |
| bool | kleidos:: |
| Arm a re-pair confirmation prompt with an explicit request timestamp. | |
| bool | kleidos:: |
Whether a prompt may be raised at nowMs. | |
| void | kleidos:: |
| Discard any pending prompt and any armed approval (deny). | |
| void | kleidos:: |
| The link the prompt stood for dropped. | |
Re-pair confirmation: state queries (any task) | |
| bool | kleidos:: |
| True while a re-pair confirmation decision is awaited. | |
| Snapshot | kleidos:: |
| Coherent copy of the prompt state. | |
Re-pair confirmation: timeout helpers | |
| bool | kleidos:: |
| True if the prompt aged out relative to the current time. | |
| bool | kleidos:: |
Timeout check at an explicit nowMs. | |
Re-pair confirmation: decision (any task) | |
| void | kleidos:: |
| Approve the re-pair: clear the prompt and arm the approval. | |
| void | kleidos:: |
| Decline the re-pair: clear the prompt and any armed grant. | |
| void | kleidos:: |
Decline at an explicit time: as decline, the cooldown from nowMs. | |
Enumeration Type Documentation
ConnectAdmission #
KeyVerdict #
The gate's verdict on one security record.
OwnAddress #
Which own address the advertising may use once privacy was set up (finding C27).
PersistResult #
What became of a confirmed pairing's security records in the store.
RepairClaim #
Whether a re-pair the owner allowed claims the identity a peer record is written under.
StoreEvent #
StoreRecord #
The kinds of record the host's store keeps, as the gate tells them apart.
Verdict #
Function Documentation
admitConnection() #
Whether the peripheral keeps a link a central just made.
- Parameters
-
Name Direction Meaning pairingWindowOpen in The "add a host" pairing window is open. keystore in What the keystore says about the central.
- Return values
-
Value Meaning true Keep the link ( connectAdmissionis notRefused).false Terminate it.
answer() #
Take the owner's answer to request, if it is still the request pending.
The answer is taken in one step with the check, so two surfaces answering at once, or a request replaced while its answer travels, never answer a request the owner did not see.
- Parameters
-
Name Direction Meaning request in The request the answer was given to. verdict in Verdict::orAccepted Verdict::.Rejected
- Returns
- Whether it was taken, and the link to inject it into.
approve() #
Approve the re-pair: clear the prompt and arm the approval.
The approval stands while the host's old bond is deleted, its link dropped and its fresh pairing awaited; clear ends it (that host's fresh pairing completed, the session stopped), and no other host's link does. It keeps the time the prompt was armed (Snapshot::), as a drop of the link does, so the approval's age reads from the request.
armedFor() #
True while the last request armed is generation generation on link connHandle.
The check an answer is injected under: a link that reused a handle and reached its own comparison armed a newer generation, so an answer taken for the earlier request never reaches it.
- Parameters
-
Name Direction Meaning connHandle in The link the answer is for. generation in The generation the answer was taken for.
- Return values
-
Value Meaning true No request was armed since that one. false A newer request was armed, on that link or another.
armPrompt() [1/2] #
Arm an eviction prompt for a candidate identity (current timestamp).
- Parameters
-
Name Direction Meaning addr in 6-byte candidate (new host) identity address. addrType in 0 = public, 1 = random.
armPrompt() [2/2] #
Arm a re-pair confirmation prompt with the current timestamp.
- Parameters
-
Name Meaning encryptedLink The request came over an encrypted link.
- Return values
-
Value Meaning true The prompt is armed. false A prompt ended without an Allow less than kPromptCooldownMs ago: nothing is armed, and the request is refused with no prompt.
armPromptAt() [1/2] #
Arm an eviction prompt with an explicit request timestamp.
- Parameters
-
Name Direction Meaning addr in 6-byte candidate identity address. addrType in 0 = public, 1 = random. requestMs in Monotonic milliseconds at which the request was received.
armPromptAt() [2/2] #
Arm a re-pair confirmation prompt with an explicit request timestamp.
- Parameters
-
Name Meaning requestMs Monotonic milliseconds at which the request was received. encryptedLink The request came over an encrypted link.
- Return values
-
Value Meaning true The prompt is armed. false The cooldown after the last prompt that ended without an Allow still runs at requestMs:nothing is armed.
armRequest() #
Arm a Numeric Comparison prompt for connHandle with the current timestamp.
- Parameters
-
Name Meaning connHandle The connection that raised the comparison. passkey 6-digit comparison value provided by NimBLE.
armRequestAt() #
Arm a Numeric Comparison prompt with an explicit request timestamp.
A request armed while another is pending replaces it: the earlier one is no longer pending, and no answer given to it is taken.
- Parameters
-
Name Meaning connHandle The connection that raised the comparison. passkey 6-digit comparison value provided by NimBLE. requestMs Monotonic milliseconds at which the request was received.
bondRecordsConfirmed() #
Whether a bond in the keystore holds a key a confirmed pairing left whole.
NimBLE lists its bonds from the device's own records, and the device record alone carries the link key a reconnect encrypts with. A bond is a host's only when the peer's record is stored beside it and both hold a confirmed key: a device record whose peer record never arrived (refused, not stored, or lost with the power between the two writes) is no host's, and the next host sync deletes it instead of adopting it.
- Parameters
-
Name Direction Meaning ownConfirmed in The device's record holds a confirmed key. peerFound in The peer's record is stored. peerConfirmed in The peer's record holds a confirmed key.
- Returns
trueonly when all three hold.
candidate() #
Read the candidate identity awaiting an eviction decision.
- Parameters
-
Name Direction Meaning outAddr out 6-byte candidate identity address (written on success). outType out Candidate address type (0 = public, 1 = random).
- Return values
-
Value Meaning true A prompt is armed; outAddr/outTypeare populated.false No prompt is armed; the outputs are untouched.
clear() #
Withdraw any pending request (the host reset or the stack stopped).
The verdict of a request already answered stays readable.
connectAdmission() #
Whether, and why, the peripheral keeps a link a central just made.
- Parameters
-
Name Direction Meaning pairingWindowOpen in The "add a host" pairing window is open. keystore in What the keystore says about the central.
- Return values
-
Value Meaning ConnectAdmission:: Pairing A stranger while the window is open, anyone while the window is open and the keystore could not be read, and anyone while nobody is bonded (no key in the keystore and no host in the table): a pairing is what the link is for. ConnectAdmission:: SavedHost A bonded host (the chosen one, when a send chose one) while the window is closed: it holds a stored key. ConnectAdmission:: Refused Anyone else: a forgotten host, and an unreadable keystore with the window closed, included.
decline() #
Decline the re-pair: clear the prompt and any armed grant.
A prompt it ends starts the cooldown (kPromptCooldownMs).
declineAt() #
Decline at an explicit time: as decline, the cooldown from nowMs.
- Parameters
-
Name Meaning nowMs Monotonic milliseconds.
encryptionDeadlineApplies() #
Whether a link gets the encryption-start deadline at its connection (finding C17).
A link kept as a saved host claims a bonded identity, and a bonded host encrypts with its stored key as soon as it connects: a central replaying that identity cannot, and is ended at the deadline. A pairing cannot be raised on such a link: a bonded identity's Pairing Request is NimBLE's repeat pairing, which the re-pair gate (E4) always refuses, so its link waits only on the owner's re-pair prompt, which the deadline leaves alone. A link kept for a pairing gets no deadline: its pairing waits on the owner's numeric comparison, bounded by NimBLE's security timer and the session's own.
- Parameters
-
Name Direction Meaning admission in What connectAdmissiondecided for the link.
- Return values
-
Value Meaning true Arm the deadline. false No deadline: a pairing may run on this link (or it is refused).
encryptionDeadlineAtMs() #
When a packed encryption-start deadline runs out.
- Parameters
-
Name Meaning packed A word from packEncryptionDeadline.
- Returns
- Its
clock::time, never 0.millis32
encryptionDeadlineHandle() #
The link a packed encryption-start deadline belongs to.
- Parameters
-
Name Meaning packed A word from packEncryptionDeadline.
- Returns
- Its connection handle.
encryptionDeadlineMissed() #
Whether a link that had the encryption-start deadline is ended for missing it.
A bonded host whose key the keystore lacks asks to pair again, and the owner's re-pair prompt (E4) then holds that link under its own timeout; the deadline leaves that link to the prompt. An Allow ends the prompt on the UI task before the BLE stack task drops the link for it (dropRepairLink, 0x13), so the link stays the re-pair's until then too: its drop always follows the opening of the pairing window the asking host comes back through, never a deadline's 0x05 in between.
- Parameters
-
Name Meaning armed The link has the deadline. reached The deadline has passed. encrypted Its encryption completed. repairHoldsLink A re-pair prompt the owner sees was raised on this link, or the owner allowed it and the link's drop for it has not run yet.
- Return values
-
Value Meaning true End the link. false Leave it.
identityShapeValid() #
True when peer is an identity a host can have.
Refused: a type other than public or random, the all-zero and the all-one address, any of the device's own addresses (whatever the type), and a random address that is not a static one (the two top bits of the most significant byte set, the 46 random bits neither all zero nor all one). A private address there means the peer distributed no identity, and a key stored under it could never be found again.
- Parameters
-
Name Direction Meaning peer in The identity a record is about to be stored under. own in The device's own addresses (public and random), as NimBLE keeps them; an all-zero entry stands for one it does not have.
- Returns
truewhen the identity may hold a key.
identityTypeOf() #
The identity address type a record's address type names.
NimBLE writes some records with the connection's identity type (2 for a public identity, 3 for a random one) and stores the keys with 0 and 1; the low bit is the identity's type in both spellings.
- Parameters
-
Name Direction Meaning addrType in The type a record carries.
- Returns
- 0 for a public identity, 1 for a random one.
keyConfirmed() #
True when record is a key this firmware's pairing can produce.
- Parameters
-
Name Direction Meaning record in The record about to be stored.
- Returns
trueonly for an authenticated Secure Connections long-term key of at leastkMinLinkKeyBytes.
lastVerdict() #
How the last request armed was answered.
Kept past the answer (the request is no longer pending) until the next request is armed, so a prompt that closed because another surface answered reads which answer stands.
- Returns
- The last request's verdict,
Verdict::Nonewhile it is pending or when it ended unanswered.
linkDropped() #
The link the prompt stood for dropped.
A pending prompt goes with it: it stands for that link only, and a new peer must raise (and the owner answer) a fresh one. An approval stays: dropping the link is what it asked for, and the host's fresh pairing is still awaited.
linkOf() #
The link request was armed for, while it is the last request armed.
- Parameters
-
Name Direction Meaning request in The request a dialog showed.
- Returns
- Its connection handle, or
kNoConnHandleonce a newer request was armed (or for an invalid ticket).
mayPromptAt() #
Whether a prompt may be raised at nowMs.
- Parameters
-
Name Meaning nowMs Monotonic milliseconds.
- Return values
-
Value Meaning true No cooldown runs. false A prompt ended without an Allow less than kPromptCooldownMs ago.
ownAddressAfterPrivacySetup() #
The own address the advertising uses after the privacy setup.
An identity address is the same on every advertisement, so anyone in range can follow the device. A shipping build (_release, _secure) never falls back to it: it does not advertise at all, and the session fails. An open build keeps the fallback, so a bench can still reach a board whose controller refused privacy.
- Parameters
-
Name Meaning privacyOn The privacy setup succeeded. failClosed The build may not fall back to the identity address.
- Returns
- The address the advertising takes, or
OwnAddress::.Refused
packEncryptionDeadline() #
One link's encryption-start deadline, packed into one word.
The handle and the time travel together, so a reader never pairs one link's time with another link's handle: a link that ends and a new one that connects between two separate reads cannot inherit an expired deadline.
- Parameters
-
Name Meaning handle The link's connection handle. atMs When its time runs out ( clock::time); 0 is taken as 1.millis32
- Returns
- The packed word, never
kNoEncryptionDeadline.
passkey() #
Current 6-digit passkey, or 0 if no prompt is active.
- Returns
- The passkey value, or 0 when not in Numeric Comparison.
pending() [1/3] #
True while a bond-eviction decision is awaited.
- Return values
-
Value Meaning true A prompt has been armed but not yet resolved. false No prompt is currently armed.
pending() [2/3] #
True while a Numeric Comparison decision is awaited.
- Return values
-
Value Meaning true A prompt has been armed but not yet resolved. false No prompt is currently armed.
pending() [3/3] #
True while a re-pair confirmation decision is awaited.
- Return values
-
Value Meaning true A prompt has been armed but not yet resolved. false No prompt is currently armed.
pendingFor() #
True while request is the request pending now.
- Parameters
-
Name Direction Meaning request in The request a dialog shows.
- Return values
-
Value Meaning true It is pending: the dialog still asks. false It was answered, withdrawn, or a newer request replaced it.
planPeerRecords() #
Decide which peer device records stay, and which kept bonds need one.
A record stays when it carries an identity and an identity key, a kept bond has that identity, that bond's peer record holds the same key, and no earlier record already stays for that bond. Every other record is removed. A kept bond with an identity key and no record that stays is marked as needing one.
- Parameters
-
Name Direction Meaning records in The peer device records, in the list's order. kept in The bonds the keystore holds whole. keep out One flag per record: truewhen it stays (sized asrecords).needs out One flag per kept bond: truewhen it needs a record (sized askept).
- Returns
- How many records go and how many bonds need one.
recordNeedsConfirmedKey() #
Whether a record of record's kind is kept only for an identity with a confirmed key.
A peer's address record, its subscriptions and its supported features belong to a bonded host. NimBLE writes the last two for every link that bonded, whatever the association model, right after the encryption change (ble_): a Just Works stranger the adapter refuses leaves its supported-features record, and a subscription to Service Changed made in the clear, under an identity with no key, which no forget and no reconcile would ever find (finding C5). Each is kept only when a confirmed key is stored for its identity and the pairing writing it did not just have its key refused (WriteGate::
- Parameters
-
Name Direction Meaning record in The record's kind.
- Return values
-
Value Meaning true Its identity must hold a confirmed key. false It is a security record (judged by WriteGate:: decideKey) or the device's own.
recordOrphaned() #
Whether a stored record under bytes belongs to no kept bond.
- Parameters
-
Name Direction Meaning bytes in The six bytes of the identity the record is stored under. kept in The bonds the keystore holds whole.
- Return values
-
Value Meaning true No kept bond has these bytes: the record is deleted. false A kept bond owns it.
reportLinkSecure() #
True when the live link satisfies the HOGP security bar.
Fail-closed: any field that falls short makes the whole predicate false, so callers that gate credential keystrokes on it never emit over a link that has lost encryption/
- Parameters
-
Name Meaning encrypted Link-layer encryption is active. authenticated Pairing was MITM-authenticated (Numeric Comparison). bonded A bond (LTK/IRK) is stored for the peer. keySize Negotiated encryption-key length in bytes.
- Returns
trueonly if encrypted && authenticated && bonded && keySize >=kMinLinkKeyBytes.
restoredKeyAdmitted() #
Whether a link that just encrypted may read as a host's.
A link that paired fresh (a numeric comparison ran on it) carries a key the owner just confirmed. A link that restored a stored key is a forgotten host's when the table keeps a tombstone for its identity: the key was to be deleted and the delete has not taken, so the link is dropped before it reads as authenticated (finding C9).
- Parameters
-
Name Direction Meaning freshPairing in The link paired here. forgotten in The table holds a tombstone for the link's identity.
- Returns
truewhen the link may read as authenticated.
sameIrk() #
Whether two identity keys are equal, read in constant time.
- Parameters
-
Name Direction Meaning a in One key. b in The other.
- Returns
truewhen every byte matches.
securityStartFailed() #
Whether the security the peripheral asks for at connection failed to start.
The peripheral asks for security when the connection event reaches it (ble_). NimBLE delivers that event only once it has read the central's version and features, and runs the SMP exchange in the meantime: a central that pairs as soon as it connects (BlueZ's pair, some Windows stacks) has started its pairing before the event, and the request returns kSecurityAlreadyRunning. That pairing is the one asked for and goes on under the same rules: Secure Connections only, the MITM bit, the numeric comparison, and an unauthenticated result refused at the encryption change. Any other non-zero code means no security can start on the link, which is then ended.
- Parameters
-
Name Meaning rc The code ble_returned.gap_ security_ initiate()
- Return values
-
Value Meaning true It failed: the link is ended. false Security started, or a procedure already runs on the link.
sendReachesNoHost() #
Whether a send can reach no host at all, so it ends at once.
A host whose row the table lists but whose key the keystore lost (a keyless row: an image before the write gate, a forget whose row a power loss brought back, a key dropped on the bench) can never connect: the link check needs its key. A send for it waited the whole session and timed out with no word (findings C10 and C44). It ends at once, and the owner is told the host must be paired again.
Never while a host may still pair: a re-pair the owner allowed has deleted the asking host's old bond and row (and cleared the target) before the host comes back to pair fresh, and the pairing window admits a new host. Ending the send there would cut the re-pair short and lose that host's row.
- Parameters
-
Name Direction Meaning hostMayPair in A re-pair the owner allowed is waiting for its host, or the pairing window is open. targetSet in The send chose one host. targetKeyless in That host's row has no key. listed in Hosts the table lists. keyless in Of them, rows with no key.
- Return values
-
Value Meaning true No listed host the send may reach has a key. false A host may still connect or pair (or the table lists none: the first pairing).
snapshot() [1/2] #
Coherent copy of the prompt state.
- Returns
- Snapshot of the current NC state.
snapshot() [2/2] #
Coherent copy of the prompt state.
- Returns
- Snapshot of the current re-pair state (pending, approved, requestMs).
storeEventProceeds() #
Whether the host may go on after a store event.
- Parameters
-
Name Direction Meaning event in The event the host reported.
- Return values
-
Value Meaning true Go on: a "full" warning before a pairing. false Refuse: an overflow is never answered by evicting a bond.
swapIrkOrder() #
Turn an identity key between the keystore's byte order and a peer device record's.
The security manager stores a distributed key in the keystore as it came (ble_ copies it) and into the peer device record byte-reversed (ble_ copies it with swap_buf). The turn is its own inverse, so one call reads a record's key into the keystore's order and another writes a kept bond's key into a record.
- Parameters
-
Name Direction Meaning key in The key in one order.
- Returns
- The same key in the other.
ticket() #
The request pending now, as an answer must name it.
- Returns
- Its generation and digits, or an invalid ticket when none is pending.
timedOut() [1/3] #
True if the prompt aged out relative to the current time.
- Parameters
-
Name Meaning timeoutMs Maximum prompt lifetime in milliseconds.
- Return values
-
Value Meaning true The elapsed time since the request exceeds timeoutMs.false The prompt is still within timeoutMs, or none is armed.
timedOut() [2/3] #
True if the prompt aged out relative to the current time.
- Parameters
-
Name Meaning timeoutMs Maximum prompt lifetime in milliseconds.
- Return values
-
Value Meaning true The elapsed time since the request exceeds timeoutMs.false The prompt is still within timeoutMs, or no prompt is armed.
timedOut() [3/3] #
True if the prompt aged out relative to the current time.
- Parameters
-
Name Meaning timeoutMs Maximum prompt lifetime in milliseconds.
- Return values
-
Value Meaning true The elapsed time since the request exceeds timeoutMs.false The prompt is still within timeoutMs, or no prompt is armed.
timedOutAt() [1/3] #
Timeout check at an explicit nowMs.
- Parameters
-
Name Meaning timeoutMs Maximum prompt lifetime in milliseconds. nowMs Current monotonic timestamp in milliseconds.
- Return values
-
Value Meaning true ( nowMs- requestMs) exceedstimeoutMs.false The prompt is still within timeoutMs, or none is armed.
timedOutAt() [2/3] #
Timeout check at an explicit nowMs.
- Parameters
-
Name Meaning timeoutMs Maximum prompt lifetime in milliseconds. nowMs Current monotonic timestamp in milliseconds.
- Return values
-
Value Meaning true ( nowMs- requestMs) exceedstimeoutMs.false The prompt is still within timeoutMs, or no prompt is armed.
timedOutAt() [3/3] #
Timeout check at an explicit nowMs.
- Parameters
-
Name Meaning timeoutMs Maximum prompt lifetime in milliseconds. nowMs Current monotonic timestamp in milliseconds.
- Return values
-
Value Meaning true ( nowMs- requestMs) exceedstimeoutMs.false The prompt is still within timeoutMs, or no prompt is armed.
timedOutTicket() #
The request that aged out, read in the same load as its age.
- Parameters
-
Name Meaning timeoutMs Maximum prompt lifetime in milliseconds.
- Returns
- Its ticket, to reject that request and no later one; an invalid ticket when nothing pending aged out.
timedOutTicketAt() #
timedOutTicket at an explicit nowMs.
- Parameters
-
Name Meaning timeoutMs Maximum prompt lifetime in milliseconds. nowMs Current monotonic timestamp in milliseconds.
- Returns
- The ticket of the pending request older than
timeoutMs, or an invalid one.
typingTargetAllows() #
Whether a send may type into the live, authenticated link.
With a target chosen, only that host's link; with none, any bonded host's. While a re-pair the owner allowed keeps the target for its host (BondStore::), nothing: a central paired meanwhile, even one the owner confirmed, is never typed to before the asking host is back (finding C4).
- Parameters
-
Name Direction Meaning targetSet in A target slot is chosen. repairTargetKept in A re-pair holds the target for its host. peerIsTarget in The live, authenticated link is the target's.
- Returns
truewhen typing may start.
unstoredDropsKeys() #
Whether the records an unstored pairing may have left are deleted.
A pairing refused for an identity that is a saved host's, or that no host can have, stored nothing: deleting by its bytes would delete the saved host's keys (or an unlisted replace-oldest candidate's). A pairing the store ran out of room for, failed, or refused at its peer record after storing its device record left records of its own.
- Parameters
-
Name Direction Meaning result in The pairing's persist result.
- Returns
truewhen its records are deleted by its identity's bytes.
verdictFor() #
How request was answered.
- Parameters
-
Name Direction Meaning request in The request a dialog showed.
- Returns
- Its verdict while it is the last request armed;
Verdict::Nonewhile it is pending, when it ended unanswered, or once a newer request replaced it.
withdraw() #
Withdraw the request connHandle raised: its link ended or its encryption failed.
A request another link raised is left as it is, and so is the verdict of a request already answered.
- Parameters
-
Name Meaning connHandle The link that went.
- Return values
-
Value Meaning true The pending request was that link's and is withdrawn. false Nothing was pending for that link.
Variable Documentation
kEncryptionStartDeadlineMs #
How long a link kept as a saved host has to start its encryption, from its connection event (finding C17). Such a link claims a bonded identity (ConnectAdmission::, encryptionDeadlineApplies in connect_), and a bonded host encrypts with its stored key as soon as it connects; a central that replays a bonded host's address cannot, and would otherwise hold the device's one link until NimBLE's own 30 s security timer ends it.
kMinLinkKeyBytes #
Minimum negotiated encryption-key length (bytes) for LE Secure Connections. A shorter key indicates a KNOB/
kNoEncryptionDeadline #
No encryption-start deadline is armed (the packed word of packEncryptionDeadline is never this value).
kSecurityAlreadyRunning #
The code ble_ returns when a security procedure (a pairing, or the encryption with a stored key) already runs on the link: NimBLE's BLE_. The raw adapter checks the two agree.