Rename step -> period
This commit is contained in:
parent
a51a5b5b0d
commit
fcd0f1747c
16
cli.c
16
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);
|
||||
|
4
otp.c
4
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user