|
libkeepass 0.2.0
KeePass key database importer/exporter library
|
Parsed TOTP parameters from an entry's custom fields. More...
#include <totp.hh>
Public Types | |
| enum class | Algorithm { kSha1 , kSha256 , kSha512 } |
| Hash algorithms used by the HMAC-based TOTP construction. | |
Public Member Functions | |
| TotpConfig ()=default | |
| Creates an empty (invalid) configuration. | |
| TotpConfig (secure_string secret, uint32_t period=30, uint32_t digits=6, Algorithm algorithm=Algorithm::kSha1) | |
| const secure_string & | secret () const |
| Returns the Base32 shared secret. | |
| void | set_secret (const secure_string &secret) |
| Replaces the Base32 shared secret. | |
| uint32_t | period () const |
| Returns the time step in seconds. | |
| void | set_period (uint32_t period) |
| Sets the time step in seconds (clamped to at least one second). | |
| uint32_t | digits () const |
| Returns the number of output digits. | |
| void | set_digits (uint32_t digits) |
| Sets the number of output digits (supported range 1-10). | |
| Algorithm | algorithm () const |
| Returns the HMAC algorithm. | |
| void | set_algorithm (Algorithm algorithm) |
| Sets the HMAC algorithm. | |
| bool | empty () const |
| Returns whether a secret is present. | |
Static Public Member Functions | |
| static std::optional< TotpConfig > | Parse (const std::string &seed_field, const std::string &settings_field={}) |
| Parses a TOTP seed/URI plus optional settings string. | |
| static std::optional< TotpConfig > | FromEntry (const Entry &entry) |
| Extracts and parses the TOTP fields of an entry. | |
Parsed TOTP parameters from an entry's custom fields.
KeePass implementations store TOTP settings in different ways:
otp/TOTP Seed/otp seed fields hold either a Base32 secret or a complete otpauth://totp/... URI,TOTP Settings field holds period;digits, comma/ampersand separated key=value pairs (period=30&digits=6&algorithm=SHA1) or an otpauth URI.The secret is kept in a wiped secure_string.
|
explicit |
| secret | Base32-encoded shared secret. |
| period | Time step in seconds (default 30). |
| digits | Number of output digits (default 6). |
| algorithm | HMAC algorithm (default SHA-1, as used by most clients). |
|
static |
Parses a TOTP seed/URI plus optional settings string.
| seed_field | Value of otp, TOTP Seed or a similar custom field. |
| settings_field | Optional TOTP Settings value. |
std::nullopt if the seed is missing/invalid or describes an unsupported (HOTP) token.