Commit Graph

29 Commits

Author SHA1 Message Date
87e8c2862c cli.c: rename key{,len} -> secret{,len} and free after use 2021-02-16 17:01:25 +00:00
dd84a23e7e Provide a single OTP function that accepts a configuration struct 2021-02-16 16:59:56 +00:00
44de0c64b0 strtonum.h still references mystrtonum 2021-02-12 23:10:23 +00:00
bfafd6b964 Fixes regarding CC0 license headers 2021-02-12 23:05:40 +00:00
2fe090286d Rework tests
Split along multiple files, produce TAP output, rely on Perl's prove for
running them. Improves clarity and hopefully makes it easier to add new
tests in the future.
2021-02-12 22:58:09 +00:00
3093486c9f Assume the secret is in base32 by default 2021-02-12 03:04:25 +00:00
15bcd35557 Add base32 decoder 2021-02-12 03:03:30 +00:00
3e8b900464 Change -h to -a 2021-02-12 01:41:54 +00:00
fcd0f1747c Rename step -> period 2021-02-12 01:38:22 +00:00
a51a5b5b0d Use getline 2021-02-11 23:13:08 +00:00
dde97e45d0 Don't call otp if the hmac is unknown 2021-02-11 21:21:01 +00:00
4d2024128e Fix an overflow for 10-digits OTP 2021-02-11 21:20:06 +00:00
0b93ea8653 Rework copyright notices
While at it, rename mystrtonum.[ch] to strtonum.[ch].
2021-02-11 21:04:05 +00:00
33cc12f030 Also run tests with standard input
While there, add a explicit `-h sha1` to TOTP tests.
2020-06-15 23:57:39 +00:00
bec943d06d Read key from standard input if there are no arguments 2020-06-15 23:57:28 +00:00
e1eb8b8d95 Be noisy when both -H and -T are given 2020-06-14 18:23:14 +00:00
24fbaa6e82 Default counter to current seconds since epoch 2020-06-14 18:11:59 +00:00
ecc23ff01f Add options for configuring digits and time step
Default digits to 6 and time step to 30 seconds. This implies passing
`-d 8' to all TOTP test cases.
2020-06-14 18:06:25 +00:00
95341d4ca2 Fix test cases for TOTP
RFC 6238 isn't clear enough in the Test Vectors section, and the
different HMAC algorithms use different secrets.
2020-06-14 17:58:01 +00:00
4e95ab2b5d Add -h flag for using a HMAC other than SHA1 2020-06-14 17:57:42 +00:00
88ec5427c7 Specify the OTP width while printing 2020-06-14 17:33:11 +00:00
41ca24d151 Add TOTP support
Add all the test vectors from RFC 6238, but comment the non-SHA1 ones
for the time being.
2020-06-14 17:31:33 +00:00
22333c5d6e Change totp to take a uint64_t instead of time_t
Let the application deal with converting time_t to uint64_t. For TOTP,
it's just a counter.

While there, rename 'granularity' to 'step', as it's used in RFC 6238.
2020-06-14 17:13:07 +00:00
9a5f0f724e Use strtonum-like functions for parsing numeric arguments 2020-06-14 17:12:55 +00:00
55b0b396dc Small update to err.[ch] 2020-06-14 15:00:33 +00:00
84587a4c32 Add test cases for HOTP 2020-06-14 04:21:11 +00:00
92539dcf58 Add basic CLI support for HOTP 2020-06-14 04:20:51 +00:00
a28d7cca02 Add HOTP implementation 2020-06-14 04:02:13 +00:00
46dd62038f Initial commit 2020-06-14 03:23:29 +00:00