From fcd0f1747c3f9c2c1f62f6599bf6ec1ccabb7ac9 Mon Sep 17 00:00:00 2001 From: Lucas Date: Fri, 12 Feb 2021 01:38:22 +0000 Subject: [PATCH] Rename step -> period --- cli.c | 16 ++++++++-------- otp.c | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cli.c b/cli.c index c758859..d544f0d 100644 --- a/cli.c +++ b/cli.c @@ -33,7 +33,7 @@ usage(void) { fprintf(stderr, "Usage:\n" " %s [-d digits] [-h HMAC] -H counter SECRET\n" - " %s [-d digits] [-h HMAC] [-s step] [-T counter] SECRET\n", + " %s [-d digits] [-h HMAC] [-p period] [-T counter] SECRET\n", __progname, __progname); exit(1); } @@ -46,7 +46,7 @@ main(int argc, char *argv[]) size_t key_len, linesz; ssize_t linelen; uint64_t counter; - unsigned int step; + unsigned int period; int32_t r; int ch, digits, do_hotp, do_totp; enum otp_hmac hmac; @@ -55,8 +55,8 @@ main(int argc, char *argv[]) digits = 6; do_hotp = do_totp = 0; hmac = OTP_HMAC_SHA1; - step = 30; - while ((ch = getopt(argc, argv, "d:H:h:s:T:")) != -1) { + period = 30; + while ((ch = getopt(argc, argv, "d:H:h:p:T:")) != -1) { switch (ch) { case 'd': digits = strtonum(optarg, 6, 10, &errstr); @@ -79,10 +79,10 @@ main(int argc, char *argv[]) else usage(); break; - case 's': - step = strtonum(optarg, 1, UINT_MAX, &errstr); + case 'p': + period = strtonum(optarg, 1, UINT_MAX, &errstr); if (errstr != NULL) - errx(1, "step is %s: %s", errstr, optarg); + errx(1, "period is %s: %s", errstr, optarg); break; case 'T': counter = strtonum(optarg, 0, LLONG_MAX, &errstr); @@ -128,7 +128,7 @@ main(int argc, char *argv[]) errx(1, "couldn't calculate HOTP"); printf("%0*" PRId32 "\n", digits, r); } else { - r = totp(hmac, key, key_len, counter, step, digits); + r = totp(hmac, key, key_len, counter, period, digits); if (r == -1) errx(1, "couldn't calculate TOTP"); printf("%0*" PRId32 "\n", digits, r); diff --git a/otp.c b/otp.c index 05316bc..2b5f8ba 100644 --- a/otp.c +++ b/otp.c @@ -93,7 +93,7 @@ hotp(enum otp_hmac hmac, const void *key, size_t key_len, uint64_t counter, int32_t totp(enum otp_hmac hmac, const void *key, size_t key_len, uint64_t t, - unsigned int step, unsigned int digits) + unsigned int period, unsigned int digits) { - return hotp(hmac, key, key_len, t / step, digits); + return hotp(hmac, key, key_len, t / period, digits); }