diff options
author | Jack Lloyd <[email protected]> | 2018-05-11 14:36:24 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-05-11 14:36:24 -0400 |
commit | 8f3f7743472ba625a0bb249cd06651ed13325b87 (patch) | |
tree | 557ab77f62c234aaf6eaf80d90e88cc4fe58ad83 /doc | |
parent | dd20ac1c786565022a5251ef86a62145a6e6f966 (diff) |
Add docs for TOTP
Diffstat (limited to 'doc')
-rw-r--r-- | doc/manual/otp.rst | 29 |
1 files changed, 29 insertions, 0 deletions
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. |