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

#include <PasswordStore.h>

Classes

struct  EntryIndex

Public Member Functions

bool readEntry (uint16_t slot, PasswordEntry *out) const
 Reads one password entry from secure-element storage.
bool addEntry (const PasswordEntry &entry)
 Adds a new password entry into first free slot.
bool updateEntry (uint16_t slot, const PasswordEntry &entry)
 Updates existing password entry.
bool deleteEntry (uint16_t slot)
 Deletes entry at logical slot index.
bool listEntriesSorted (EntryIndex *entries, uint16_t maxEntries, uint16_t *countOut) const
 Lists entries sorted alphabetically by title.
bool findFreeLogicalSlot (uint16_t *logicalSlotOut) const
 Finds first free logical slot in this module's range.
bool findByTitle (const char *title, uint16_t *logicalSlotOut) const
 Finds the logical slot of an entry with a matching title.
void setSlotRange (const cdc::core::IModule::SlotRange &range)
 Configures logical-to-physical slot mapping for password entries.
uint16_t capacity () const
bool toPhysicalSlot (uint16_t logicalIndex, uint16_t *slotOut) const
bool toLogicalSlot (uint16_t slot, uint16_t *logicalIndexOut) const
bool hasSlotRange () const
uint8_t moduleId () const
uint16_t rmemStart () const
uint16_t rmemEnd () const

Static Public Member Functions

static PasswordStore & instance ()
 Returns singleton password store instance.

Static Public Attributes

static constexpr uint8_t TITLE_LEN = PASSWORD_TITLE_LEN
static constexpr uint8_t USERNAME_LEN = PASSWORD_USERNAME_LEN
static constexpr uint8_t PASSWORD_LEN = PASSWORD_PASSWORD_LEN
static constexpr uint8_t URL_LEN = PASSWORD_URL_LEN
static constexpr uint8_t TOTP_SLOT_NONE = 0xFF
static constexpr size_t PAYLOAD_MAX = PASSWORD_PAYLOAD_MAX
static constexpr size_t FIXED_PAYLOAD = PASSWORD_FIXED_PAYLOAD
static constexpr size_t NOTES_LEN = PASSWORD_NOTES_LEN

Detailed Description

Definition at line 32 of file PasswordStore.h.

Member Function Documentation

◆ addEntry()

◆ capacity()

uint16_t cdc::mod_password::PasswordStore::capacity ( ) const
inline

Definition at line 61 of file PasswordStore.h.

Referenced by cdc::mod_password::ensureListBuffers().

◆ deleteEntry()

bool cdc::mod_password::PasswordStore::deleteEntry ( uint16_t slot)

Deletes entry at logical slot index.

Parameters
slotLogical slot index.
Returns
true on successful erase.

Definition at line 210 of file PasswordStore.cpp.

References cdc::core::TropicStorage::eraseSlot(), cdc::hal::getSecureElementInstance(), cdc::core::TropicStorage::instance(), cdc::hal::OK, and toPhysicalSlot().

Referenced by cdc::mod_password::cmd_password_del(), and cdc::mod_password::onMenuDeleteConfirm().

◆ findByTitle()

bool cdc::mod_password::PasswordStore::findByTitle ( const char * title,
uint16_t * logicalSlotOut ) const

Finds the logical slot of an entry with a matching title.

Title is the entry's natural identity (it is the secure-element header name). Comparison is case-insensitive to match the list ordering.

Parameters
titleTitle to look up.
logicalSlotOutOutput logical slot index of the first match.
Returns
true if a matching entry exists.

Definition at line 298 of file PasswordStore.cpp.

References cdc::core::TropicStorage::forEachSlot(), cdc::core::TropicStorage::instance(), instance(), and toLogicalSlot().

◆ findFreeLogicalSlot()

bool cdc::mod_password::PasswordStore::findFreeLogicalSlot ( uint16_t * logicalSlotOut) const

Finds first free logical slot in this module's range.

Parameters
logicalSlotOutOutput logical slot index.
Returns
true if a free slot was found.

