64 bool addAccount(uint8_t type,
const char*
name,
const char* issuer,
65 const char* secretBase32, uint8_t digits, uint32_t period,
66 uint8_t algorithm, uint64_t counter, uint8_t
flags = 0);
67 bool updateAccount(uint16_t slot, uint8_t type,
const char*
name,
const char* issuer,
68 const char* secretBase32, uint8_t digits, uint32_t period,
69 uint8_t algorithm, uint64_t counter, uint8_t
flags = 0);
87 int challengeResponse(
const char* entryName,
const uint8_t* challenge,
size_t clen,
88 uint8_t* out,
bool* touchRequiredOut =
nullptr);
106 bool* touchRequiredOut =
nullptr);
145 int8_t
generateCode(uint16_t slot,
char* codeOut,
size_t codeOutLen);
153 uint16_t
capacity()
const {
return slots_.capacity(); }
155 return slots_.toPhysicalSlot(logicalIndex, slotOut);
158 return slots_.toLogicalSlot(slot, logicalIndexOut);
161 uint8_t
moduleId()
const {
return slots_.moduleId(); }
162 uint16_t
rmemStart()
const {
return slots_.rmemStart(); }
163 uint16_t
rmemEnd()
const {
return slots_.rmemEnd(); }
168 uint32_t generate(
const uint8_t* secret,
size_t secretLen, uint64_t counter,
170 bool hmacCompute(
OathAlgorithm algo,
const uint8_t* key,
size_t keyLen,
171 const uint8_t* data,
size_t dataLen,
172 uint8_t* output,
size_t* outputLen)
const;
173 bool persistCounter(uint16_t slot,
const OathEntry& entry, uint64_t counter);
char name[cdc::hal::ISecureElement::RMEM_NAME_LEN]
Manages logical-to-physical RMEM slot mapping for module storage layers.
int challengeResponseUsbSlot(const uint8_t *challenge, size_t clen, uint8_t *out, bool *touchRequiredOut=nullptr)
Computes the raw HMAC challenge-response for the USB-CR slot entry.
bool toPhysicalSlot(uint16_t logicalIndex, uint16_t *slotOut) const
bool isTimeValid() const
Returns whether system time is considered valid for TOTP.
void clearUsbCrFlagExcept(uint16_t keepSlot)
Clears the USB-CR-slot flag on every entry except keepSlot.
int challengeResponse(const char *entryName, const uint8_t *challenge, size_t clen, uint8_t *out, bool *touchRequiredOut=nullptr)
Computes the raw HMAC challenge-response for a CR entry by name.
static constexpr uint8_t NAME_LEN
static constexpr uint8_t SECRET_LEN
bool hasSlotRange() const
bool toLogicalSlot(uint16_t slot, uint16_t *logicalIndexOut) const
bool findUsbCrSlot(uint16_t *slotOut) const
Finds the logical slot of the CR entry flagged as the USB-CR slot.
bool addAccount(uint8_t type, const char *name, const char *issuer, const char *secretBase32, uint8_t digits, uint32_t period, uint8_t algorithm, uint64_t counter, uint8_t flags=0)
Adds a new OATH entry from a Base32 secret.
static OathStore & instance()
Returns singleton OATH store instance.
static constexpr uint8_t DEFAULT_DIGITS
int8_t generateCode(uint16_t slot, char *codeOut, size_t codeOutLen)
Renders the current code for an entry into codeOut.
uint16_t capacity() const
bool updateAccount(uint16_t slot, uint8_t type, const char *name, const char *issuer, const char *secretBase32, uint8_t digits, uint32_t period, uint8_t algorithm, uint64_t counter, uint8_t flags=0)
Updates an existing OATH entry.
uint16_t rmemStart() const
static constexpr uint32_t DEFAULT_PERIOD
uint8_t timeRemaining(uint32_t period) const
Returns seconds remaining in current TOTP time step.
void setSlotRange(const cdc::core::IModule::SlotRange &range)
Configures logical-to-physical slot mapping for OATH entries.
static constexpr uint8_t ISSUER_LEN
bool findByName(const char *name, uint16_t *slotOut) const
Finds a logical slot index by account name.
bool readAccount(uint16_t slot, OathEntry *out)
Reads one OATH entry from secure-element storage.
bool deleteAccount(uint16_t slot)
Deletes account in logical slot.
Per-entry flag bits stored in OathEntry::flags.
constexpr uint8_t USB_CR_SLOT
Designate this CR entry as the USB OTP-HID slot-2 responder.
constexpr uint8_t TOUCH_REQUIRED
Require an on-device touch confirmation before answering a CR request.
OathType
OATH entry type discriminator.
OathAlgorithm
Hash algorithm used by an OATH entry's HMAC engine.
Unified OATH credential record (TOTP, HOTP, and reserved CR).
uint8_t digits
Output digit count (TOTP/HOTP).
uint8_t secret[64]
Raw HMAC key.
uint8_t algorithm
OathAlgorithm value.
uint8_t secretLen
Valid bytes in secret.
uint64_t counter
Moving factor (HOTP only).
uint8_t type
OathType discriminator.
uint32_t period
TOTP step in seconds (TOTP only).
char issuer[32+1]
Optional issuer text.
char name[16+1]
Account label.
uint8_t flags
Reserved entry flags.