CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
TwoFaModule.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace cdc::mod_2fa {
7
8class TwoFaModule : public core::ModuleBase, public core::IChallengeResponder {
9public:
10 bool init() override;
11 bool start() override;
12 void stop() override;
13 void onTick(uint32_t nowMs) override;
14
15 const char* getVersion() const override { return "1.0"; }
16 uint8_t getMenuItems(core::ModuleMenuItem* items, uint8_t maxItems) override;
18 void setSlotRange(const core::IModule::SlotRange& range) override;
19
20 bool exportBackup(cJSON* out) override;
21 core::IModule::BackupResult importBackup(const cJSON* in) override;
22
23 // IChallengeResponder
24 int challengeResponse(const char* entryName, const uint8_t* challenge,
25 size_t clen, uint8_t* out) override;
26 int challengeResponseUsbSlot(const uint8_t* challenge, size_t clen,
27 uint8_t* out, bool* touchRequiredOut) override;
28
29 static TwoFaModule& instance();
30
31private:
32 TwoFaModule() : ModuleBase("mod_2fa") {}
33 core::IModule::SlotRange slotRange_ = {};
34};
35
36} // namespace cdc::mod_2fa
37
38extern "C" void mod_2fa_register();
void mod_2fa_register()
Registers 2FA module initializer in the global module registry.
Challenge-response provider interface.
Base implementation that handles common module lifecycle boilerplate.
Definition ModuleBase.h:20
ModuleBase(const char *name)
Constructs a module base with the given module name.
Definition ModuleBase.h:26
const char * getVersion() const override
Returns the module version string.
Definition TwoFaModule.h:15
bool exportBackup(cJSON *out) override
Exports all stored OATH entries into the module's backup section.
uint8_t getMenuItems(core::ModuleMenuItem *items, uint8_t maxItems) override
Provides main-menu entry for the 2FA module.
static TwoFaModule & instance()
Returns singleton 2FA module instance.
void stop() override
Stops the 2FA module and releases list buffers.
core::IModule::BackupResult importBackup(const cJSON *in) override
Restores OATH entries from the module's backup section.
int challengeResponseUsbSlot(const uint8_t *challenge, size_t clen, uint8_t *out, bool *touchRequiredOut) override
Computes the raw HMAC response for the designated USB-CR slot entry.
bool init() override
Initializes module resources, translations, commands, and slot mapping.
void setSlotRange(const core::IModule::SlotRange &range) override
Stores assigned Tropic slot range for the module.
int challengeResponse(const char *entryName, const uint8_t *challenge, size_t clen, uint8_t *out) override
Computes the raw HMAC challenge-response for a named CR entry.
core::IModule::SlotRequest getSlotRequest() const override
Declares minimum slot requirements for the 2FA module.
void onTick(uint32_t nowMs) override
Forwards the BLE CR state machine on the main task.
bool start() override
Starts the 2FA module service.
Per-module restore outcome reported by importBackup().
Definition IModule.h:85
Menu item registered by a module.
Definition IModule.h:29