1oath_totp_validate_callback(3) liboath oath_totp_validate_callback(3)
2
3
4
6 oath_totp_validate_callback - API function
7
9 #include <oath.h>
10
11 int oath_totp_validate_callback(const char * secret, size_t
12 secret_length, time_t now, unsigned time_step_size, time_t start_off‐
13 set, unsigned digits, size_t window, oath_validate_strcmp_function str‐
14 cmp_otp, void * strcmp_handle);
15
17 const char * secret
18 the shared secret string
19
20 size_t secret_length
21 length of secret
22
23 time_t now Unix time value to compute TOTP for
24
25 unsigned time_step_size
26 time step system parameter (typically 30)
27
28 time_t start_offset
29 Unix time of when to start counting time steps (typically
30 0)
31
32 unsigned digits
33 number of requested digits in the OTP
34
35 size_t window
36 how many OTPs after start counter to test
37
38 oath_validate_strcmp_function strcmp_otp
39 function pointer to a strcmp-like function.
40
41 void * strcmp_handle
42 caller handle to be passed on to strcmp_otp.
43
45 Validate an OTP according to OATH TOTP algorithm per RFC 6238.
46
47 Validation is implemented by generating a number of potential OTPs and
48 performing a call to the strcmp_otp function, to compare the potential
49 OTP against the given otp. It has the following prototype:
50
51 int (*oath_validate_strcmp_function) (void *handle, const char
52 *test_otp);
53
54 The function should be similar to strcmp in that it return 0 only on
55 matches. It differs by permitting use of negative return codes as
56 indication of internal failures in the callback. Positive values indi‐
57 cate OTP mismatch.
58
59 This callback interface is useful when you cannot compare OTPs directly
60 using normal strcmp, but instead for example only have a hashed OTP.
61 You would then typically pass in the hashed OTP in the strcmp_handle
62 and let your implementation of strcmp_otp hash the test_otp OTP using
63 the same hash, and then compare the results.
64
65 Currently only OTP lengths of 6, 7 or 8 digits are supported. This
66 restrictions may be lifted in future versions, although some limita‐
67 tions are inherent in the protocol.
68
70 Returns position in OTP window (zero is first position), or
71 OATH_INVALID_OTP if no OTP was found in OTP window, or an error code.
72
74 1.6.0
75
77 Report bugs to <oath-toolkit-help@nongnu.org>. liboath home page:
78 http://www.gnu.org/software/liboath/ General help using GNU software:
79 http://www.gnu.org/gethelp/
80
82 Copyright © 2009-2016 Simon Josefsson.
83 Copying and distribution of this file, with or without modification,
84 are permitted in any medium without royalty provided the copyright
85 notice and this notice are preserved.
86
87
88
89liboath 2.6.2 oath_totp_validate_callback(3)