|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
Namespaces | |
| namespace | OathFlag |
| Per-entry flag bits stored in OathEntry::flags. | |
Classes | |
| struct | OathEntry |
| Unified OATH credential record (TOTP, HOTP, and reserved CR). More... | |
| class | OathStore |
| class | TwoFaModule |
| struct | PendingChallenge |
| Pending challenge handed from the BLE host task to the main task. More... | |
| struct | PendingConfirm |
| Response awaiting an on-device touch confirmation. More... | |
| struct | OathPayload |
| class | OathCodeView |
| struct | WizardState |
Enumerations | |
| enum class | OathAlgorithm : uint8_t { SHA1 = 0 , SHA256 = 1 , SHA512 = 2 } |
| Hash algorithm used by an OATH entry's HMAC engine. More... | |
| enum class | OathType : uint8_t { TOTP = 0 , HOTP = 1 , CR = 2 } |
| OATH entry type discriminator. More... | |
Functions | |
| bool | ble_chalresp_init () |
| BLE GATT challenge-response transport. | |
| void | ble_chalresp_deinit () |
| Tears down the BLE CR subsystem and removes GATT callbacks. | |
| void | ble_chalresp_tick (uint32_t nowMs) |
| Main-task tick: processes a pending challenge (confirm + notify). | |
| static IBluetoothController * | getBle () |
| Returns shared Bluetooth controller instance. | |
| static void | notifyResponse (uint16_t connHandle, const uint8_t *data, size_t len) |
| Sends a response notification to the requesting connection. | |
| static void | deliverConfirmedResponse () |
| Computes and notifies the response stashed in s_confirm. | |
| static void | onTouchConfirm (void *userData) |
| Touch-confirm accepted: notify the prepared response. | |
| static void | onTouchCancel (void *userData) |
| Touch-confirm declined: discard the prepared response. | |
| static int | onChallengeWrite (uint16_t connHandle, uint16_t, const uint8_t *data, uint16_t len) |
| GATT challenge write callback (BLE host task). | |
| static bool | registerGattService () |
| Registers the CR GATT service and characteristics. | |
| static void | onDisconnect (uint16_t connHandle, int reason) |
| Clears pending request state if the requesting peer disconnects. | |
| static bool | validateOathParams (uint8_t type, uint8_t &digits, uint32_t &period, uint8_t &algorithm) |
| Validates OATH entry parameters and clamps to defaults when invalid. | |
| static int | base32CharValue (char c) |
| Converts one Base32 character into 5-bit value. | |
| static int | base32Decode (const char *encoded, uint8_t *out, size_t outMax) |
| Decodes Base32 secret into raw bytes. | |
| static bool | writePayload (uint16_t physSlot, const char *name, uint8_t type, const char *issuer, const uint8_t *secret, uint8_t secretLen, uint8_t digits, uint32_t period, uint64_t counter, uint8_t algorithm, uint8_t flags) |
| Builds and persists an OATH payload to a physical slot. | |
| static void | formatCode (uint32_t code, uint8_t digits, char *codeOut, size_t codeOutLen) |
Formats a numeric code into codeOut with leading zeros. | |
| static void | registerStrings () |
| static uint8_t | parseAlgo (const char *token) |
| Parses textual or numeric algorithm identifiers into store values. | |
| static uint8_t | parseType (const char *token) |
| Parses a textual or numeric entry-type token. | |
| static bool | findSlotByIndex (uint16_t index, uint16_t *slotOut) |
| Resolves a displayed list index to the logical OATH slot number. | |
| static void | cmd_totp_list (const char *args) |
| Serial command handler printing all configured OATH entries. | |
| static void | cmd_totp_add (const char *args) |
| Serial command handler adding an OATH entry from tokens. | |
| static void | cmd_totp_del (const char *args) |
| Serial command handler deleting an OATH entry by index. | |
| static void | cmd_totp_get (const char *args) |
| Serial command handler generating one code by index. | |
| static int | hexDecode (const char *hex, uint8_t *out, size_t outMax) |
| Decodes a hex string into bytes. | |
| static void | cmd_chalresp (const char *args) |
| Serial command computing a raw challenge-response for a named CR entry. | |
| static void | cmd_totp (const char *args) |
| static void | registerCommands () |
| Registers serial commands exposed by the 2FA module. | |
| static void | wizardEdit (uint16_t slot) |
| OATH code detail view implementation. | |
| static void | pushT9WizardStep (const char *title, const char *initialText, uint16_t maxLen, ui::T9InputView::SaveCallback onSave) |
| Pushes a configured T9 input step for the account wizard flow. | |
| static void | freeListBuffers () |
| Frees dynamically allocated list buffers used by the account list. | |
| static void | rebuildList () |
| Rebuilds the account list view content from Tropic storage cache. | |
| static void | onListSelect (uint16_t index, void *userData) |
| Handles selection from the account list. | |
| static void | wizardStart () |
| Starts the add-account wizard with default values. | |
| static void | onWizardType (uint16_t index, void *userData) |
| Saves selected entry type and opens the name step. | |
| static void | onWizardName (const char *text) |
| Saves wizard account name and opens secret step. | |
| static void | onWizardSecret (const char *text) |
| Saves wizard secret and opens issuer step. | |
| static void | onWizardIssuer (const char *text) |
| Saves wizard issuer and opens digit-selection step. | |
| static void | onWizardDigits (uint16_t index, void *userData) |
| Saves selected code length and opens algorithm-selection step. | |
| static void | onWizardAlgo (uint16_t index, void *userData) |
| Saves selected algorithm; opens period step (TOTP) or finishes (HOTP). | |
| static void | onWizardPeriod (uint16_t index, void *userData) |
| Saves selected period and finalizes add/edit operation. | |
| static void | onWizardTouch (uint16_t index, void *userData) |
| Saves the CR touch-confirm choice and finalizes the entry. | |
| static void | onWizardUsbCr (uint16_t index, void *userData) |
| Saves the USB-CR-slot designation and finalizes the entry. | |
| static void | pushAlgoStep () |
| Pushes the algorithm-selection step. | |
| static void | pushTouchStep () |
| Pushes the CR touch-confirm toggle step. | |
| static void | pushUsbCrStep () |
| Pushes the CR USB-slot-2 designation step. | |
| static void | wizardFinish () |
| Validates wizard data and persists account changes. | |
| static void | base32Encode (const uint8_t *data, size_t dataLen, char *out, size_t outMax) |
| Encodes binary secret bytes into unpadded Base32 text. | |
| static bool | ensureListBuffers () |
| Ensures account list backing buffers are allocated for current capacity. | |
| static bool | importOathEntry (const cJSON *entry, void *user) |
| Maps and upserts one OATH entry from its JSON representation. | |
| 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 | |
| static const uint8_t | CR_SVC_UUID [16] |
| CR service UUID: 8E2F1F30-8B5D-4D7A-9A6E-4C9D6A8B1A01 (little-endian). | |
| static const uint8_t | CR_CHALLENGE_UUID [16] |
| Challenge characteristic UUID (...1F31...), write. | |
| static const uint8_t | CR_RESPONSE_UUID [16] |
| Response characteristic UUID (...1F32...), read + notify. | |
| static constexpr uint16_t | INVALID_HANDLE = 0xFFFF |
| static constexpr size_t | MAX_NAME_LEN = 16 |
| Max challenge payload (entry name + NUL + challenge bytes) accepted per write. | |
| static constexpr size_t | MAX_CHALLENGE_LEN = 128 |
| static constexpr size_t | MAX_FRAME_LEN = MAX_NAME_LEN + 1 + MAX_CHALLENGE_LEN |
| static bool | s_initialized = false |
| static uint16_t | s_challenge_handle = 0 |
| static uint16_t | s_response_handle = 0 |
| static GattCharacteristic | s_gattChars [2] = {} |
| static GattServiceDef | s_gattSvcDef = {} |
| static IBluetoothController::ListenerToken | s_tokDisconn = IBluetoothController::INVALID_LISTENER |
| static SemaphoreHandle_t | s_mutex = nullptr |
| static uint8_t | s_challengeBuf [MAX_CHALLENGE_LEN] = {} |
| static PendingChallenge | s_pending = {} |
| static PendingConfirm | s_confirm = {} |
| static constexpr uint8_t | OATH_DIGITS_MIN = 6 |
| Allowed OATH digit count range per RFC 4226 / RFC 6238. | |
| static constexpr uint8_t | OATH_DIGITS_MAX = 8 |
| static constexpr uint32_t | TOTP_PERIOD_MIN = 15 |
| Allowed TOTP period range in seconds. | |
| static constexpr uint32_t | TOTP_PERIOD_MAX = 300 |
| static const uint32_t | POWERS_10 [] |
| constexpr ui::I18nEntry | kStrings [] |
| static constexpr const char * | CMD_MODULE = "totp" |
| Serial command handlers for 2FA module. | |
| static constexpr size_t | SECRET_B32_LEN = 128 |
| static bool | s_commandsRegistered = false |
| static const cdc::serial::SubCommand | kTotpSubs [] |
| Sub-command table for the TOTP serial command group. | |
| static ui::ListView | s_listView |
| 2FA module UI state. | |
| static ui::T9InputView | s_t9Input |
| static ui::ListView | s_typeMenu |
| static ui::ListView | s_digitsMenu |
| static ui::ListView | s_algoMenu |
| static ui::ListView | s_periodMenu |
| static ui::ListView | s_touchMenu |
| static ui::ListView | s_usbCrMenu |
| static OathCodeView | s_codeView |
| static bool | s_viewsInitialized = false |
| static ui::ListItem * | s_listItems = nullptr |
| Dynamic list buffers released by freeListBuffers. | |
| static char(* | s_listLabels )[24] = nullptr |
| static uint16_t * | s_listSlots = nullptr |
| static uint16_t | s_accountCount = 0 |
| static uint16_t | s_capacity = 0 |
| static WizardState | s_wizard = {} |
| static constexpr int | kSchemaVer = 1 |
| Schema version written to and expected from the 2FA backup section. | |
| static constexpr size_t | kBase32BufLen = 103 + 1 |
| Maximum Base32 string length for the longest supported secret (64 bytes raw). | |
|
strong |
Hash algorithm used by an OATH entry's HMAC engine.
| Enumerator | |
|---|---|
| SHA1 | |
| SHA256 | |
| SHA512 | |
Definition at line 14 of file OathStore.h.
|
strong |
|
static |
Converts one Base32 character into 5-bit value.
| c | Input character. |
Definition at line 98 of file OathStore.cpp.
Referenced by base32Decode().
|
static |
Decodes Base32 secret into raw bytes.
| encoded | Base32 input string. |
| out | Output byte buffer. |
| outMax | Output capacity. |
Definition at line 112 of file OathStore.cpp.
References base32CharValue().
Referenced by cdc::mod_2fa::OathStore::addAccount(), and cdc::mod_2fa::OathStore::updateAccount().
|
static |
Encodes binary secret bytes into unpadded Base32 text.
| data | Input binary payload. |
| dataLen | Input length in bytes. |
| out | Output Base32 buffer. |
| outMax | Output buffer size. |
Definition at line 809 of file TwoFaModule.cpp.
Referenced by cdc::mod_2fa::TwoFaModule::exportBackup(), and wizardEdit().
| void cdc::mod_2fa::ble_chalresp_deinit | ( | ) |
Tears down the BLE CR subsystem and removes GATT callbacks.
Definition at line 280 of file ble_chalresp.cpp.
References CR_SVC_UUID, BleUuid::from128(), getBle(), IBluetoothController::INVALID_LISTENER, s_confirm, s_initialized, s_mutex, s_pending, and s_tokDisconn.
Referenced by cdc::mod_2fa::TwoFaModule::stop().
| bool cdc::mod_2fa::ble_chalresp_init | ( | ) |
BLE GATT challenge-response transport.
Initializes the BLE CR subsystem and registers the GATT service.
Exposes a small GATT service with a write characteristic (challenge) and a notify characteristic (response). A connected host writes a challenge frame, the badge optionally requires an on-device touch confirmation, computes the raw HMAC via the registered IChallengeResponder, and notifies the result.
Implemented purely through IBluetoothController; this file never touches NimBLE directly. The write callback runs on the BLE host task and only records the pending request; ble_chalresp_tick() (main task) performs the confirmation and notification so the E-Paper UI is touched only there.
Initializes the BLE CR subsystem and registers the GATT service.
Definition at line 238 of file ble_chalresp.cpp.
References getBle(), LOG_E, LOG_I, onDisconnect(), registerGattService(), s_initialized, s_mutex, s_tokDisconn, and TAG.
Referenced by cdc::mod_2fa::TwoFaModule::init().
| void cdc::mod_2fa::ble_chalresp_tick | ( | uint32_t | nowMs | ) |
Main-task tick: processes a pending challenge (confirm + notify).
| nowMs | Current uptime in milliseconds. |
Definition at line 298 of file ble_chalresp.cpp.
References cdc::mod_2fa::OathStore::challengeResponse(), deliverConfirmedResponse(), cdc::mod_2fa::OathStore::instance(), INVALID_HANDLE, LOG_W, MAX_CHALLENGE_LEN, MAX_NAME_LEN, cdc::core::IChallengeResponder::MAX_RESPONSE_LEN, name, onTouchCancel(), onTouchConfirm(), cdc::ui::ConfirmView::QUESTION, s_challengeBuf, s_confirm, s_initialized, s_mutex, s_pending, cdc::ui::showConfirm(), TAG, and cdc::ui::tr().
Referenced by cdc::mod_2fa::TwoFaModule::onTick().
|
static |
Serial command computing a raw challenge-response for a named CR entry.
Looks up the CR entry by name, computes HMAC(secret, challenge) using the entry's algorithm (SHA1 or SHA256), and prints the hex response. The serial path is trusted (AUTH-gated) and does not require a touch confirmation.
| args | Command arguments (<name> <hex-challenge>). |
Definition at line 365 of file TwoFaModule.cpp.
References cdc::mod_2fa::OathStore::challengeResponse(), hexDecode(), cdc::mod_2fa::OathStore::instance(), cdc::core::IChallengeResponder::MAX_RESPONSE_LEN, name, cdc::mod_2fa::OathStore::NAME_LEN, nextToken(), and cdc::serial::Console::printf().
Referenced by registerCommands().
|
static |
Definition at line 421 of file TwoFaModule.cpp.
References cdc::serial::dispatchSubCommand(), and kTotpSubs.
Referenced by registerCommands().
|
static |
Serial command handler adding an OATH entry from tokens.
| args | Command arguments (<type> <name> <secret> [issuer] [digits] [period] [algo] [counter]). |
Definition at line 207 of file TwoFaModule.cpp.
References cdc::mod_2fa::OathStore::addAccount(), cdc::mod_2fa::OathStore::DEFAULT_DIGITS, cdc::mod_2fa::OathStore::DEFAULT_PERIOD, cdc::mod_2fa::OathStore::instance(), cdc::mod_2fa::OathStore::ISSUER_LEN, name, cdc::mod_2fa::OathStore::NAME_LEN, nextToken(), parseAlgo(), parseType(), cdc::serial::Console::printf(), and SECRET_B32_LEN.
|
static |
Serial command handler deleting an OATH entry by index.
| args | Command arguments (<index>). |
Definition at line 263 of file TwoFaModule.cpp.
References cdc::mod_2fa::OathStore::deleteAccount(), findSlotByIndex(), cdc::mod_2fa::OathStore::instance(), and cdc::serial::Console::printf().
|
static |
Serial command handler generating one code by index.
For HOTP entries this advances and persists the moving counter.
| args | Command arguments (<index>). |
Definition at line 285 of file TwoFaModule.cpp.
References cdc::mod_2fa::OathEntry::counter, findSlotByIndex(), cdc::mod_2fa::OathStore::generateCode(), HOTP, cdc::mod_2fa::OathStore::instance(), cdc::mod_2fa::OathEntry::issuer, cdc::serial::Console::printf(), and cdc::mod_2fa::OathEntry::type.
|
static |
Serial command handler printing all configured OATH entries.
| args | Unused command arguments. |
Definition at line 165 of file TwoFaModule.cpp.
References CR, cdc::core::TropicStorage::forEachSlot(), HOTP, cdc::core::TropicStorage::instance(), cdc::mod_2fa::OathStore::instance(), moduleId, cdc::serial::Console::printf(), and cdc::mod_2fa::OathEntry::type.
|
static |
Computes and notifies the response stashed in s_confirm.
Runs on the main task (touch-confirm callback or direct tick path).
Definition at line 115 of file ble_chalresp.cpp.
References LOG_I, notifyResponse(), s_confirm, s_mutex, and TAG.
Referenced by ble_chalresp_tick(), and onTouchConfirm().
|
static |
Ensures account list backing buffers are allocated for current capacity.
Definition at line 843 of file TwoFaModule.cpp.
References cdc::mod_2fa::OathStore::capacity(), cdc::mod_2fa::OathStore::instance(), s_capacity, s_listItems, s_listLabels, and s_listSlots.
Referenced by rebuildList().
|
static |
Resolves a displayed list index to the logical OATH slot number.
| index | UI list index. |
| slotOut | Output logical slot. |
Definition at line 126 of file TwoFaModule.cpp.
References cdc::core::TropicStorage::forEachSlot(), cdc::core::TropicStorage::instance(), and cdc::mod_2fa::OathStore::instance().
Referenced by cmd_totp_del(), and cmd_totp_get().
|
static |
Formats a numeric code into codeOut with leading zeros.
| code | Numeric code value. |
| digits | Number of digits to pad to. |
| codeOut | Output text buffer. |
| codeOutLen | Output buffer size. |
Definition at line 505 of file OathStore.cpp.
References OATH_DIGITS_MAX, and OATH_DIGITS_MIN.
Referenced by cdc::mod_2fa::OathStore::generateCode().
|
static |
Frees dynamically allocated list buffers used by the account list.
Definition at line 773 of file TwoFaModule.cpp.
References s_accountCount, s_capacity, s_listItems, s_listLabels, and s_listSlots.
Referenced by cdc::mod_2fa::TwoFaModule::stop().
|
static |
Returns shared Bluetooth controller instance.
Definition at line 94 of file ble_chalresp.cpp.
References cdc::hal::getBluetoothControllerInstance().
Referenced by ble_chalresp_deinit(), ble_chalresp_init(), notifyResponse(), and registerGattService().
|
static |
Decodes a hex string into bytes.
| hex | Null-terminated hex text (even number of nibbles, no separators). |
| out | Output byte buffer. |
| outMax | Output capacity. |
Definition at line 334 of file TwoFaModule.cpp.
Referenced by cmd_chalresp().
|
static |
Maps and upserts one OATH entry from its JSON representation.
If an entry with the same name already exists it is overwritten (backup wins); otherwise a new slot is allocated. Malformed or unstorable entries return false so the caller can tally them as failed.
| entry | JSON array element. |
| user | Unused. |
Definition at line 1450 of file TwoFaModule.cpp.
References cdc::mod_2fa::OathStore::addAccount(), cdc::mod_2fa::OathStore::findByName(), flags, cdc::mod_2fa::OathStore::instance(), LOG_W, name, TAG, and cdc::mod_2fa::OathStore::updateAccount().
Referenced by cdc::mod_2fa::TwoFaModule::importBackup().
|
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_chalresp(), and cmd_totp_add().
|
static |
Sends a response notification to the requesting connection.
| connHandle | Connection handle. |
| data | Response bytes. |
| len | Response length. |
Definition at line 104 of file ble_chalresp.cpp.
References getBle(), INVALID_HANDLE, and s_response_handle.
Referenced by deliverConfirmedResponse().
|
static |
GATT challenge write callback (BLE host task).
Records the request only; the response is computed on the main task in ble_chalresp_tick so the touch-confirm UI is never driven from here.
| connHandle | Connection handle. |
| data | Frame bytes: NUL-terminated entry name then challenge. |
| len | Frame length. |
Definition at line 154 of file ble_chalresp.cpp.
References LOG_W, MAX_CHALLENGE_LEN, MAX_FRAME_LEN, MAX_NAME_LEN, s_challengeBuf, s_confirm, s_mutex, s_pending, and TAG.
Referenced by registerGattService().
|
static |
Clears pending request state if the requesting peer disconnects.
| connHandle | Disconnected handle. |
| reason | BLE disconnect reason (unused). |
Definition at line 223 of file ble_chalresp.cpp.
References s_confirm, s_mutex, and s_pending.
Referenced by ble_chalresp_init().
|
static |
Handles selection from the account list.
| index | Selected row index. |
| userData | Optional user pointer (unused). |
Definition at line 915 of file TwoFaModule.cpp.
References cdc::ui::ViewStack::instance(), name, cdc::ui::ViewStack::push(), s_accountCount, s_codeView, s_listLabels, s_listSlots, and wizardStart().
Referenced by cdc::mod_2fa::TwoFaModule::getMenuItems().
|
static |
Touch-confirm declined: discard the prepared response.
| userData | Unused. |
Definition at line 136 of file ble_chalresp.cpp.
References LOG_W, s_confirm, s_mutex, and TAG.
Referenced by ble_chalresp_tick().
|
static |
Touch-confirm accepted: notify the prepared response.
| userData | Unused. |
Definition at line 127 of file ble_chalresp.cpp.
References deliverConfirmedResponse().
Referenced by ble_chalresp_tick().
|
static |
Saves selected algorithm; opens period step (TOTP) or finishes (HOTP).
| index | Selected list index. |
| userData | Optional user pointer (unused). |
Definition at line 1072 of file TwoFaModule.cpp.
References CR, HOTP, cdc::ui::ViewStack::instance(), onWizardPeriod(), cdc::ui::ViewStack::push(), pushTouchStep(), s_periodMenu, s_wizard, cdc::ui::tr(), and wizardFinish().
Referenced by pushAlgoStep().
|
static |
Saves selected code length and opens algorithm-selection step.
| index | Selected list index. |
| userData | Optional user pointer (unused). |
Definition at line 1041 of file TwoFaModule.cpp.
References pushAlgoStep(), and s_wizard.
Referenced by onWizardIssuer().
|
static |
Saves wizard issuer and opens digit-selection step.
| text | Entered issuer string. |
Definition at line 1023 of file TwoFaModule.cpp.
References cdc::ui::ViewStack::instance(), onWizardDigits(), cdc::ui::ViewStack::push(), s_digitsMenu, s_wizard, and cdc::ui::tr().
Referenced by onWizardSecret().
|
static |
Saves wizard account name and opens secret step.
| text | Entered account name. |
Definition at line 1000 of file TwoFaModule.cpp.
References onWizardSecret(), pushT9WizardStep(), s_wizard, SECRET_B32_LEN, and cdc::ui::tr().
Referenced by onWizardType(), and wizardEdit().
|
static |
Saves selected period and finalizes add/edit operation.
| index | Selected list index. |
| userData | Optional user pointer (unused). |
Definition at line 1102 of file TwoFaModule.cpp.
References s_wizard, and wizardFinish().
Referenced by onWizardAlgo().
|
static |
Saves wizard secret and opens issuer step.
| text | Entered Base32 secret. |
Definition at line 1009 of file TwoFaModule.cpp.
References CR, cdc::mod_2fa::OathStore::ISSUER_LEN, onWizardIssuer(), pushAlgoStep(), pushT9WizardStep(), s_wizard, and cdc::ui::tr().
Referenced by onWizardName().
|
static |
Saves the CR touch-confirm choice and finalizes the entry.
| index | Selected list index (0 = required, 1 = not required). |
| userData | Unused. |
Definition at line 1128 of file TwoFaModule.cpp.
References pushUsbCrStep(), s_wizard, and cdc::mod_2fa::OathFlag::TOUCH_REQUIRED.
Referenced by pushTouchStep().
|
static |
Saves selected entry type and opens the name step.
| index | Selected list index. |
| userData | Optional user pointer (unused). |
Definition at line 986 of file TwoFaModule.cpp.
References CR, HOTP, cdc::mod_2fa::OathStore::NAME_LEN, onWizardName(), pushT9WizardStep(), s_wizard, TOTP, and cdc::ui::tr().
Referenced by wizardStart().
|
static |
Saves the USB-CR-slot designation and finalizes the entry.
| index | Selected list index (0 = designate, 1 = leave undesignated). |
| userData | Unused. |
Definition at line 1158 of file TwoFaModule.cpp.
References s_wizard, cdc::mod_2fa::OathFlag::USB_CR_SLOT, and wizardFinish().
Referenced by pushUsbCrStep().
|
static |
Parses textual or numeric algorithm identifiers into store values.
| token | Algorithm token (sha1, sha256, sha512, or numeric). |
Definition at line 79 of file TwoFaModule.cpp.
References SHA1, SHA256, and SHA512.
Referenced by cmd_totp_add().
|
static |
Parses a textual or numeric entry-type token.
| token | Type token (totp, hotp, or numeric). |
Definition at line 103 of file TwoFaModule.cpp.
References CR, HOTP, and TOTP.
Referenced by cmd_totp_add().
|
static |
Pushes the algorithm-selection step.
CR offers only SHA1/SHA256 (the algorithms the transports carry); TOTP/HOTP additionally offer SHA512. The selected list index maps 1:1 to the OathAlgorithm enum value.
Definition at line 1055 of file TwoFaModule.cpp.
References CR, cdc::ui::ViewStack::instance(), onWizardAlgo(), cdc::ui::ViewStack::push(), s_algoMenu, s_wizard, and cdc::ui::tr().
Referenced by onWizardDigits(), and onWizardSecret().
|
static |
Pushes a configured T9 input step for the account wizard flow.
| title | Step title. |
| initialText | Initial input text. |
| maxLen | Maximum accepted text length. |
| onSave | Save callback for the step. |
Definition at line 763 of file TwoFaModule.cpp.
References cdc::ui::ViewStack::instance(), cdc::ui::ViewStack::push(), and s_t9Input.
Referenced by onWizardName(), onWizardSecret(), onWizardType(), and wizardEdit().
|
static |
Pushes the CR touch-confirm toggle step.
Touch confirmation defaults to on; the first list entry (index 0) sets the touch flag, the second clears it.
Definition at line 1114 of file TwoFaModule.cpp.
References cdc::ui::ViewStack::instance(), onWizardTouch(), cdc::ui::ViewStack::push(), s_touchMenu, and cdc::ui::tr().
Referenced by onWizardAlgo().
|
static |
Pushes the CR USB-slot-2 designation step.
Defaults to off; the first entry (index 0) marks this CR entry as the single USB OTP-HID slot-2 responder, the second leaves it undesignated.
Definition at line 1144 of file TwoFaModule.cpp.
References cdc::ui::ViewStack::instance(), onWizardUsbCr(), cdc::ui::ViewStack::push(), s_usbCrMenu, and cdc::ui::tr().
Referenced by onWizardTouch().
|
static |
Rebuilds the account list view content from Tropic storage cache.
Definition at line 876 of file TwoFaModule.cpp.
References ensureListBuffers(), cdc::core::TropicStorage::forEachSlot(), cdc::core::ModuleRegistry::instance(), cdc::core::TropicStorage::instance(), cdc::mod_2fa::OathStore::instance(), cdc::mod_2fa::TwoFaModule::instance(), moduleId, cdc::core::ModuleRegistry::reportModuleError(), s_accountCount, s_capacity, s_listItems, s_listLabels, s_listSlots, s_listView, and cdc::ui::tr().
Referenced by cdc::mod_2fa::TwoFaModule::getMenuItems(), and wizardFinish().
|
static |
Registers serial commands exposed by the 2FA module.
Definition at line 428 of file TwoFaModule.cpp.
References cmd_chalresp(), CMD_MODULE, cmd_totp(), cdc::serial::getCommandRegistry(), kTotpSubs, and s_commandsRegistered.
Referenced by cdc::mod_2fa::TwoFaModule::init().
|
static |
Registers the CR GATT service and characteristics.
Definition at line 186 of file ble_chalresp.cpp.
References CR_CHALLENGE_UUID, CR_RESPONSE_UUID, CR_SVC_UUID, BleUuid::from128(), getBle(), LOG_E, LOG_I, cdc::hal::GattProp::NOTIFY, onChallengeWrite(), cdc::hal::GattPerm::READ, cdc::hal::GattProp::READ, s_challenge_handle, s_gattChars, s_gattSvcDef, s_response_handle, TAG, cdc::hal::GattPerm::WRITE, and cdc::hal::GattProp::WRITE.
Referenced by ble_chalresp_init().
|
static |
Definition at line 61 of file TwoFaModule.cpp.
References cdc::ui::I18n::instance(), kStrings, and cdc::ui::I18n::registerEnglishTable().
Referenced by cdc::mod_2fa::TwoFaModule::init().
|
inline |
Advances over leading ASCII whitespace in a C string.
| s | Input string pointer. |
Definition at line 13 of file StringUtils.h.
|
static |
Validates OATH entry parameters and clamps to defaults when invalid.
| type | In/out entry type, rejected if out of the supported range. |
| digits | In/out digit count, replaced by default if zero. |
| period | In/out period seconds (TOTP only), replaced by default if zero. |
| algorithm | In/out algorithm code. |
Definition at line 34 of file OathStore.cpp.
References CR, cdc::mod_2fa::OathStore::DEFAULT_DIGITS, cdc::mod_2fa::OathStore::DEFAULT_PERIOD, LOG_W, OATH_DIGITS_MAX, OATH_DIGITS_MIN, SHA1, SHA256, SHA512, TAG, TOTP, TOTP_PERIOD_MAX, and TOTP_PERIOD_MIN.
Referenced by cdc::mod_2fa::OathStore::addAccount(), and cdc::mod_2fa::OathStore::updateAccount().
|
static |
OATH code detail view implementation.
Starts edit wizard prefilled with an existing account.
Forward declaration for edit wizard entry point.
| slot | Logical slot to edit. |
Definition at line 957 of file TwoFaModule.cpp.
References cdc::mod_2fa::OathEntry::algorithm, base32Encode(), cdc::mod_2fa::OathEntry::counter, cdc::mod_2fa::OathEntry::digits, cdc::mod_2fa::OathEntry::flags, cdc::mod_2fa::OathStore::instance(), cdc::mod_2fa::OathEntry::issuer, cdc::mod_2fa::OathEntry::name, cdc::mod_2fa::OathStore::NAME_LEN, onWizardName(), cdc::mod_2fa::OathEntry::period, pushT9WizardStep(), s_wizard, cdc::mod_2fa::OathEntry::secret, cdc::mod_2fa::OathEntry::secretLen, cdc::ui::showToastError(), cdc::ui::tr(), and cdc::mod_2fa::OathEntry::type.
Referenced by cdc::mod_2fa::OathCodeView::onKey().
|
static |
Validates wizard data and persists account changes.
Definition at line 1171 of file TwoFaModule.cpp.
References cdc::mod_2fa::OathStore::addAccount(), cdc::mod_2fa::OathStore::clearUsbCrFlagExcept(), cdc::mod_2fa::OathStore::instance(), cdc::ui::ViewStack::instance(), cdc::ui::ViewStack::popToAnchor(), rebuildList(), s_listView, s_wizard, cdc::ui::showToastError(), cdc::ui::showToastSuccess(), cdc::ui::tr(), cdc::mod_2fa::OathStore::updateAccount(), and cdc::mod_2fa::OathFlag::USB_CR_SLOT.
Referenced by onWizardAlgo(), onWizardPeriod(), and onWizardUsbCr().
|
static |
Starts the add-account wizard with default values.
Definition at line 932 of file TwoFaModule.cpp.
References cdc::mod_2fa::OathStore::DEFAULT_DIGITS, cdc::mod_2fa::OathStore::DEFAULT_PERIOD, cdc::ui::ViewStack::instance(), onWizardType(), cdc::ui::ViewStack::push(), s_typeMenu, s_wizard, SHA1, TOTP, and cdc::ui::tr().
Referenced by onListSelect().
|
static |
Builds and persists an OATH payload to a physical slot.
| physSlot | Physical R-Memory slot. |
| name | Account label. |
| type | Entry type discriminator. |
| issuer | Optional issuer text. |
| secret | Raw secret bytes. |
| secretLen | Secret length. |
| digits | Output digit count. |
| period | TOTP period seconds. |
| counter | HOTP moving factor. |
| algorithm | Hash algorithm identifier. |
| flags | Entry flags. |
Definition at line 237 of file OathStore.cpp.
References cdc::mod_2fa::OathPayload::algorithm, cdc::mod_2fa::OathPayload::counter, cdc::mod_2fa::OathStore::DEFAULT_DIGITS, cdc::mod_2fa::OathStore::DEFAULT_PERIOD, cdc::mod_2fa::OathPayload::digits, cdc::mod_2fa::OathPayload::flags, flags, cdc::hal::getSecureElementInstance(), cdc::core::TropicStorage::instance(), cdc::mod_2fa::OathStore::instance(), cdc::mod_2fa::OathPayload::issuer, LOG_E, cdc::mod_2fa::OathStore::moduleId(), moduleId, name, cdc::hal::OK, cdc::mod_2fa::OathPayload::period, cdc::mod_2fa::OathPayload::secret, cdc::mod_2fa::OathPayload::secretLen, TAG, cdc::mod_2fa::OathPayload::type, and cdc::core::TropicStorage::writeSlot().
Referenced by cdc::mod_2fa::OathStore::addAccount(), cdc::mod_2fa::OathStore::clearUsbCrFlagExcept(), and cdc::mod_2fa::OathStore::updateAccount().
|
staticconstexpr |
Serial command handlers for 2FA module.
Definition at line 67 of file TwoFaModule.cpp.
Referenced by registerCommands().
|
static |
Challenge characteristic UUID (...1F31...), write.
Definition at line 32 of file ble_chalresp.cpp.
Referenced by registerGattService().
|
static |
Response characteristic UUID (...1F32...), read + notify.
Definition at line 40 of file ble_chalresp.cpp.
Referenced by registerGattService().
|
static |
CR service UUID: 8E2F1F30-8B5D-4D7A-9A6E-4C9D6A8B1A01 (little-endian).
Definition at line 24 of file ble_chalresp.cpp.
Referenced by ble_chalresp_deinit(), and registerGattService().
|
staticconstexpr |
Definition at line 45 of file ble_chalresp.cpp.
Referenced by ble_chalresp_tick(), and notifyResponse().
|
staticconstexpr |
Maximum Base32 string length for the longest supported secret (64 bytes raw).
Definition at line 1370 of file TwoFaModule.cpp.
Referenced by cdc::mod_2fa::TwoFaModule::exportBackup().
|
staticconstexpr |
Schema version written to and expected from the 2FA backup section.
Definition at line 1367 of file TwoFaModule.cpp.
Referenced by cdc::mod_2fa::TwoFaModule::exportBackup(), and cdc::mod_2fa::TwoFaModule::importBackup().
|
constexpr |
Definition at line 33 of file TwoFaModule.cpp.
Referenced by registerStrings().
|
static |
Sub-command table for the TOTP serial command group.
Definition at line 413 of file TwoFaModule.cpp.
Referenced by cmd_totp(), and registerCommands().
|
staticconstexpr |
Definition at line 49 of file ble_chalresp.cpp.
Referenced by ble_chalresp_tick(), and onChallengeWrite().
|
staticconstexpr |
Definition at line 50 of file ble_chalresp.cpp.
Referenced by onChallengeWrite().
|
staticconstexpr |
Max challenge payload (entry name + NUL + challenge bytes) accepted per write.
Definition at line 48 of file ble_chalresp.cpp.
Referenced by ble_chalresp_tick(), and onChallengeWrite().
|
staticconstexpr |
Definition at line 18 of file OathStore.cpp.
Referenced by formatCode(), and validateOathParams().
|
staticconstexpr |
Allowed OATH digit count range per RFC 4226 / RFC 6238.
Definition at line 17 of file OathStore.cpp.
Referenced by formatCode(), and validateOathParams().
|
static |
Definition at line 141 of file OathStore.cpp.
|
static |
Definition at line 737 of file TwoFaModule.cpp.
Referenced by freeListBuffers(), onListSelect(), and rebuildList().
|
static |
Definition at line 726 of file TwoFaModule.cpp.
Referenced by pushAlgoStep().
|
static |
Definition at line 738 of file TwoFaModule.cpp.
Referenced by ensureListBuffers(), freeListBuffers(), and rebuildList().
|
static |
Definition at line 54 of file ble_chalresp.cpp.
Referenced by registerGattService().
|
static |
Definition at line 76 of file ble_chalresp.cpp.
Referenced by ble_chalresp_tick(), and onChallengeWrite().
|
static |
Definition at line 730 of file TwoFaModule.cpp.
Referenced by onListSelect().
|
static |
Definition at line 69 of file TwoFaModule.cpp.
Referenced by registerCommands().
|
static |
Definition at line 88 of file ble_chalresp.cpp.
Referenced by ble_chalresp_deinit(), ble_chalresp_tick(), deliverConfirmedResponse(), onChallengeWrite(), onDisconnect(), and onTouchCancel().
|
static |
Definition at line 725 of file TwoFaModule.cpp.
Referenced by onWizardIssuer().
|
static |
Definition at line 57 of file ble_chalresp.cpp.
Referenced by registerGattService().
|
static |
Definition at line 58 of file ble_chalresp.cpp.
Referenced by registerGattService().
|
static |
Definition at line 52 of file ble_chalresp.cpp.
Referenced by ble_chalresp_deinit(), ble_chalresp_init(), and ble_chalresp_tick().
|
static |
Dynamic list buffers released by freeListBuffers.
Definition at line 734 of file TwoFaModule.cpp.
Referenced by ensureListBuffers(), freeListBuffers(), and rebuildList().
|
static |
Definition at line 735 of file TwoFaModule.cpp.
Referenced by ensureListBuffers(), freeListBuffers(), onListSelect(), and rebuildList().
|
static |
Definition at line 736 of file TwoFaModule.cpp.
Referenced by ensureListBuffers(), freeListBuffers(), onListSelect(), and rebuildList().
|
static |
2FA module UI state.
Static view instances (no dynamic allocation, no leaks).
Definition at line 722 of file TwoFaModule.cpp.
Referenced by cdc::mod_2fa::TwoFaModule::getMenuItems(), rebuildList(), and wizardFinish().
|
static |
Definition at line 62 of file ble_chalresp.cpp.
Referenced by ble_chalresp_deinit(), ble_chalresp_init(), ble_chalresp_tick(), deliverConfirmedResponse(), onChallengeWrite(), onDisconnect(), and onTouchCancel().
|
static |
Definition at line 77 of file ble_chalresp.cpp.
Referenced by ble_chalresp_deinit(), ble_chalresp_tick(), onChallengeWrite(), and onDisconnect().
|
static |
Definition at line 727 of file TwoFaModule.cpp.
Referenced by onWizardAlgo().
|
static |
Definition at line 55 of file ble_chalresp.cpp.
Referenced by notifyResponse(), and registerGattService().
|
static |
Definition at line 723 of file TwoFaModule.cpp.
Referenced by pushT9WizardStep().
|
static |
Definition at line 60 of file ble_chalresp.cpp.
Referenced by ble_chalresp_deinit(), and ble_chalresp_init().
|
static |
Definition at line 728 of file TwoFaModule.cpp.
Referenced by pushTouchStep().
|
static |
Definition at line 724 of file TwoFaModule.cpp.
Referenced by wizardStart().
|
static |
Definition at line 729 of file TwoFaModule.cpp.
Referenced by pushUsbCrStep().
|
static |
Definition at line 731 of file TwoFaModule.cpp.
Referenced by cdc::mod_2fa::TwoFaModule::getMenuItems().
|
static |
Definition at line 754 of file TwoFaModule.cpp.
Referenced by onWizardAlgo(), onWizardDigits(), onWizardIssuer(), onWizardName(), onWizardPeriod(), onWizardSecret(), onWizardTouch(), onWizardType(), onWizardUsbCr(), pushAlgoStep(), wizardEdit(), wizardFinish(), and wizardStart().
|
staticconstexpr |
Definition at line 68 of file TwoFaModule.cpp.
Referenced by cmd_totp_add(), and onWizardName().
|
staticconstexpr |
Definition at line 24 of file OathStore.cpp.
Referenced by validateOathParams().
|
staticconstexpr |
Allowed TOTP period range in seconds.
Definition at line 23 of file OathStore.cpp.
Referenced by validateOathParams().