Rename step -> period

This commit is contained in:
Lucas 2021-02-12 01:38:22 +00:00
parent a51a5b5b0d
commit fcd0f1747c
2 changed files with 10 additions and 10 deletions

16
cli.c
View File

@ -33,7 +33,7 @@ usage(void)
{ {
fprintf(stderr, "Usage:\n" fprintf(stderr, "Usage:\n"
" %s [-d digits] [-h HMAC] -H counter SECRET\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); __progname, __progname);
exit(1); exit(1);
} }
@ -46,7 +46,7 @@ main(int argc, char *argv[])
size_t key_len, linesz; size_t key_len, linesz;
ssize_t linelen; ssize_t linelen;
uint64_t counter; uint64_t counter;
unsigned int step; unsigned int period;
int32_t r; int32_t r;
int ch, digits, do_hotp, do_totp; int ch, digits, do_hotp, do_totp;
enum otp_hmac hmac; enum otp_hmac hmac;
@ -55,8 +55,8 @@ main(int argc, char *argv[])
digits = 6; digits = 6;
do_hotp = do_totp = 0; do_hotp = do_totp = 0;
hmac = OTP_HMAC_SHA1; hmac = OTP_HMAC_SHA1;
step = 30; period = 30;
while ((ch = getopt(argc, argv, "d:H:h:s:T:")) != -1) { while ((ch = getopt(argc, argv, "d:H:h:p:T:")) != -1) {
switch (ch) { switch (ch) {
case 'd': case 'd':
digits = strtonum(optarg, 6, 10, &errstr); digits = strtonum(optarg, 6, 10, &errstr);
@ -79,10 +79,10 @@ main(int argc, char *argv[])
else else
usage(); usage();
break; break;
case 's': case 'p':
step = strtonum(optarg, 1, UINT_MAX, &errstr); period = strtonum(optarg, 1, UINT_MAX, &errstr);
if (errstr != NULL) if (errstr != NULL)
errx(1, "step is %s: %s", errstr, optarg); errx(1, "period is %s: %s", errstr, optarg);
break; break;
case 'T': case 'T':
counter = strtonum(optarg, 0, LLONG_MAX, &errstr); counter = strtonum(optarg, 0, LLONG_MAX, &errstr);
@ -128,7 +128,7 @@ main(int argc, char *argv[])
errx(1, "couldn't calculate HOTP"); errx(1, "couldn't calculate HOTP");
printf("%0*" PRId32 "\n", digits, r); printf("%0*" PRId32 "\n", digits, r);
} else { } else {
r = totp(hmac, key, key_len, counter, step, digits); r = totp(hmac, key, key_len, counter, period, digits);
if (r == -1) if (r == -1)
errx(1, "couldn't calculate TOTP"); errx(1, "couldn't calculate TOTP");
printf("%0*" PRId32 "\n", digits, r); printf("%0*" PRId32 "\n", digits, r);

4
otp.c
View File

@ -93,7 +93,7 @@ hotp(enum otp_hmac hmac, const void *key, size_t key_len, uint64_t counter,
int32_t int32_t
totp(enum otp_hmac hmac, const void *key, size_t key_len, uint64_t 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);
} }