CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
GpgModule.cpp File Reference
#include "mod_gpg/GpgModule.h"
#include "mod_gpg/GpgStorage.h"
#include "mod_gpg/GpgRecvStore.h"
#include "mod_gpg/ble_gpg_xsig.h"
#include "openpgp/xsig.h"
#include "cdc_core/KeyFingerprint.h"
#include "cdc_core/Raii.h"
#include "cdc_core/ModuleRegistry.h"
#include "cdc_core/UsbManager.h"
#include "cdc_ui/I18n.h"
#include "mod_gpg/openpgp/ccid.h"
#include "mod_gpg/openpgp/openpgp.h"
#include "cdc_ui/ViewStack.h"
#include "cdc_views/ListView.h"
#include "cdc_views/T9InputView.h"
#include "cdc_views/InfoView.h"
#include "cdc_views/QRCodeView.h"
#include "cdc_views/ConfirmView.h"
#include "cdc_views/ToastView.h"
#include "cdc_os_ui/views/PinChangeView.h"
#include "cdc_core/PinManager.h"
#include "cdc_core/pin_storage_c.h"
#include "serial_cmd/ICommandRegistry.h"
#include "serial_cmd/SubCommand.h"
#include "serial_cmd/Console.h"
#include "mod_gpg/gpg.h"
#include "cdc_log.h"
#include "esp_timer.h"
#include "esp_random.h"
#include "esp_attr.h"
#include <new>
#include <cstring>
#include <cstdio>
#include <cctype>

Go to the source code of this file.

Classes

struct  cdc::mod_gpg::WizardState

Namespaces

namespace  cdc
namespace  cdc::mod_gpg

Enumerations

enum  cdc::mod_gpg::GpgMenuAction : uintptr_t {
  cdc::mod_gpg::GPG_MENU_STATUS = 1 , cdc::mod_gpg::GPG_MENU_GENERATE , cdc::mod_gpg::GPG_MENU_EXPORT , cdc::mod_gpg::GPG_MENU_SEND ,
  cdc::mod_gpg::GPG_MENU_RECEIVED , cdc::mod_gpg::GPG_MENU_SETTINGS , cdc::mod_gpg::GPG_MENU_RESET
}

Functions

static void cdc::mod_gpg::registerStrings ()
static void cdc::mod_gpg::cmd_gpg_status (const char *args)
 Serial command printing current GPG key status.
static void cdc::mod_gpg::cmd_gpg_generate (const char *args)
 Serial command generating GPG key with selected curve and user-id.
static void cdc::mod_gpg::cmd_gpg_export (const char *args)
 Serial command exporting GPG public key in PEM format.
static void cdc::mod_gpg::cmd_gpg_reset (const char *args)
static void cdc::mod_gpg::cmd_gpg_recv_list (const char *args)
static void cdc::mod_gpg::cmd_gpg_recv_info (const char *args)
static void cdc::mod_gpg::cmd_gpg_recv_delete (const char *args)
static void cdc::mod_gpg::cmd_gpg_cross_sign (const char *args)
static void cdc::mod_gpg::cmd_gpg_export_signed (const char *args)
static void cdc::mod_gpg::cmd_gpg (const char *args)
static void cdc::mod_gpg::registerCommands ()
 Registers serial commands exposed by GPG module.
static void cdc::mod_gpg::fp_to_hex (const uint8_t *fp, size_t len, char *out, size_t out_size)
static bool cdc::mod_gpg::parse_index (const char *args, uint8_t *out)
static void cdc::mod_gpg::showStatus ()
 Displays current GPG key status and metadata.
static void cdc::mod_gpg::wizardStart ()
 Starts key-generation wizard flow.
static void cdc::mod_gpg::showExport ()
 Exports public key to serial output and QR view.
static void cdc::mod_gpg::confirmReset ()
 Opens reset confirmation dialog.
static void cdc::mod_gpg::showSettings ()
 Shows GPG settings menu.
static void cdc::mod_gpg::onSettingsSelect (uint16_t index, void *)
 Handles settings-menu selection for PW1/PW3 change flow.
static void cdc::mod_gpg::showSendKey ()
static void cdc::mod_gpg::showReceivedKeys ()
static void cdc::mod_gpg::onMenuSelect (uint16_t, void *userData)
 Handles GPG main-menu selections via the entry's userData tag.
static ui::ListItem cdc::mod_gpg::makeMenuItem (const char *label, GpgMenuAction action)
static void cdc::mod_gpg::rebuildMenu ()
 Rebuilds GPG main menu labels and populates userData tags.
static bool cdc::mod_gpg::gpg_verify_pw1 (const char *pin)
 Verifies OpenPGP PW1 using persistent pin-storage backend.
