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

NVS-backed store of third-party certifications on the badge's own key. More...

#include <GpgSelfCertStore.h>

Public Member Functions

bool addCert (const gpg_self_cert_t &cert)
 Persist a certification. Replaces an existing entry from the same issuer.
uint8_t count ()
 Number of stored certifications.
uint8_t listIndex (gpg_self_cert_index_entry_t *out, uint8_t max)
 Build the sorted index (oldest first).
bool getCert (uint8_t index, gpg_self_cert_t *out)
 Load one certification by sorted index (0..count()-1).
bool deleteCert (uint8_t index)
 Remove one certification by sorted index. No-op if out of range.

Static Public Member Functions

static GpgSelfCertStore & instance ()

Static Public Attributes

static constexpr uint8_t kMaxCerts = 16
 Hard ceiling. Past this addCert rejects further inserts.

Detailed Description

NVS-backed store of third-party certifications on the badge's own key.

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

Definition at line 48 of file GpgSelfCertStore.h.

Member Function Documentation

◆ addCert()

bool cdc::mod_gpg::GpgSelfCertStore::addCert ( const gpg_self_cert_t & cert)

Persist a certification. Replaces an existing entry from the same issuer.

Definition at line 51 of file GpgSelfCertStore.cpp.

References count(), cdc::mod_gpg::gpg_self_cert_t::issuer_fp_v4, cdc::mod_gpg::kGpgSelfCertSigMax, kMaxCerts, LOG_W, name, cdc::mod_gpg::gpg_self_cert_t::sig_pkt_len, and TAG.

◆ count()

uint8_t cdc::mod_gpg::GpgSelfCertStore::count ( )

Number of stored certifications.

Definition at line 66 of file GpgSelfCertStore.cpp.

References kMaxCerts.

Referenced by addCert().

◆ deleteCert()

bool cdc::mod_gpg::GpgSelfCertStore::deleteCert ( uint8_t index)

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

Definition at line 130 of file GpgSelfCertStore.cpp.

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

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

◆ getCert()

bool cdc::mod_gpg::GpgSelfCertStore::getCert ( uint8_t index,
gpg_self_cert_t * out )

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

Definition at line 123 of file GpgSelfCertStore.cpp.

References name.

◆ instance()

◆ listIndex()

uint8_t cdc::mod_gpg::GpgSelfCertStore::listIndex ( gpg_self_cert_index_entry_t * out,
uint8_t max )

Build the sorted index (oldest first).

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

Definition at line 83 of file GpgSelfCertStore.cpp.

References cdc::mod_gpg::gpg_self_cert_index_entry_t::received_at, and cdc::mod_gpg::gpg_self_cert_t::received_at.

Member Data Documentation

◆ kMaxCerts

uint8_t cdc::mod_gpg::GpgSelfCertStore::kMaxCerts = 16
staticconstexpr

Hard ceiling. Past this addCert rejects further inserts.

Definition at line 51 of file GpgSelfCertStore.h.

Referenced by addCert(), cdc::mod_gpg::cmd_gpg_mycert_list(), count(), and cdc::mod_gpg::rebuildMyCertList().


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