CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
ble_chalresp.cpp File Reference
#include "mod_2fa/ble_chalresp.h"
#include "mod_2fa/OathStore.h"
#include "cdc_core/IChallengeResponder.h"
#include "cdc_core/Raii.h"
#include "cdc_hal/IBluetoothController.h"
#include "cdc_ui/I18n.h"
#include "cdc_views/ConfirmView.h"
#include "cdc_log.h"
#include "esp_attr.h"
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include <cstring>
#include <cstdio>

Go to the source code of this file.

Classes

struct  cdc::mod_2fa::PendingChallenge
 Pending challenge handed from the BLE host task to the main task. More...
struct  cdc::mod_2fa::PendingConfirm
 Response awaiting an on-device touch confirmation. More...

Namespaces

namespace  cdc
namespace  cdc::mod_2fa

Functions

static IBluetoothControllercdc::mod_2fa::getBle ()
 Returns shared Bluetooth controller instance.
static void cdc::mod_2fa::notifyResponse (uint16_t connHandle, const uint8_t *data, size_t len)
 Sends a response notification to the requesting connection.
static void cdc::mod_2fa::deliverConfirmedResponse ()
 Computes and notifies the response stashed in s_confirm.
static void cdc::mod_2fa::onTouchConfirm (void *userData)
 Touch-confirm accepted: notify the prepared response.
static void cdc::mod_2fa::onTouchCancel (void *userData)
 Touch-confirm declined: discard the prepared response.
static int cdc::mod_2fa::onChallengeWrite (uint16_t connHandle, uint16_t, const uint8_t *data, uint16_t len)
 GATT challenge write callback (BLE host task).
static bool cdc::mod_2fa::registerGattService ()
 Registers the CR GATT service and characteristics.
static void cdc::mod_2fa::onDisconnect (uint16_t connHandle, int reason)
 Clears pending request state if the requesting peer disconnects.
bool cdc::mod_2fa::ble_chalresp_init ()
 BLE GATT challenge-response transport.
void cdc::mod_2fa::ble_chalresp_deinit ()
 Tears down the BLE CR subsystem and removes GATT callbacks.
void cdc::mod_2fa::ble_chalresp_tick (uint32_t nowMs)
 Main-task tick: processes a pending challenge (confirm + notify).

Variables

static const char * TAG = "2FA_CR_BLE"
static const uint8_t cdc::mod_2fa::CR_SVC_UUID [16]
 CR service UUID: 8E2F1F30-8B5D-4D7A-9A6E-4C9D6A8B1A01 (little-endian).
static const uint8_t cdc::mod_2fa::CR_CHALLENGE_UUID [16]
 Challenge characteristic UUID (...1F31...), write.
static const uint8_t cdc::mod_2fa::CR_RESPONSE_UUID [16]
 Response characteristic UUID (...1F32...), read + notify.
static constexpr uint16_t cdc::mod_2fa::INVALID_HANDLE = 0xFFFF
static constexpr size_t cdc::mod_2fa::MAX_NAME_LEN = 16
 Max challenge payload (entry name + NUL + challenge bytes) accepted per write.
static constexpr size_t cdc::mod_2fa::MAX_CHALLENGE_LEN = 128
static constexpr size_t cdc::mod_2fa::MAX_FRAME_LEN = MAX_NAME_LEN + 1 + MAX_CHALLENGE_LEN
static bool cdc::mod_2fa::s_initialized = false
static uint16_t cdc::mod_2fa::s_challenge_handle = 0
static uint16_t cdc::mod_2fa::s_response_handle = 0
static GattCharacteristic cdc::mod_2fa::s_gattChars [2] = {}
static GattServiceDef cdc::mod_2fa::s_gattSvcDef = {}
static IBluetoothController::ListenerToken cdc::mod_2fa::s_tokDisconn = IBluetoothController::INVALID_LISTENER
static SemaphoreHandle_t cdc::mod_2fa::s_mutex = nullptr
static uint8_t cdc::mod_2fa::s_challengeBuf [MAX_CHALLENGE_LEN] = {}
static PendingChallenge cdc::mod_2fa::s_pending = {}
static PendingConfirm cdc::mod_2fa::s_confirm = {}

Variable Documentation

◆ TAG

const char* TAG = "2FA_CR_BLE"
static

Definition at line 17 of file ble_chalresp.cpp.