CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
OathStore.cpp File Reference
#include "mod_2fa/OathStore.h"
#include "cdc_hal/ISecureElement.h"
#include "cdc_core/TropicStorage.h"
#include "cdc_log.h"
#include <mbedtls/md.h>
#include <cstring>
#include <ctime>
#include <cstdint>

Go to the source code of this file.

Classes

struct  cdc::mod_2fa::OathPayload

Namespaces

namespace  cdc
namespace  cdc::mod_2fa

Functions

static bool cdc::mod_2fa::validateOathParams (uint8_t type, uint8_t &digits, uint32_t &period, uint8_t &algorithm)
 Validates OATH entry parameters and clamps to defaults when invalid.
static int cdc::mod_2fa::base32CharValue (char c)
 Converts one Base32 character into 5-bit value.
static int cdc::mod_2fa::base32Decode (const char *encoded, uint8_t *out, size_t outMax)
 Decodes Base32 secret into raw bytes.
static bool cdc::mod_2fa::writePayload (uint16_t physSlot, const char *name, uint8_t type, const char *issuer, const uint8_t *secret, uint8_t secretLen, uint8_t digits, uint32_t period, uint64_t counter, uint8_t algorithm, uint8_t flags)
 Builds and persists an OATH payload to a physical slot.
static void cdc::mod_2fa::formatCode (uint32_t code, uint8_t digits, char *codeOut, size_t codeOutLen)
 Formats a numeric code into codeOut with leading zeros.

Variables

static const char * TAG = "2FA"
static constexpr uint8_t cdc::mod_2fa::OATH_DIGITS_MIN = 6
 Allowed OATH digit count range per RFC 4226 / RFC 6238.
static constexpr uint8_t cdc::mod_2fa::OATH_DIGITS_MAX = 8
static constexpr uint32_t cdc::mod_2fa::TOTP_PERIOD_MIN = 15
 Allowed TOTP period range in seconds.
static constexpr uint32_t cdc::mod_2fa::TOTP_PERIOD_MAX = 300
static const uint32_t cdc::mod_2fa::POWERS_10 []

Variable Documentation

◆ TAG

const char* TAG = "2FA"
static

Definition at line 10 of file OathStore.cpp.