From 8f3f7743472ba625a0bb249cd06651ed13325b87 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Fri, 11 May 2018 14:36:24 -0400 Subject: Add docs for TOTP --- doc/manual/otp.rst | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/doc/manual/otp.rst b/doc/manual/otp.rst index 5c49c4533..5a7864afd 100644 --- a/doc/manual/otp.rst +++ b/doc/manual/otp.rst @@ -65,3 +65,32 @@ given to any other symmetric key or plaintext password. then always returns (false,starting_counter), since the last successful authentication counter has not changed. + +TOTP +^^^^^^^^^^ + +TOTP is based on the same algorithm as HOTP, but instead of a counter a +timestamp is used. + +.. cpp:class:: TOTP + + .. cpp:function:: TOTP(const SymmetricKey& key, const std::string& hash_algo = "SHA-1", \ + size_t digits = 6, size_t time_step = 30) + + Setup to perform TOTP authentication using secret key *key*. + + .. cpp:function:: uint32_t generate_totp(std::chrono::system_clock::time_point time_point) + + .. cpp:function:: uint32_t generate_totp(uint64_t unix_time) + + Generate and return a TOTP code based on a timestamp. + + .. cpp:function:: bool verify_totp(uint32_t otp, std::chrono::system_clock::time_point time, \ + size_t clock_drift_accepted = 0) + + .. cpp:function:: bool verify_totp(uint32_t otp, uint64_t unix_time, \ + size_t clock_drift_accepted = 0) + + Return true if the provided OTP code is correct for the provided + timestamp. If required, use *clock_drift_accepted* to deal with + the client and server having slightly different clocks. -- cgit v1.2.3