Botan 3.6.1
Crypto and TLS for C&
|
#include <otp.h>
Public Member Functions | |
uint32_t | generate_totp (std::chrono::system_clock::time_point time_point) |
uint32_t | generate_totp (uint64_t unix_time) |
TOTP (const SymmetricKey &key, std::string_view hash_algo="SHA-1", size_t digits=6, size_t time_step=30) | |
TOTP (const uint8_t key[], size_t key_len, std::string_view hash_algo="SHA-1", size_t digits=6, size_t time_step=30) | |
bool | verify_totp (uint32_t otp, std::chrono::system_clock::time_point time, size_t clock_drift_accepted=0) |
bool | verify_totp (uint32_t otp, uint64_t unix_time, size_t clock_drift_accepted=0) |
|
inline |
key | the secret key shared between client and server |
hash_algo | the hash algorithm to use, should be SHA-1, SHA-256 or SHA-512 |
digits | the number of digits in the OTP (must be 6, 7, or 8) |
time_step | granularity of OTP in seconds |
Botan::TOTP::TOTP | ( | const uint8_t | key[], |
size_t | key_len, | ||
std::string_view | hash_algo = "SHA-1", | ||
size_t | digits = 6, | ||
size_t | time_step = 30 ) |
key | the secret key shared between client and server |
key_len | length of key |
hash_algo | the hash algorithm to use, should be SHA-1, SHA-256 or SHA-512 |
digits | the number of digits in the OTP (must be 6, 7, or 8) |
time_step | granularity of OTP in seconds |
Definition at line 14 of file totp.cpp.
References BOTAN_ARG_CHECK.
uint32_t Botan::TOTP::generate_totp | ( | std::chrono::system_clock::time_point | time_point | ) |
Convert the provided time_point to a Unix timestamp and call generate_totp
Definition at line 25 of file totp.cpp.
References generate_totp().
Referenced by generate_totp().
uint32_t Botan::TOTP::generate_totp | ( | uint64_t | unix_time | ) |
Generate the OTP corresponding the the provided "Unix timestamp" (ie number of seconds since midnight Jan 1, 1970)
Definition at line 30 of file totp.cpp.
References Botan::HOTP::generate_hotp().
bool Botan::TOTP::verify_totp | ( | uint32_t | otp, |
std::chrono::system_clock::time_point | time, | ||
size_t | clock_drift_accepted = 0 ) |
Definition at line 34 of file totp.cpp.
References verify_totp().
Referenced by verify_totp().
bool Botan::TOTP::verify_totp | ( | uint32_t | otp, |
uint64_t | unix_time, | ||
size_t | clock_drift_accepted = 0 ) |
Definition at line 39 of file totp.cpp.
References Botan::HOTP::generate_hotp().