static bool cdc::mod_gpg::gpg_verify_pw3 (const char *pin)
 Verifies OpenPGP PW3 using persistent pin-storage backend.
static bool cdc::mod_gpg::gpg_change_pw1 (const char *, const char *newPin)
 Changes OpenPGP PW1 value.
static bool cdc::mod_gpg::gpg_change_pw3 (const char *, const char *newPin)
 Changes OpenPGP PW3 value.
static uint8_t cdc::mod_gpg::gpg_retries_pw1 ()
 Returns remaining retries for OpenPGP PW1.
static uint8_t cdc::mod_gpg::gpg_retries_pw3 ()
 Returns remaining retries for OpenPGP PW3.
static bool cdc::mod_gpg::gpg_blocked_pw1 ()
 Returns whether OpenPGP PW1 is blocked.
static bool cdc::mod_gpg::gpg_blocked_pw3 ()
 Returns whether OpenPGP PW3 is blocked.
static void cdc::mod_gpg::onGpgPinComplete (bool)
 Pin-change completion callback returning to previous view.
static void cdc::mod_gpg::onWizardName (const char *text)
 Saves wizard name and opens email step.
static void cdc::mod_gpg::onWizardEmail (const char *text)
 Saves wizard email and opens curve selection.
static void cdc::mod_gpg::onWizardCurve (uint16_t index, void *)
 Finalizes wizard curve selection and triggers key generation.
static void cdc::mod_gpg::onResetConfirm (void *)
 Confirm callback resetting all GPG key material.
static void cdc::mod_gpg::rebuildReceivedList ()
static void cdc::mod_gpg::onReceivedListSelect (uint16_t index, void *)
static void cdc::mod_gpg::showReceivedDetail ()
static void cdc::mod_gpg::onReceivedActionSelect (uint16_t index, void *)
static void cdc::mod_gpg::onReceivedSignConfirm (void *)
static void cdc::mod_gpg::onReceivedDeleteConfirm (void *)
void mod_gpg_register ()
 Registers GPG module initializer in global registry.

Variables

static const char * TAG = "GPG"
constexpr ui::I18nEntry cdc::mod_gpg::kStrings []
static constexpr const char * cdc::mod_gpg::CMD_MODULE = "gpg"
static bool cdc::mod_gpg::s_commandsRegistered = false
static const cdc::serial::SubCommand cdc::mod_gpg::kGpgSubs []
static char cdc::mod_gpg::s_reset_token [7] = {}
 Serial command resetting GPG key material.
static uint64_t cdc::mod_gpg::s_reset_token_ts_us = 0
static constexpr uint64_t cdc::mod_gpg::RESET_TOKEN_TIMEOUT_US = 30ULL * 1000ULL * 1000ULL
static ui::ListView cdc::mod_gpg::s_menuView
static ui::ListView cdc::mod_gpg::s_settingsView
static ui::PinChangeView cdc::mod_gpg::s_pinChangeView
static ui::T9InputView cdc::mod_gpg::s_t9Input
static ui::ListView cdc::mod_gpg::s_curveView
static ui::InfoView cdc::mod_gpg::s_infoView
static ui::QRCodeView cdc::mod_gpg::s_qrView
static bool cdc::mod_gpg::s_viewsInitialized = false
static ui::ListItem cdc::mod_gpg::s_menuItems [8] = {}
static ui::ListItem cdc::mod_gpg::s_settingsItems []
static WizardState cdc::mod_gpg::s_wizard = {}
static ui::ListView cdc::mod_gpg::s_recvListView
 Received-keys list UI state.
static ui::ListView cdc::mod_gpg::s_recvActionView
static ui::ListItem cdc::mod_gpg::s_recvListItems [GpgRecvStore::kMaxKeys+1]
static ui::ListItem cdc::mod_gpg::s_recvActionItems [3]
static char cdc::mod_gpg::s_recvListLabels [GpgRecvStore::kMaxKeys][72]
static uint8_t cdc::mod_gpg::s_recvSelectedIndex = 0
static gpg_recv_key_t cdc::mod_gpg::s_recvSelectedKey = {}
static char cdc::mod_gpg::s_recvDetailText [640]
static char cdc::mod_gpg::s_recvExportBuf [4096]

Function Documentation

◆ mod_gpg_register()

void mod_gpg_register ( )

Registers GPG module initializer in global registry.

Definition at line 1035 of file GpgModule.cpp.

References cdc::core::ModuleRegistry::instance(), and cdc::core::ModuleRegistry::registerInitializer().

Variable Documentation

◆ TAG

const char* TAG = "GPG"
static

Definition at line 36 of file GpgModule.cpp.