CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc::mod_gpg::GpgRecvStore Class Reference

NVS-backed store for cross-sign target keys received via BLE. More...

#include <GpgRecvStore.h>

Public Member Functions

bool addKey (const gpg_recv_key_t &key)
 Persist a new key. Replaces an existing entry if the fingerprint matches.
uint8_t count ()
 Number of stored keys.
uint8_t listIndex (gpg_recv_index_entry_t *out, uint8_t max)
 Build the sorted index (oldest first).
bool getKey (uint8_t index, gpg_recv_key_t *out)
 Load one key by sorted index (0..count()-1).
bool deleteKey (uint8_t index)
 Remove one key by sorted index. No-op if index is out of range.
bool setSignature (uint8_t index, const uint8_t *sig, uint8_t sig_len, uint8_t flags)
 Attach a cross-signature and flag bits to an existing entry.

Static Public Member Functions

static GpgRecvStore & instance ()

Static Public Attributes

static constexpr uint8_t kMaxKeys = 128
 Hard ceiling. Past this addKey rejects further inserts.

Detailed Description

NVS-backed store for cross-sign target keys received via BLE.

Singleton. All public methods open and close their own NVS handle, so the store is safe to call from any task without external synchronisation (NVS itself serialises writes).

Definition at line 58 of file GpgRecvStore.h.

Member Function Documentation

◆ addKey()

bool cdc::mod_gpg::GpgRecvStore::addKey ( const gpg_recv_key_t & key)

Persist a new key. Replaces an existing entry if the fingerprint matches.

Definition at line 51 of file GpgRecvStore.cpp.

References count(), cdc::mod_gpg::gpg_recv_key_t::fingerprint_v4, kMaxKeys, LOG_W, name, and TAG.

◆ count()

uint8_t cdc::mod_gpg::GpgRecvStore::count ( )

Number of stored keys.

Definition at line 66 of file GpgRecvStore.cpp.

References kMaxKeys.

Referenced by addKey().

◆ deleteKey()

bool cdc::mod_gpg::GpgRecvStore::deleteKey ( uint8_t index)

Remove one key by sorted index. No-op if index is out of range.

Definition at line 131 of file GpgRecvStore.cpp.

References cdc::core::NvsScope::commit(), and name.

Referenced by cdc::mod_gpg::onReceivedDeleteConfirm().

◆ getKey()

bool cdc::mod_gpg::GpgRecvStore::getKey ( uint8_t index,
gpg_recv_key_t * out )

Load one key by sorted index (0..count()-1).

Definition at line 124 of file GpgRecvStore.cpp.

References name.

Referenced by cdc::mod_gpg::onReceivedSignConfirm().

◆ instance()

◆ listIndex()

uint8_t cdc::mod_gpg::GpgRecvStore::listIndex ( gpg_recv_index_entry_t * out,
uint8_t max )

Build the sorted index (oldest first).

Parameters
outCaller-owned buffer of at least max entries (use PSRAM).
maxCapacity of out.
Returns
Number of entries written (capped at max and kMaxKeys).

Definition at line 83 of file GpgRecvStore.cpp.

References cdc::mod_gpg::gpg_recv_index_entry_t::flags, cdc::mod_gpg::gpg_recv_key_t::flags, cdc::mod_gpg::gpg_recv_index_entry_t::received_at, and cdc::mod_gpg::gpg_recv_key_t::received_at.

◆ setSignature()

bool cdc::mod_gpg::GpgRecvStore::setSignature ( uint8_t index,
const uint8_t * sig,
uint8_t sig_len,
uint8_t flags )

Attach a cross-signature and flag bits to an existing entry.

Definition at line 141 of file GpgRecvStore.cpp.

References cdc::mod_gpg::gpg_recv_key_t::flags, flags, cdc::mod_gpg::gpg_recv_key_t::my_signature, name, and cdc::mod_gpg::gpg_recv_key_t::sig_len.

Member Data Documentation

◆ kMaxKeys

uint8_t cdc::mod_gpg::GpgRecvStore::kMaxKeys = 128
staticconstexpr

Hard ceiling. Past this addKey rejects further inserts.

Definition at line 61 of file GpgRecvStore.h.

Referenced by addKey(), cdc::mod_gpg::cmd_gpg_recv_list(), count(), and cdc::mod_gpg::rebuildReceivedList().


The documentation for this class was generated from the following files: