Change -h to -a
This commit is contained in:
parent
fcd0f1747c
commit
3e8b900464
26
cli.c
26
cli.c
@ -32,8 +32,8 @@ static void
|
|||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage:\n"
|
fprintf(stderr, "Usage:\n"
|
||||||
" %s [-d digits] [-h HMAC] -H counter SECRET\n"
|
" %s [-a HMAC] [-d digits] -H counter SECRET\n"
|
||||||
" %s [-d digits] [-h HMAC] [-p period] [-T counter] SECRET\n",
|
" %s [-a HMAC] [-d digits] [-p period] [-T time] SECRET\n",
|
||||||
__progname, __progname);
|
__progname, __progname);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -56,8 +56,18 @@ main(int argc, char *argv[])
|
|||||||
do_hotp = do_totp = 0;
|
do_hotp = do_totp = 0;
|
||||||
hmac = OTP_HMAC_SHA1;
|
hmac = OTP_HMAC_SHA1;
|
||||||
period = 30;
|
period = 30;
|
||||||
while ((ch = getopt(argc, argv, "d:H:h:p:T:")) != -1) {
|
while ((ch = getopt(argc, argv, "a:d:H:p:T:")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
case 'a':
|
||||||
|
if (strcasecmp(optarg, "sha1") == 0)
|
||||||
|
hmac = OTP_HMAC_SHA1;
|
||||||
|
else if (strcasecmp(optarg, "sha256") == 0)
|
||||||
|
hmac = OTP_HMAC_SHA256;
|
||||||
|
else if (strcasecmp(optarg, "sha512") == 0)
|
||||||
|
hmac = OTP_HMAC_SHA512;
|
||||||
|
else
|
||||||
|
usage();
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
digits = strtonum(optarg, 6, 10, &errstr);
|
digits = strtonum(optarg, 6, 10, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
@ -69,16 +79,6 @@ main(int argc, char *argv[])
|
|||||||
errx(1, "counter is %s: %s", errstr, optarg);
|
errx(1, "counter is %s: %s", errstr, optarg);
|
||||||
do_hotp = 1;
|
do_hotp = 1;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
|
||||||
if (strcasecmp(optarg, "sha1") == 0)
|
|
||||||
hmac = OTP_HMAC_SHA1;
|
|
||||||
else if (strcasecmp(optarg, "sha256") == 0)
|
|
||||||
hmac = OTP_HMAC_SHA256;
|
|
||||||
else if (strcasecmp(optarg, "sha512") == 0)
|
|
||||||
hmac = OTP_HMAC_SHA512;
|
|
||||||
else
|
|
||||||
usage();
|
|
||||||
break;
|
|
||||||
case 'p':
|
case 'p':
|
||||||
period = strtonum(optarg, 1, UINT_MAX, &errstr);
|
period = strtonum(optarg, 1, UINT_MAX, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
|
72
run-tests.sh
72
run-tests.sh
@ -75,43 +75,43 @@ case_stdin_eq 162583 "$HOTP_SECRET" ./otpcli -H 7
|
|||||||
case_stdin_eq 399871 "$HOTP_SECRET" ./otpcli -H 8
|
case_stdin_eq 399871 "$HOTP_SECRET" ./otpcli -H 8
|
||||||
case_stdin_eq 520489 "$HOTP_SECRET" ./otpcli -H 9
|
case_stdin_eq 520489 "$HOTP_SECRET" ./otpcli -H 9
|
||||||
|
|
||||||
case_eq 94287082 ./otpcli -d 8 -h sha1 -T 59 "$TOTP_SECRET"
|
case_eq 94287082 ./otpcli -d 8 -a sha1 -T 59 "$TOTP_SECRET"
|
||||||
case_eq 46119246 ./otpcli -d 8 -h sha256 -T 59 "$TOTP_SHA256_SECRET"
|
case_eq 46119246 ./otpcli -d 8 -a sha256 -T 59 "$TOTP_SHA256_SECRET"
|
||||||
case_eq 90693936 ./otpcli -d 8 -h sha512 -T 59 "$TOTP_SHA512_SECRET"
|
case_eq 90693936 ./otpcli -d 8 -a sha512 -T 59 "$TOTP_SHA512_SECRET"
|
||||||
case_eq 07081804 ./otpcli -d 8 -h sha1 -T 1111111109 "$TOTP_SECRET"
|
case_eq 07081804 ./otpcli -d 8 -a sha1 -T 1111111109 "$TOTP_SECRET"
|
||||||
case_eq 68084774 ./otpcli -d 8 -h sha256 -T 1111111109 "$TOTP_SHA256_SECRET"
|
case_eq 68084774 ./otpcli -d 8 -a sha256 -T 1111111109 "$TOTP_SHA256_SECRET"
|
||||||
case_eq 25091201 ./otpcli -d 8 -h sha512 -T 1111111109 "$TOTP_SHA512_SECRET"
|
case_eq 25091201 ./otpcli -d 8 -a sha512 -T 1111111109 "$TOTP_SHA512_SECRET"
|
||||||
case_eq 14050471 ./otpcli -d 8 -h sha1 -T 1111111111 "$TOTP_SECRET"
|
case_eq 14050471 ./otpcli -d 8 -a sha1 -T 1111111111 "$TOTP_SECRET"
|
||||||
case_eq 67062674 ./otpcli -d 8 -h sha256 -T 1111111111 "$TOTP_SHA256_SECRET"
|
case_eq 67062674 ./otpcli -d 8 -a sha256 -T 1111111111 "$TOTP_SHA256_SECRET"
|
||||||
case_eq 99943326 ./otpcli -d 8 -h sha512 -T 1111111111 "$TOTP_SHA512_SECRET"
|
case_eq 99943326 ./otpcli -d 8 -a sha512 -T 1111111111 "$TOTP_SHA512_SECRET"
|
||||||
case_eq 89005924 ./otpcli -d 8 -h sha1 -T 1234567890 "$TOTP_SECRET"
|
case_eq 89005924 ./otpcli -d 8 -a sha1 -T 1234567890 "$TOTP_SECRET"
|
||||||
case_eq 91819424 ./otpcli -d 8 -h sha256 -T 1234567890 "$TOTP_SHA256_SECRET"
|
case_eq 91819424 ./otpcli -d 8 -a sha256 -T 1234567890 "$TOTP_SHA256_SECRET"
|
||||||
case_eq 93441116 ./otpcli -d 8 -h sha512 -T 1234567890 "$TOTP_SHA512_SECRET"
|
case_eq 93441116 ./otpcli -d 8 -a sha512 -T 1234567890 "$TOTP_SHA512_SECRET"
|
||||||
case_eq 69279037 ./otpcli -d 8 -h sha1 -T 2000000000 "$TOTP_SECRET"
|
case_eq 69279037 ./otpcli -d 8 -a sha1 -T 2000000000 "$TOTP_SECRET"
|
||||||
case_eq 90698825 ./otpcli -d 8 -h sha256 -T 2000000000 "$TOTP_SHA256_SECRET"
|
case_eq 90698825 ./otpcli -d 8 -a sha256 -T 2000000000 "$TOTP_SHA256_SECRET"
|
||||||
case_eq 38618901 ./otpcli -d 8 -h sha512 -T 2000000000 "$TOTP_SHA512_SECRET"
|
case_eq 38618901 ./otpcli -d 8 -a sha512 -T 2000000000 "$TOTP_SHA512_SECRET"
|
||||||
case_eq 65353130 ./otpcli -d 8 -h sha1 -T 20000000000 "$TOTP_SECRET"
|
case_eq 65353130 ./otpcli -d 8 -a sha1 -T 20000000000 "$TOTP_SECRET"
|
||||||
case_eq 77737706 ./otpcli -d 8 -h sha256 -T 20000000000 "$TOTP_SHA256_SECRET"
|
case_eq 77737706 ./otpcli -d 8 -a sha256 -T 20000000000 "$TOTP_SHA256_SECRET"
|
||||||
case_eq 47863826 ./otpcli -d 8 -h sha512 -T 20000000000 "$TOTP_SHA512_SECRET"
|
case_eq 47863826 ./otpcli -d 8 -a sha512 -T 20000000000 "$TOTP_SHA512_SECRET"
|
||||||
|
|
||||||
case_stdin_eq 94287082 "$TOTP_SECRET" ./otpcli -d 8 -h sha1 -T 59
|
case_stdin_eq 94287082 "$TOTP_SECRET" ./otpcli -d 8 -a sha1 -T 59
|
||||||
case_stdin_eq 46119246 "$TOTP_SHA256_SECRET" ./otpcli -d 8 -h sha256 -T 59
|
case_stdin_eq 46119246 "$TOTP_SHA256_SECRET" ./otpcli -d 8 -a sha256 -T 59
|
||||||
case_stdin_eq 90693936 "$TOTP_SHA512_SECRET" ./otpcli -d 8 -h sha512 -T 59
|
case_stdin_eq 90693936 "$TOTP_SHA512_SECRET" ./otpcli -d 8 -a sha512 -T 59
|
||||||
case_stdin_eq 07081804 "$TOTP_SECRET" ./otpcli -d 8 -h sha1 -T 1111111109
|
case_stdin_eq 07081804 "$TOTP_SECRET" ./otpcli -d 8 -a sha1 -T 1111111109
|
||||||
case_stdin_eq 68084774 "$TOTP_SHA256_SECRET" ./otpcli -d 8 -h sha256 -T 1111111109
|
case_stdin_eq 68084774 "$TOTP_SHA256_SECRET" ./otpcli -d 8 -a sha256 -T 1111111109
|
||||||
case_stdin_eq 25091201 "$TOTP_SHA512_SECRET" ./otpcli -d 8 -h sha512 -T 1111111109
|
case_stdin_eq 25091201 "$TOTP_SHA512_SECRET" ./otpcli -d 8 -a sha512 -T 1111111109
|
||||||
case_stdin_eq 14050471 "$TOTP_SECRET" ./otpcli -d 8 -h sha1 -T 1111111111
|
case_stdin_eq 14050471 "$TOTP_SECRET" ./otpcli -d 8 -a sha1 -T 1111111111
|
||||||
case_stdin_eq 67062674 "$TOTP_SHA256_SECRET" ./otpcli -d 8 -h sha256 -T 1111111111
|
case_stdin_eq 67062674 "$TOTP_SHA256_SECRET" ./otpcli -d 8 -a sha256 -T 1111111111
|
||||||
case_stdin_eq 99943326 "$TOTP_SHA512_SECRET" ./otpcli -d 8 -h sha512 -T 1111111111
|
case_stdin_eq 99943326 "$TOTP_SHA512_SECRET" ./otpcli -d 8 -a sha512 -T 1111111111
|
||||||
case_stdin_eq 89005924 "$TOTP_SECRET" ./otpcli -d 8 -h sha1 -T 1234567890
|
case_stdin_eq 89005924 "$TOTP_SECRET" ./otpcli -d 8 -a sha1 -T 1234567890
|
||||||
case_stdin_eq 91819424 "$TOTP_SHA256_SECRET" ./otpcli -d 8 -h sha256 -T 1234567890
|
case_stdin_eq 91819424 "$TOTP_SHA256_SECRET" ./otpcli -d 8 -a sha256 -T 1234567890
|
||||||
case_stdin_eq 93441116 "$TOTP_SHA512_SECRET" ./otpcli -d 8 -h sha512 -T 1234567890
|
case_stdin_eq 93441116 "$TOTP_SHA512_SECRET" ./otpcli -d 8 -a sha512 -T 1234567890
|
||||||
case_stdin_eq 69279037 "$TOTP_SECRET" ./otpcli -d 8 -h sha1 -T 2000000000
|
case_stdin_eq 69279037 "$TOTP_SECRET" ./otpcli -d 8 -a sha1 -T 2000000000
|
||||||
case_stdin_eq 90698825 "$TOTP_SHA256_SECRET" ./otpcli -d 8 -h sha256 -T 2000000000
|
case_stdin_eq 90698825 "$TOTP_SHA256_SECRET" ./otpcli -d 8 -a sha256 -T 2000000000
|
||||||
case_stdin_eq 38618901 "$TOTP_SHA512_SECRET" ./otpcli -d 8 -h sha512 -T 2000000000
|
case_stdin_eq 38618901 "$TOTP_SHA512_SECRET" ./otpcli -d 8 -a sha512 -T 2000000000
|
||||||
case_stdin_eq 65353130 "$TOTP_SECRET" ./otpcli -d 8 -h sha1 -T 20000000000
|
case_stdin_eq 65353130 "$TOTP_SECRET" ./otpcli -d 8 -a sha1 -T 20000000000
|
||||||
case_stdin_eq 77737706 "$TOTP_SHA256_SECRET" ./otpcli -d 8 -h sha256 -T 20000000000
|
case_stdin_eq 77737706 "$TOTP_SHA256_SECRET" ./otpcli -d 8 -a sha256 -T 20000000000
|
||||||
case_stdin_eq 47863826 "$TOTP_SHA512_SECRET" ./otpcli -d 8 -h sha512 -T 20000000000
|
case_stdin_eq 47863826 "$TOTP_SHA512_SECRET" ./otpcli -d 8 -a sha512 -T 20000000000
|
||||||
|
|
||||||
if [ $_test_rc -eq 0 ]; then
|
if [ $_test_rc -eq 0 ]; then
|
||||||
printf "All %u tests completed successfully!\n" "$_test_nr" >&2
|
printf "All %u tests completed successfully!\n" "$_test_nr" >&2
|
||||||
|
Loading…
Reference in New Issue
Block a user