15TOTP::TOTP(
const uint8_t key[],
size_t key_len, std::string_view hash_algo,
size_t digits,
size_t time_step) :
16 m_hotp(key, key_len, hash_algo, digits),
17 m_time_step(time_step),
18 m_unix_epoch(
calendar_point(1970, 1, 1, 0, 0, 0).to_std_timepoint()) {
23 BOTAN_ARG_CHECK(m_time_step > 0 && m_time_step < 300,
"Invalid TOTP time step");
41 uint64_t t = unix_time / m_time_step;
43 for(
size_t i = 0; i <= clock_drift_accepted; ++i) {
44 if(m_hotp.generate_hotp(t - i) == otp) {