|
cryptnox-pos 1.0.0
Standalone USDC payment terminal firmware (ESP32 + Cryptnox smart card)
|
Anomaly handling (§3.3): local fail-closed + persisted counter and a RAM ring buffer for on-site inspection. Never bricks. More...
Go to the source code of this file.
Classes | |
| struct | anom_entry_t |
Macros | |
| #define | NS_HARDEN "harden" |
| #define | K_ANOMALY "anomaly_ct" |
| #define | ANOM_RING 8U |
Functions | |
| static uint32_t | nvs_load_ctr (void) |
| Read the persisted anomaly counter from NVS. | |
| static void | nvs_store_ctr (uint32_t v) |
| Persist the anomaly counter to NVS. | |
| static void | ensure_loaded (void) |
| Lazily seed both counter copies from NVS on first use. | |
| void | pos_handle_anomaly (const char *where) |
| Report an anomaly: bump a self-checked persisted counter, log it, and keep a local ring buffer for on-site inspection. | |
| uint32_t | pos_anomaly_count (void) |
| Persisted total anomaly count (for the optional maintenance view). | |
Variables | |
| static const char *const | TAG = "harden" |
| static anom_entry_t | s_ring [ANOM_RING] |
| static uint32_t | s_ring_head = 0U |
| static volatile uint32_t | s_ctr = 0U |
| static volatile uint32_t | s_ctr_echo = 0U |
| static bool | s_loaded = false |
Anomaly handling (§3.3): local fail-closed + persisted counter and a RAM ring buffer for on-site inspection. Never bricks.
Definition in file hardening.cpp.
| #define ANOM_RING 8U |
Definition at line 25 of file hardening.cpp.
Referenced by pos_handle_anomaly().
| #define K_ANOMALY "anomaly_ct" |
Definition at line 21 of file hardening.cpp.
Referenced by nvs_load_ctr(), and nvs_store_ctr().
| #define NS_HARDEN "harden" |
Definition at line 20 of file hardening.cpp.
Referenced by nvs_load_ctr(), and nvs_store_ctr().
|
static |
Lazily seed both counter copies from NVS on first use.
Idempotent: later calls are no-ops, so every public entry point can call it without caring whether NVS has been read yet.
Definition at line 89 of file hardening.cpp.
References nvs_load_ctr(), s_ctr, s_ctr_echo, and s_loaded.
Referenced by pos_anomaly_count(), and pos_handle_anomaly().
|
static |
Read the persisted anomaly counter from NVS.
Definition at line 44 of file hardening.cpp.
References K_ANOMALY, NS_HARDEN, and TAG.
Referenced by ensure_loaded().
|
static |
Persist the anomaly counter to NVS.
| [in] | v | Counter value to store. Write failures are logged and ignored. |
Definition at line 71 of file hardening.cpp.
References K_ANOMALY, NS_HARDEN, and TAG.
Referenced by pos_handle_anomaly().
| uint32_t pos_anomaly_count | ( | void | ) |
Persisted total anomaly count (for the optional maintenance view).
Definition at line 125 of file hardening.cpp.
References ensure_loaded(), and s_ctr.
| void pos_handle_anomaly | ( | const char * | where | ) |
Report an anomaly: bump a self-checked persisted counter, log it, and keep a local ring buffer for on-site inspection.
Fails the current transaction closed (the caller's gate returns FALSE32); never bricks — a keyless POS holds no secret to protect (§3.3). Firmware only (NVS + esp_log); defined in hardening.cpp.
Definition at line 99 of file hardening.cpp.
References ANOM_RING, anom_entry_t::at_count, ensure_loaded(), nvs_store_ctr(), s_ctr, s_ctr_echo, s_ring, s_ring_head, TAG, and anom_entry_t::where.
Referenced by app_main(), settle_inflight(), sign_and_broadcast(), and sign_and_broadcast_tron().
|
static |
Definition at line 34 of file hardening.cpp.
Referenced by ensure_loaded(), pos_anomaly_count(), and pos_handle_anomaly().
|
static |
Definition at line 35 of file hardening.cpp.
Referenced by ensure_loaded(), and pos_handle_anomaly().
|
static |
Definition at line 36 of file hardening.cpp.
Referenced by ensure_loaded().
|
static |
Definition at line 30 of file hardening.cpp.
Referenced by pos_handle_anomaly().
|
static |
Definition at line 31 of file hardening.cpp.
Referenced by pos_handle_anomaly().
|
static |
Definition at line 18 of file hardening.cpp.