|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
Global lockdown latch. More...
#include <SystemLock.h>
Public Types | |
| using | ShutdownHandler = void (*)(LockdownReason reason, const char* detail) |
| UI handler invoked from main context just before deep sleep. | |
Public Member Functions | |
| bool | isLocked () const |
| Returns true once a lockdown has been latched. | |
| LockdownReason | getReason () const |
| Reason captured at the first triggerLockdown call. | |
| const char * | getDetail () const |
Returns the optional detail string captured at the first triggerLockdown call, or nullptr if none was provided. Caller must ensure pointed-to memory has static lifetime. | |
| void | triggerLockdown (LockdownReason reason, const char *detail=nullptr) |
| Latches the lockdown flag. Idempotent and ISR-safe. | |
| void | setShutdownHandler (ShutdownHandler handler) |
| Installs an optional UI handler invoked just before deep sleep. Must be set from main task before main loop starts polling. | |
| void | enforceIfLocked () |
| If locked, runs the shutdown sequence and never returns. Otherwise returns immediately. Call from main loop top. | |
Static Public Member Functions | |
| static SystemLock & | instance () |
| Returns the process-wide lockdown latch singleton. | |
Global lockdown latch.
Any task may call triggerLockdown to mark the system as compromised. The lockdown is monotonic: once set it cannot be cleared except by a power cycle / hard reset.
The main loop calls enforceIfLocked at the top of every iteration to perform the shutdown sequence: optional UI handler (drawn from main context) then esp_deep_sleep_start with no wake source enabled. Other tasks check isLocked to fail-fast their own operations.
Definition at line 31 of file SystemLock.h.
| using cdc::core::SystemLock::ShutdownHandler = void (*)(LockdownReason reason, const char* detail) |
UI handler invoked from main context just before deep sleep.
Definition at line 34 of file SystemLock.h.
| void cdc::core::SystemLock::enforceIfLocked | ( | ) |
If locked, runs the shutdown sequence and never returns. Otherwise returns immediately. Call from main loop top.
Main-loop poll. Runs the shutdown sequence if the latch is set.
Definition at line 53 of file SystemLock.cpp.
Referenced by runMainLoopIteration().
|
inline |
Returns the optional detail string captured at the first triggerLockdown call, or nullptr if none was provided. Caller must ensure pointed-to memory has static lifetime.
Definition at line 49 of file SystemLock.h.
|
inline |
Reason captured at the first triggerLockdown call.
Definition at line 42 of file SystemLock.h.
|
static |
Returns the process-wide lockdown latch singleton.
Definition at line 20 of file SystemLock.cpp.
Referenced by checkBuildProfileAndWipeNvs(), cdc::hal::Tropic01Element::eccDelete(), cdc::hal::Tropic01Element::eccGenerate(), cdc::hal::Tropic01Element::eccGetPublicKey(), cdc::hal::Tropic01Element::eccImport(), cdc::hal::Tropic01Element::ecdsaSign(), cdc::hal::Tropic01Element::eddsaSign(), cdc::hal::Tropic01Element::getChipId(), cdc::hal::Tropic01Element::getFwVersion(), cdc::hal::Tropic01Element::getRandom(), cdc::hal::Tropic01Element::getRandomStrict(), cdc::hal::Tropic01Element::init(), initDisplay(), cdc::hal::Tropic01Element::rmemErase(), cdc::hal::Tropic01Element::rmemRead(), cdc::hal::Tropic01Element::rmemReadWithHeader(), cdc::hal::Tropic01Element::rmemWrite(), cdc::hal::Tropic01Element::rmemWriteWithHeader(), runMainLoopIteration(), cdc::hal::Tropic01Element::sessionStart(), and cdc::hal::Tropic01Element::sleep().
|
inline |
Returns true once a lockdown has been latched.
Definition at line 39 of file SystemLock.h.
| void cdc::core::SystemLock::setShutdownHandler | ( | ShutdownHandler | handler | ) |
Installs an optional UI handler invoked just before deep sleep. Must be set from main task before main loop starts polling.
Stores the UI shutdown handler pointer.
| handler | Function pointer, or nullptr to clear. |
| handler | Handler invoked once from main context before deep sleep. |
Definition at line 46 of file SystemLock.cpp.
Referenced by initDisplay().
| void cdc::core::SystemLock::triggerLockdown | ( | LockdownReason | reason, |
| const char * | detail = nullptr ) |
Latches the lockdown flag. Idempotent and ISR-safe.
Latches the lockdown flag. Idempotent.
| reason | Reason to record; ignored if already locked. |
| detail | Optional pointer to a string literal with static lifetime describing the specific failure (for example lt_ret_verbose(ret) or "PSA Crypto init failed"). |
| reason | Reason recorded only on the first call. |
| detail | Optional static-lifetime string with extra context. |
Definition at line 30 of file SystemLock.cpp.
Referenced by checkBuildProfileAndWipeNvs(), and cdc::hal::Tropic01Element::init().