CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
PasswordModule.cpp File Reference
#include "mod_password/PasswordModule.h"
#include "mod_password/PasswordStore.h"
#include "cdc_core/ModuleRegistry.h"
#include "cdc_core/StringUtils.h"
#include "cdc_core/TropicStorage.h"
#include "cdc_ui/BackupImport.h"
#include "cdc_core/IKeyboardProvider.h"
#include "cJSON.h"
#include "cdc_hal/ISecureElement.h"
#include "esp_random.h"
#include "cdc_ui/I18n.h"
#include "cdc_ui/ViewStack.h"
#include "cdc_views/ListView.h"
#include "cdc_views/ContextMenuView.h"
#include "cdc_views/T9InputView.h"
#include "cdc_views/InfoView.h"
#include "cdc_views/ConfirmView.h"
#include "cdc_views/ToastView.h"
#include "serial_cmd/ICommandRegistry.h"
#include "serial_cmd/SubCommand.h"
#include "serial_cmd/Console.h"
#include "cdc_log.h"
#include "esp_attr.h"
#include <cctype>
#include <cstring>
#include <strings.h>
#include <new>
#include <memory>
#include <cstdio>

Go to the source code of this file.

Classes

struct  cdc::mod_password::WizardState

Namespaces

namespace  cdc
namespace  cdc::mod_password

Functions

static void cdc::mod_password::registerStrings ()
static bool cdc::mod_password::isValidSlot (uint16_t slot)
 Validates that a slot number is within the configured password range.
static void cdc::mod_password::cmd_password_list (const char *args)
 Serial command handler listing all password entries.
static void cdc::mod_password::cmd_password_get (const char *args)
 Serial command handler printing one password entry by index.
static bool cdc::mod_password::isPlaceholder (const char *s)
 Serial command handler adding one password entry.
static void cdc::mod_password::generateRandomPassword (char *out, size_t outSize)
 Generates a 16-character random password from charset a-zA-Z0-9$!%=.
static void cdc::mod_password::cmd_password_add (const char *args)
static void cdc::mod_password::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 cdc::mod_password::cmd_password_del (const char *args)
 Serial command handler deleting one password entry by index.
static void cdc::mod_password::cmd_password (const char *args)
static void cdc::mod_password::registerCommands ()
 Registers serial commands exposed by the password module.
static void cdc::mod_password::freeListBuffers ()
 Releases dynamic buffers used by the password list view.
static bool cdc::mod_password::ensureListBuffers ()
 Ensures list and entry buffers are allocated for current store capacity.
static void cdc::mod_password::rebuildList ()
 Rebuilds password list items from sorted store entries.
static void cdc::mod_password::onTypePassword (void *userData)
 Types currently selected password through attached keyboard provider.
static void cdc::mod_password::showDetails (uint16_t slot)
 Shows full entry details in the info view for a slot.
static void cdc::mod_password::wizardFinish ()
 Persists wizard add/edit changes and returns to list view.
static void cdc::mod_password::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 cdc::mod_password::onWizardTitle (const char *text)
 Saves title field and advances to username step.
static void cdc::mod_password::onWizardUsername (const char *text)
 Saves username field and advances to password step.
static void cdc::mod_password::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 cdc::mod_password::onWizardUrl (const char *text)
 Saves URL field and advances to optional TOTP slot step.
static void cdc::mod_password::onWizardTotp (const char *text)
 Validates and saves optional TOTP slot, then advances to notes step.
static void cdc::mod_password::onWizardNotes (const char *text)
 Saves notes field and completes wizard persistence.
static void cdc::mod_password::wizardStart ()
 Starts add-entry wizard with empty fields.
static void cdc::mod_password::wizardEdit (uint16_t slot)
 Starts edit-entry wizard prefilled with existing slot data.
static void cdc::mod_password::onMenuView ()
 Opens details view for currently active entry.
static void cdc::mod_password::onMenuEdit ()
 Opens edit wizard for currently active entry.
static void cdc::mod_password::onMenuDeleteConfirm (void *userData)
 Confirmation callback deleting selected entry slot.
static void cdc::mod_password::onMenuDelete ()
 Opens delete confirmation dialog for currently active entry.
static void cdc::mod_password::onListMenu (uint16_t index, void *userData)
 Opens contextual action menu for selected list entry.
static void cdc::mod_password::onListSelect (uint16_t index, void *userData)
 Handles direct selection from list view (view existing or add new).
static bool cdc::mod_password::importPasswordEntry (const cJSON *je, void *user)
 Maps and upserts one vault entry from its JSON representation.
void mod_password_register ()
 Registers password module initializer in global module registry.
const char * cdc::mod_password::skipSpaces (const char *s)
 Advances over leading ASCII whitespace in a C string.
const char * cdc::mod_password::nextToken (const char *s, char *out, size_t outSize)
 Extracts one whitespace-delimited token from a string.

Variables

static const char * TAG = "PASSWORD"
constexpr ui::I18nEntry cdc::mod_password::kStrings []
static constexpr const char * cdc::mod_password::CMD_MODULE = "password"
 Serial command handlers for password module.
static bool cdc::mod_password::s_commandsRegistered = false
static const cdc::serial::SubCommand cdc::mod_password::kPasswordSubs []
static ui::ListView cdc::mod_password::s_listView
 Password module UI state and reusable view instances.
static ui::T9InputView cdc::mod_password::s_t9Input
static ui::InfoView cdc::mod_password::s_infoView
static bool cdc::mod_password::s_viewsInitialized = false
static ui::ListItemcdc::mod_password::s_listItems = nullptr
static PasswordStore::EntryIndexcdc::mod_password::s_entries = nullptr
static uint16_t cdc::mod_password::s_entryCount = 0
static uint16_t cdc::mod_password::s_capacity = 0
static uint16_t cdc::mod_password::s_activeSlot = 0
static WizardState cdc::mod_password::s_wizard = {}
static constexpr uint16_t cdc::mod_password::NOTES_INPUT_MAX
static char cdc::mod_password::s_passwordToType [PasswordStore::PASSWORD_LEN+1] = {}
 Shared output buffer used for keyboard typing callback payload.
static constexpr int cdc::mod_password::kSchemaVer = 1
 Schema version written to and expected from the password backup section.

Function Documentation

◆ mod_password_register()

void mod_password_register ( )

Registers password module initializer in global module registry.

Definition at line 1067 of file PasswordModule.cpp.

References cdc::core::ModuleRegistry::instance(), and cdc::core::ModuleRegistry::registerInitializer().

Variable Documentation

◆ TAG

const char* TAG = "PASSWORD"
static

Definition at line 31 of file PasswordModule.cpp.