Definition at line 333 of file PasswordStore.cpp.

References toLogicalSlot().

◆ hasSlotRange()

bool cdc::mod_password::PasswordStore::hasSlotRange ( ) const
inline

Definition at line 68 of file PasswordStore.h.

◆ instance()

◆ listEntriesSorted()

bool cdc::mod_password::PasswordStore::listEntriesSorted ( EntryIndex * entries,
uint16_t maxEntries,
uint16_t * countOut ) const

Lists entries sorted alphabetically by title.

Parameters
entriesOutput entry index array.
maxEntriesMaximum writable entries.
countOutOutput number of entries.
Returns
true on successful listing.

Definition at line 253 of file PasswordStore.cpp.

References cdc::mod_password::copyText(), cdc::core::TropicStorage::forEachSlot(), cdc::core::TropicStorage::instance(), instance(), cdc::mod_password::PasswordStore::EntryIndex::title, and toLogicalSlot().

Referenced by cdc::mod_password::rebuildList().

◆ moduleId()

uint8_t cdc::mod_password::PasswordStore::moduleId ( ) const
inline

Definition at line 69 of file PasswordStore.h.

◆ readEntry()

◆ rmemEnd()

uint16_t cdc::mod_password::PasswordStore::rmemEnd ( ) const
inline

Definition at line 71 of file PasswordStore.h.

◆ rmemStart()

uint16_t cdc::mod_password::PasswordStore::rmemStart ( ) const
inline

Definition at line 70 of file PasswordStore.h.

◆ setSlotRange()

void cdc::mod_password::PasswordStore::setSlotRange ( const cdc::core::IModule::SlotRange & range)

Configures logical-to-physical slot mapping for password entries.

Parameters
rangeSlot range descriptor (RMEM fields are consumed).

Definition at line 56 of file PasswordStore.cpp.

References setSlotRange().

Referenced by cdc::mod_password::PasswordModule::init(), and setSlotRange().

◆ toLogicalSlot()

bool cdc::mod_password::PasswordStore::toLogicalSlot ( uint16_t slot,
uint16_t * logicalIndexOut ) const
inline

Definition at line 65 of file PasswordStore.h.

Referenced by findByTitle(), findFreeLogicalSlot(), and listEntriesSorted().

◆ toPhysicalSlot()

bool cdc::mod_password::PasswordStore::toPhysicalSlot ( uint16_t logicalIndex,
uint16_t * slotOut ) const
inline

Definition at line 62 of file PasswordStore.h.

Referenced by deleteEntry(), readEntry(), and updateEntry().

◆ updateEntry()

Member Data Documentation

◆ FIXED_PAYLOAD

size_t cdc::mod_password::PasswordStore::FIXED_PAYLOAD = PASSWORD_FIXED_PAYLOAD
staticconstexpr

Definition at line 41 of file PasswordStore.h.

◆ NOTES_LEN

size_t cdc::mod_password::PasswordStore::NOTES_LEN = PASSWORD_NOTES_LEN
staticconstexpr

Definition at line 42 of file PasswordStore.h.

Referenced by cdc::mod_password::cmd_password_edit().

◆ PASSWORD_LEN

uint8_t cdc::mod_password::PasswordStore::PASSWORD_LEN = PASSWORD_PASSWORD_LEN
staticconstexpr

◆ PAYLOAD_MAX

size_t cdc::mod_password::PasswordStore::PAYLOAD_MAX = PASSWORD_PAYLOAD_MAX
staticconstexpr

Definition at line 40 of file PasswordStore.h.

◆ TITLE_LEN

uint8_t cdc::mod_password::PasswordStore::TITLE_LEN = PASSWORD_TITLE_LEN
staticconstexpr

◆ TOTP_SLOT_NONE

◆ URL_LEN

uint8_t cdc::mod_password::PasswordStore::URL_LEN = PASSWORD_URL_LEN
staticconstexpr

◆ USERNAME_LEN

uint8_t cdc::mod_password::PasswordStore::USERNAME_LEN = PASSWORD_USERNAME_LEN
staticconstexpr

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