|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
Central, data-agnostic backup loader. More...
#include <BackupManager.h>
Public Member Functions | |
| bool | exportTo (const char *passphrase) |
| Exports all module sections into one encrypted backup file. | |
| BackupSummary | importFrom (const char *passphrase) |
| Restores from the on-device backup file (best-effort). | |
| bool | backupExists () const |
| Reports whether a backup file is present on the device. | |
| bool | deleteBackup () |
| Deletes the on-device backup file. | |
Static Public Member Functions | |
| static BackupManager & | instance () |
| Returns the process-wide singleton. | |
Central, data-agnostic backup loader.
Owns the encrypted container I/O for the single on-device backup file. It iterates the module registry, lets each module emit/consume only its own JSON section (via IModule::exportBackup / importBackup), and never inspects module payloads itself.
Container format (binary): magic[6] "CDCBAK" || version(1) || kdf_iters(uint32 LE) || salt(16) || nonce(12) || ciphertext(N) || gcm_tag(16) The plaintext is a JSON document; only the ciphertext (incl. tag) is ever present in the container. Key = PBKDF2-HMAC-SHA256(passphrase, salt, kdf_iters) -> 32 bytes; cipher = AES-256-GCM with the header bytes as AAD. The binary container is stored base64-encoded on vFAT for text-safe serial transfer. The same format is reproduced by tools/backup.py.
Definition at line 36 of file BackupManager.h.
| bool cdc::os_ui::BackupManager::backupExists | ( | ) | const |
Reports whether a backup file is present on the device.
Definition at line 427 of file BackupManager.cpp.
Referenced by deleteBackup(), and importFrom().
| bool cdc::os_ui::BackupManager::deleteBackup | ( | ) |
Deletes the on-device backup file.
Definition at line 432 of file BackupManager.cpp.
References backupExists().
| bool cdc::os_ui::BackupManager::exportTo | ( | const char * | passphrase | ) |
Exports all module sections into one encrypted backup file.
Overwrites any existing backup. The serialized JSON lives only transiently in PSRAM and is zeroized after encryption.
| passphrase | Export passphrase (must be non-empty). |
Definition at line 248 of file BackupManager.cpp.
References APP_VERSION, cdc::core::IModule::exportBackup(), cdc::os_ui::SystemSettingsBackup::exportSystemSettings(), cdc::core::IService::getName(), HOST_API_LEVEL_STR, cdc::core::ModuleRegistry::instance(), LOG_E, LOG_I, cdc::core::openFile(), cdc::core::psramAlloc(), and TAG.
| BackupSummary cdc::os_ui::BackupManager::importFrom | ( | const char * | passphrase | ) |
Restores from the on-device backup file (best-effort).
Reads and decrypts the container, parses the JSON, gates compatibility on the host API level, then routes each section to its module. Unknown modules are skipped and counted; never aborts on a per-module failure.
| passphrase | Passphrase used at export time. |
ok is false on read/decrypt/parse failure. Definition at line 342 of file BackupManager.cpp.
References backupExists(), cdc::core::IModule::BackupResult::failed, cdc::os_ui::BackupSummary::failed, HOST_API_LEVEL_PACKED, HOST_API_LEVEL_STR, cdc::core::IModule::importBackup(), cdc::core::IModule::BackupResult::imported, cdc::os_ui::BackupSummary::imported, cdc::os_ui::SystemSettingsBackup::importSystemSettings(), cdc::core::ModuleRegistry::instance(), LOG_E, LOG_I, LOG_W, cdc::os_ui::BackupSummary::modules, cdc::os_ui::BackupSummary::ok, cdc::core::openFile(), cdc::core::psramAlloc(), cdc::os_ui::BackupSummary::skipped, cdc::os_ui::BackupSummary::system, and TAG.
|
static |
Returns the process-wide singleton.
Definition at line 243 of file BackupManager.cpp.