|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
Classes | |
| class | PasswordModule |
| struct | PasswordEntry |
| class | PasswordStore |
| struct | WizardState |
| struct | PasswordPayload |
Functions | |
| static void | registerStrings () |
| static bool | isValidSlot (uint16_t slot) |
| Validates that a slot number is within the configured password range. | |
| static void | cmd_password_list (const char *args) |
| Serial command handler listing all password entries. | |
| static void | cmd_password_get (const char *args) |
| Serial command handler printing one password entry by index. | |
| static bool | isPlaceholder (const char *s) |
| Serial command handler adding one password entry. | |
| static void | generateRandomPassword (char *out, size_t outSize) |
| Generates a 16-character random password from charset a-zA-Z0-9$!%=. | |
| static void | cmd_password_add (const char *args) |
| static void | cmd_password_edit (const char *args) |
| Serial command handler editing one field of a password entry. Usage: PASSWORD_EDIT <index> <field> <new value...> Field: title | username | password | url | totp | notes. | |
| static void | cmd_password_del (const char *args) |
| Serial command handler deleting one password entry by index. | |
| static void | cmd_password (const char *args) |
| static void | registerCommands () |
| Registers serial commands exposed by the password module. | |
| static void | freeListBuffers () |
| Releases dynamic buffers used by the password list view. | |
| static bool | ensureListBuffers () |
| Ensures list and entry buffers are allocated for current store capacity. | |
| static void | rebuildList () |
| Rebuilds password list items from sorted store entries. | |
| static void | onTypePassword (void *userData) |
| Types currently selected password through attached keyboard provider. | |
| static void | showDetails (uint16_t slot) |
| Shows full entry details in the info view for a slot. | |
| static void | wizardFinish () |
| Persists wizard add/edit changes and returns to list view. | |
| static void | pushT9WizardStep (const char *title, const char *initialText, uint16_t maxLen, ui::T9InputView::SaveCallback onSave) |
| Pushes a configured T9 input step for wizard flow. | |
| static void | onWizardTitle (const char *text) |
| Saves title field and advances to username step. | |
| static void | onWizardUsername (const char *text) |
| Saves username field and advances to password step. | |
| static void | onWizardPassword (const char *text) |
| Saves password field; an "x" input generates a random 16-char password via the shared generator. Then advances to URL step. | |
| static void | onWizardUrl (const char *text) |
| Saves URL field and advances to optional TOTP slot step. | |
| static void | onWizardTotp (const char *text) |
| Validates and saves optional TOTP slot, then advances to notes step. | |
| static void | onWizardNotes (const char *text) |
| Saves notes field and completes wizard persistence. | |
| static void | wizardStart () |
| Starts add-entry wizard with empty fields. | |
| static void | wizardEdit (uint16_t slot) |
| Starts edit-entry wizard prefilled with existing slot data. | |
| static void | onMenuView () |
| Opens details view for currently active entry. | |
| static void | onMenuEdit () |
| Opens edit wizard for currently active entry. | |
| static void | onMenuDeleteConfirm (void *userData) |
| Confirmation callback deleting selected entry slot. | |
| static void | onMenuDelete () |
| Opens delete confirmation dialog for currently active entry. | |
| static void | onListMenu (uint16_t index, void *userData) |
| Opens contextual action menu for selected list entry. | |
| static void | onListSelect (uint16_t index, void *userData) |
| Handles direct selection from list view (view existing or add new). | |
| static bool | importPasswordEntry (const cJSON *je, void *user) |
| Maps and upserts one vault entry from its JSON representation. | |
| static void | copyText (char *dst, size_t dstSize, const char *src) |
| Copies text into bounded destination buffer. | |
| const char * | skipSpaces (const char *s) |
| Advances over leading ASCII whitespace in a C string. | |
| const char * | nextToken (const char *s, char *out, size_t outSize) |
| Extracts one whitespace-delimited token from a string. | |
Variables | |
| constexpr uint8_t | PASSWORD_TITLE_LEN = 24 |
| constexpr uint8_t | PASSWORD_USERNAME_LEN = 64 |
| constexpr uint8_t | PASSWORD_PASSWORD_LEN = 64 |
| constexpr uint8_t | PASSWORD_URL_LEN = 96 |
| constexpr size_t | PASSWORD_PAYLOAD_MAX |
| constexpr size_t | PASSWORD_FIXED_PAYLOAD |
| constexpr size_t | PASSWORD_NOTES_LEN = PASSWORD_PAYLOAD_MAX - PASSWORD_FIXED_PAYLOAD |
| constexpr ui::I18nEntry | kStrings [] |
| static constexpr const char * | CMD_MODULE = "password" |
| Serial command handlers for password module. | |
| static bool | s_commandsRegistered = false |
| static const cdc::serial::SubCommand | kPasswordSubs [] |
| static ui::ListView | s_listView |
| Password module UI state and reusable view instances. | |
| static ui::T9InputView | s_t9Input |
| static ui::InfoView | s_infoView |
| static bool | s_viewsInitialized = false |
| static ui::ListItem * | s_listItems = nullptr |
| static PasswordStore::EntryIndex * | s_entries = nullptr |
| static uint16_t | s_entryCount = 0 |
| static uint16_t | s_capacity = 0 |
| static uint16_t | s_activeSlot = 0 |
| static WizardState | s_wizard = {} |
| static constexpr uint16_t | NOTES_INPUT_MAX |
| static char | s_passwordToType [PasswordStore::PASSWORD_LEN+1] = {} |
| Shared output buffer used for keyboard typing callback payload. | |
| static constexpr int | kSchemaVer = 1 |
| Schema version written to and expected from the password backup section. | |
|
static |
Definition at line 405 of file PasswordModule.cpp.
References cdc::serial::dispatchSubCommand(), and kPasswordSubs.
Referenced by registerCommands().
|
static |
Definition at line 186 of file PasswordModule.cpp.
References generateRandomPassword(), cdc::mod_password::PasswordStore::instance(), isPlaceholder(), isValidSlot(), nextToken(), cdc::mod_password::PasswordEntry::notes, cdc::mod_password::PasswordEntry::password, cdc::mod_password::PasswordStore::PASSWORD_LEN, cdc::serial::Console::printf(), skipSpaces(), cdc::mod_password::PasswordEntry::title, cdc::mod_password::PasswordStore::TITLE_LEN, cdc::mod_password::PasswordStore::TOTP_SLOT_NONE, cdc::mod_password::PasswordEntry::totpSlot, cdc::core::unescapeSpaces(), cdc::mod_password::PasswordEntry::url, cdc::mod_password::PasswordStore::URL_LEN, cdc::mod_password::PasswordEntry::username, and cdc::mod_password::PasswordStore::USERNAME_LEN.
|
static |
Serial command handler deleting one password entry by index.
| args | Command arguments (<index>). |
Definition at line 380 of file PasswordModule.cpp.
References cdc::mod_password::PasswordStore::deleteEntry(), cdc::mod_password::PasswordStore::instance(), isValidSlot(), nextToken(), and cdc::serial::Console::printf().
|
static |
Serial command handler editing one field of a password entry. Usage: PASSWORD_EDIT <index> <field> <new value...> Field: title | username | password | url | totp | notes.
Definition at line 284 of file PasswordModule.cpp.
References cdc::mod_password::PasswordStore::instance(), isValidSlot(), nextToken(), cdc::mod_password::PasswordEntry::notes, cdc::mod_password::PasswordStore::NOTES_LEN, cdc::mod_password::PasswordEntry::password, cdc::mod_password::PasswordStore::PASSWORD_LEN, cdc::serial::Console::printf(), skipSpaces(), cdc::mod_password::PasswordEntry::title, cdc::mod_password::PasswordStore::TITLE_LEN, cdc::mod_password::PasswordEntry::totpSlot, cdc::core::unescapeSpaces(), cdc::mod_password::PasswordStore::updateEntry(), cdc::mod_password::PasswordEntry::url, cdc::mod_password::PasswordStore::URL_LEN, cdc::mod_password::PasswordEntry::username, and cdc::mod_password::PasswordStore::USERNAME_LEN.
|
static |
Serial command handler printing one password entry by index.
| args | Command arguments (<index>). |
Definition at line 120 of file PasswordModule.cpp.
References cdc::mod_password::PasswordStore::instance(), isValidSlot(), nextToken(), cdc::mod_password::PasswordEntry::notes, cdc::mod_password::PasswordEntry::password, cdc::serial::Console::printf(), cdc::mod_password::PasswordEntry::title, cdc::mod_password::PasswordStore::TOTP_SLOT_NONE, cdc::mod_password::PasswordEntry::totpSlot, cdc::mod_password::PasswordEntry::url, and cdc::mod_password::PasswordEntry::username.
|
static |
Serial command handler listing all password entries.
| args | Unused command arguments. |
Definition at line 85 of file PasswordModule.cpp.
References cdc::mod_password::PasswordStore::instance(), and cdc::serial::Console::printf().
|
static |
Copies text into bounded destination buffer.
| dst | Destination buffer. |
| dstSize | Destination size. |
| src | Source string. |
Definition at line 33 of file PasswordStore.cpp.
Referenced by cdc::mod_password::PasswordStore::addEntry(), cdc::mod_password::PasswordStore::listEntriesSorted(), cdc::mod_password::PasswordStore::readEntry(), and cdc::mod_password::PasswordStore::updateEntry().
|
static |
Ensures list and entry buffers are allocated for current store capacity.
Definition at line 465 of file PasswordModule.cpp.
References cdc::mod_password::PasswordStore::capacity(), cdc::mod_password::PasswordStore::instance(), s_capacity, s_entries, and s_listItems.
Referenced by rebuildList().
|
static |
Releases dynamic buffers used by the password list view.
Definition at line 452 of file PasswordModule.cpp.
References s_capacity, s_entries, s_entryCount, and s_listItems.
Referenced by cdc::mod_password::PasswordModule::stop().
|
static |
Generates a 16-character random password from charset a-zA-Z0-9$!%=.
| out | Output buffer (must hold at least 17 bytes). |
Definition at line 161 of file PasswordModule.cpp.
References cdc::hal::getSecureElementInstance().
Referenced by cmd_password_add(), and onWizardPassword().
|
static |
Maps and upserts one vault entry from its JSON representation.
Title is the entry's identity: an existing entry with the same title is overwritten (backup wins), otherwise a new slot is allocated. Returns false for malformed entries or storage failures so the caller can tally them as failed.
| je | JSON array element. |
| user | Unused. |
Definition at line 998 of file PasswordModule.cpp.
References cdc::mod_password::PasswordStore::instance(), LOG_W, cdc::mod_password::PasswordEntry::notes, cdc::mod_password::PasswordEntry::password, TAG, cdc::mod_password::PasswordEntry::title, cdc::mod_password::PasswordStore::TOTP_SLOT_NONE, cdc::mod_password::PasswordEntry::totpSlot, cdc::mod_password::PasswordEntry::url, and cdc::mod_password::PasswordEntry::username.
Referenced by cdc::mod_password::PasswordModule::importBackup().
|
static |
Serial command handler adding one password entry.
| args | Command arguments (<title> <username|- > <password> <url|- > [totpSlot] [notes]). |
Definition at line 153 of file PasswordModule.cpp.
Referenced by cmd_password_add().
|
static |
Validates that a slot number is within the configured password range.
| slot | Logical slot number. |
Definition at line 76 of file PasswordModule.cpp.
References cdc::mod_password::PasswordStore::instance().
Referenced by cmd_password_add(), cmd_password_del(), cmd_password_edit(), and cmd_password_get().
|
inline |
Extracts one whitespace-delimited token from a string.
Supports \ (backslash-space) as an escaped literal space inside a token, so tokens may contain space characters when escaped.
| s | Input cursor position. |
| out | Output token buffer (will be null-terminated on success). |
| outSize | Output buffer capacity. |
Definition at line 31 of file StringUtils.h.
Referenced by cmd_password_add(), cmd_password_del(), cmd_password_edit(), and cmd_password_get().
|
static |
Opens contextual action menu for selected list entry.
| index | Selected row index. |
| userData | Optional user pointer (unused). |
Definition at line 805 of file PasswordModule.cpp.
References onMenuDelete(), onMenuEdit(), onMenuView(), s_activeSlot, s_entries, s_entryCount, cdc::ui::showContextMenu(), cdc::ui::tr(), and wizardStart().
Referenced by cdc::mod_password::PasswordModule::getMenuItems().
|
static |
Handles direct selection from list view (view existing or add new).
| index | Selected row index. |
| userData | Optional user pointer (unused). |
Definition at line 830 of file PasswordModule.cpp.
References s_activeSlot, s_entries, s_entryCount, showDetails(), and wizardStart().
Referenced by cdc::mod_password::PasswordModule::getMenuItems().
|
static |
Opens delete confirmation dialog for currently active entry.
Definition at line 793 of file PasswordModule.cpp.
References onMenuDeleteConfirm(), s_activeSlot, cdc::ui::showConfirm(), cdc::ui::tr(), and cdc::ui::ConfirmView::WARNING.
Referenced by onListMenu().
|
static |
Confirmation callback deleting selected entry slot.
| userData | Pointer to selected slot value. |
Definition at line 777 of file PasswordModule.cpp.
References cdc::mod_password::PasswordStore::deleteEntry(), cdc::mod_password::PasswordStore::instance(), cdc::ui::ViewStack::instance(), cdc::ui::ViewStack::popToAnchor(), rebuildList(), s_listView, cdc::ui::showToastError(), cdc::ui::showToastSuccess(), and cdc::ui::tr().
Referenced by onMenuDelete().
|
static |
Opens edit wizard for currently active entry.
Definition at line 769 of file PasswordModule.cpp.
References s_activeSlot, and wizardEdit().
Referenced by onListMenu().
|
static |
Opens details view for currently active entry.
Definition at line 762 of file PasswordModule.cpp.
References s_activeSlot, and showDetails().
Referenced by onListMenu().
|
static |
Types currently selected password through attached keyboard provider.
| userData | Optional user pointer (unused). |
Definition at line 529 of file PasswordModule.cpp.
References cdc::core::getKeyboard(), s_passwordToType, cdc::ui::showToastError(), cdc::ui::showToastSuccess(), and cdc::ui::tr().
Referenced by showDetails().
|
static |
Saves notes field and completes wizard persistence.
| text | Entered notes text. |
Definition at line 753 of file PasswordModule.cpp.
References s_wizard, and wizardFinish().
Referenced by onWizardTotp().
|
static |
Saves password field; an "x" input generates a random 16-char password via the shared generator. Then advances to URL step.
| text | Entered password text. |
Definition at line 702 of file PasswordModule.cpp.
References generateRandomPassword(), onWizardUrl(), pushT9WizardStep(), s_wizard, cdc::ui::tr(), and cdc::mod_password::PasswordStore::URL_LEN.
Referenced by onWizardUsername().
|
static |
Saves title field and advances to username step.
| text | Entered title text. |
Definition at line 678 of file PasswordModule.cpp.
References onWizardUsername(), pushT9WizardStep(), s_wizard, cdc::ui::tr(), and cdc::mod_password::PasswordStore::USERNAME_LEN.
Referenced by wizardEdit(), and wizardStart().
|
static |
Validates and saves optional TOTP slot, then advances to notes step.
| text | Entered TOTP slot text. |
Definition at line 733 of file PasswordModule.cpp.
References NOTES_INPUT_MAX, onWizardNotes(), onWizardTotp(), pushT9WizardStep(), s_wizard, cdc::ui::showToastError(), cdc::mod_password::PasswordStore::TOTP_SLOT_NONE, and cdc::ui::tr().
Referenced by onWizardTotp(), and onWizardUrl().
|
static |
Saves URL field and advances to optional TOTP slot step.
| text | Entered URL text. |
Definition at line 718 of file PasswordModule.cpp.
References onWizardTotp(), pushT9WizardStep(), s_wizard, cdc::mod_password::PasswordStore::TOTP_SLOT_NONE, and cdc::ui::tr().
Referenced by onWizardPassword().
|
static |
Saves username field and advances to password step.
| text | Entered username text. |
Definition at line 688 of file PasswordModule.cpp.
References cdc::ui::ViewStack::instance(), onWizardPassword(), cdc::mod_password::PasswordStore::PASSWORD_LEN, cdc::ui::ViewStack::push(), s_t9Input, s_wizard, and cdc::ui::tr().
Referenced by onWizardTitle().
|
static |
Pushes a configured T9 input step for wizard flow.
| title | Step title. |
| initialText | Initial input text. |
| maxLen | Maximum accepted text length. |
| onSave | Save callback for this step. |
Definition at line 629 of file PasswordModule.cpp.
References cdc::ui::ViewStack::instance(), cdc::ui::ViewStack::push(), and s_t9Input.
Referenced by onWizardPassword(), onWizardTitle(), onWizardTotp(), onWizardUrl(), wizardEdit(), and wizardStart().
|
static |
Rebuilds password list items from sorted store entries.
Definition at line 493 of file PasswordModule.cpp.
References ensureListBuffers(), cdc::core::ModuleRegistry::instance(), cdc::mod_password::PasswordModule::instance(), cdc::mod_password::PasswordStore::instance(), cdc::mod_password::PasswordStore::listEntriesSorted(), cdc::core::ModuleRegistry::reportModuleError(), s_capacity, s_entries, s_entryCount, s_listItems, s_listView, cdc::ui::showToastError(), and cdc::ui::tr().
Referenced by cdc::mod_password::PasswordModule::getMenuItems(), onMenuDeleteConfirm(), and wizardFinish().
|
static |
Registers serial commands exposed by the password module.
Definition at line 412 of file PasswordModule.cpp.
References CMD_MODULE, cmd_password(), cdc::serial::getCommandRegistry(), kPasswordSubs, and s_commandsRegistered.
Referenced by cdc::mod_password::PasswordModule::init().
|
static |
Definition at line 59 of file PasswordModule.cpp.
References cdc::ui::I18n::instance(), kStrings, and cdc::ui::I18n::registerEnglishTable().
Referenced by cdc::mod_password::PasswordModule::init().
|
static |
Shows full entry details in the info view for a slot.
| slot | Logical password slot. |
Definition at line 546 of file PasswordModule.cpp.
References cdc::core::getKeyboard(), cdc::mod_password::PasswordStore::instance(), cdc::ui::ViewStack::instance(), cdc::ui::InfoView::MAX_TEXT_LEN, cdc::mod_password::PasswordEntry::notes, onTypePassword(), cdc::mod_password::PasswordEntry::password, cdc::ui::ViewStack::push(), s_infoView, s_passwordToType, cdc::ui::showToastError(), cdc::mod_password::PasswordEntry::title, cdc::mod_password::PasswordStore::TOTP_SLOT_NONE, cdc::mod_password::PasswordEntry::totpSlot, cdc::ui::tr(), cdc::mod_password::PasswordEntry::url, and cdc::mod_password::PasswordEntry::username.
Referenced by onListSelect(), and onMenuView().
|
inline |
Advances over leading ASCII whitespace in a C string.
| s | Input string pointer. |
Definition at line 13 of file StringUtils.h.
Referenced by cmd_password_add(), and cmd_password_edit().
|
static |
Starts edit-entry wizard prefilled with existing slot data.
| slot | Logical slot to edit. |
Definition at line 659 of file PasswordModule.cpp.
References cdc::mod_password::PasswordStore::instance(), onWizardTitle(), pushT9WizardStep(), s_wizard, cdc::ui::showToastError(), cdc::mod_password::PasswordStore::TITLE_LEN, and cdc::ui::tr().
Referenced by onMenuEdit().
|
static |
Persists wizard add/edit changes and returns to list view.
Definition at line 604 of file PasswordModule.cpp.
References cdc::mod_password::PasswordStore::addEntry(), cdc::mod_password::PasswordStore::instance(), cdc::ui::ViewStack::instance(), cdc::ui::ViewStack::popToAnchor(), rebuildList(), s_listView, s_wizard, cdc::ui::showToastError(), cdc::ui::showToastSuccess(), cdc::ui::tr(), and cdc::mod_password::PasswordStore::updateEntry().
Referenced by onWizardNotes().
|
static |
Starts add-entry wizard with empty fields.
Definition at line 646 of file PasswordModule.cpp.
References onWizardTitle(), pushT9WizardStep(), s_wizard, cdc::mod_password::PasswordStore::TITLE_LEN, cdc::mod_password::PasswordStore::TOTP_SLOT_NONE, and cdc::ui::tr().
Referenced by onListMenu(), and onListSelect().
|
staticconstexpr |
Serial command handlers for password module.
Definition at line 65 of file PasswordModule.cpp.
Referenced by registerCommands().
|
static |
Definition at line 396 of file PasswordModule.cpp.
Referenced by cmd_password(), and registerCommands().
|
staticconstexpr |
Schema version written to and expected from the password backup section.
Definition at line 926 of file PasswordModule.cpp.
Referenced by cdc::mod_password::PasswordModule::exportBackup(), and cdc::mod_password::PasswordModule::importBackup().
|
constexpr |
Definition at line 35 of file PasswordModule.cpp.
Referenced by registerStrings().
|
staticconstexpr |
Definition at line 444 of file PasswordModule.cpp.
Referenced by onWizardTotp().
|
constexpr |
Definition at line 18 of file PasswordStore.h.
|
constexpr |
Definition at line 20 of file PasswordStore.h.
|
constexpr |
Definition at line 13 of file PasswordStore.h.
|
constexpr |
Definition at line 16 of file PasswordStore.h.
|
constexpr |
Definition at line 11 of file PasswordStore.h.
|
constexpr |
Definition at line 14 of file PasswordStore.h.
|
constexpr |
Definition at line 12 of file PasswordStore.h.
|
static |
Definition at line 434 of file PasswordModule.cpp.
Referenced by onListMenu(), onListSelect(), onMenuDelete(), onMenuEdit(), and onMenuView().
|
static |
Definition at line 432 of file PasswordModule.cpp.
Referenced by ensureListBuffers(), freeListBuffers(), and rebuildList().
|
static |
Definition at line 66 of file PasswordModule.cpp.
Referenced by registerCommands().
|
static |
Definition at line 430 of file PasswordModule.cpp.
Referenced by ensureListBuffers(), freeListBuffers(), onListMenu(), onListSelect(), and rebuildList().
|
static |
Definition at line 431 of file PasswordModule.cpp.
Referenced by freeListBuffers(), onListMenu(), onListSelect(), and rebuildList().
|
static |
Definition at line 426 of file PasswordModule.cpp.
Referenced by showDetails().
|
static |
Definition at line 429 of file PasswordModule.cpp.
Referenced by ensureListBuffers(), freeListBuffers(), and rebuildList().
|
static |
Password module UI state and reusable view instances.
Definition at line 424 of file PasswordModule.cpp.
Referenced by cdc::mod_password::PasswordModule::getMenuItems(), onMenuDeleteConfirm(), rebuildList(), and wizardFinish().
|
static |
Shared output buffer used for keyboard typing callback payload.
Definition at line 523 of file PasswordModule.cpp.
Referenced by onTypePassword(), and showDetails().
|
static |
Definition at line 425 of file PasswordModule.cpp.
Referenced by onWizardUsername(), and pushT9WizardStep().
|
static |
Definition at line 427 of file PasswordModule.cpp.
Referenced by cdc::mod_password::PasswordModule::getMenuItems().
|
static |
Definition at line 442 of file PasswordModule.cpp.
Referenced by onWizardNotes(), onWizardPassword(), onWizardTitle(), onWizardTotp(), onWizardUrl(), onWizardUsername(), wizardEdit(), wizardFinish(), and wizardStart().