26 HOTP(
const SymmetricKey& key, std::string_view hash_algo =
"SHA-1",
size_t digits = 6) :
27 HOTP(key.begin(), key.size(), hash_algo, digits) {}
35 HOTP(
const uint8_t key[],
size_t key_len, std::string_view hash_algo =
"SHA-1",
size_t digits = 6);
41 uint32_t generate_hotp(uint64_t counter);
53 std::pair<bool, uint64_t> verify_hotp(uint32_t otp, uint64_t starting_counter,
size_t resync_range = 0);
56 std::unique_ptr<MessageAuthenticationCode> m_mac;
71 TOTP(
const SymmetricKey& key, std::string_view hash_algo =
"SHA-1",
size_t digits = 6,
size_t time_step = 30) :
72 TOTP(key.begin(), key.size(), hash_algo, digits, time_step) {}
81 TOTP(
const uint8_t key[],
83 std::string_view hash_algo =
"SHA-1",
85 size_t time_step = 30);
90 uint32_t generate_totp(std::chrono::system_clock::time_point time_point);
96 uint32_t generate_totp(uint64_t unix_time);
98 bool verify_totp(uint32_t otp, std::chrono::system_clock::time_point time,
size_t clock_drift_accepted = 0);
100 bool verify_totp(uint32_t otp, uint64_t unix_time,
size_t clock_drift_accepted = 0);
105 std::chrono::system_clock::time_point m_unix_epoch;