From 95341d4ca2c83ca7e8e6fff01188ad38ae27e71c Mon Sep 17 00:00:00 2001 From: Lucas Date: Sun, 14 Jun 2020 17:58:01 +0000 Subject: [PATCH] Fix test cases for TOTP RFC 6238 isn't clear enough in the Test Vectors section, and the different HMAC algorithms use different secrets. --- run-tests.sh | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/run-tests.sh b/run-tests.sh index d6515da..e81281e 100644 --- a/run-tests.sh +++ b/run-tests.sh @@ -31,7 +31,11 @@ case_eq() fi } -HOTP_SECRET="12345678901234567890" +b="1234567890" +HOTP_SECRET=$b$b +TOTP_SECRET=$b$b +TOTP_SHA256_SECRET=$b$b$b"12" +TOTP_SHA512_SECRET=$b$b$b$b$b$b"1234" case_eq 755224 ./otpcli -H 0 "$HOTP_SECRET" case_eq 287082 ./otpcli -H 1 "$HOTP_SECRET" @@ -44,24 +48,24 @@ case_eq 162583 ./otpcli -H 7 "$HOTP_SECRET" case_eq 399871 ./otpcli -H 8 "$HOTP_SECRET" case_eq 520489 ./otpcli -H 9 "$HOTP_SECRET" -case_eq 94287082 ./otpcli -T 59 "$HOTP_SECRET" -#case_eq 46119246 ./otpcli -h sha256 -T 59 "$HOTP_SECRET" -#case_eq 90693936 ./otpcli -h sha512 -T 59 "$HOTP_SECRET" -case_eq 07081804 ./otpcli -T 1111111109 "$HOTP_SECRET" -#case_eq 68084774 ./otpcli -h sha256 -T 1111111109 "$HOTP_SECRET" -#case_eq 25091201 ./otpcli -h sha512 -T 1111111109 "$HOTP_SECRET" -case_eq 14050471 ./otpcli -T 1111111111 "$HOTP_SECRET" -#case_eq 67062674 ./otpcli -h sha256 -T 1111111111 "$HOTP_SECRET" -#case_eq 99943326 ./otpcli -h sha512 -T 1111111111 "$HOTP_SECRET" -case_eq 89005924 ./otpcli -T 1234567890 "$HOTP_SECRET" -#case_eq 91819424 ./otpcli -h sha256 -T 1234567890 "$HOTP_SECRET" -#case_eq 93441116 ./otpcli -h sha512 -T 1234567890 "$HOTP_SECRET" -case_eq 69279037 ./otpcli -T 2000000000 "$HOTP_SECRET" -#case_eq 90698825 ./otpcli -h sha256 -T 2000000000 "$HOTP_SECRET" -#case_eq 38618901 ./otpcli -h sha512 -T 2000000000 "$HOTP_SECRET" -case_eq 65353130 ./otpcli -T 20000000000 "$HOTP_SECRET" -#case_eq 77737706 ./otpcli -h sha256 -T 20000000000 "$HOTP_SECRET" -#case_eq 47863826 ./otpcli -h sha512 -T 20000000000 "$HOTP_SECRET" +case_eq 94287082 ./otpcli -T 59 "$TOTP_SECRET" +case_eq 46119246 ./otpcli -h sha256 -T 59 "$TOTP_SHA256_SECRET" +case_eq 90693936 ./otpcli -h sha512 -T 59 "$TOTP_SHA512_SECRET" +case_eq 07081804 ./otpcli -T 1111111109 "$TOTP_SECRET" +case_eq 68084774 ./otpcli -h sha256 -T 1111111109 "$TOTP_SHA256_SECRET" +case_eq 25091201 ./otpcli -h sha512 -T 1111111109 "$TOTP_SHA512_SECRET" +case_eq 14050471 ./otpcli -T 1111111111 "$TOTP_SECRET" +case_eq 67062674 ./otpcli -h sha256 -T 1111111111 "$TOTP_SHA256_SECRET" +case_eq 99943326 ./otpcli -h sha512 -T 1111111111 "$TOTP_SHA512_SECRET" +case_eq 89005924 ./otpcli -T 1234567890 "$TOTP_SECRET" +case_eq 91819424 ./otpcli -h sha256 -T 1234567890 "$TOTP_SHA256_SECRET" +case_eq 93441116 ./otpcli -h sha512 -T 1234567890 "$TOTP_SHA512_SECRET" +case_eq 69279037 ./otpcli -T 2000000000 "$TOTP_SECRET" +case_eq 90698825 ./otpcli -h sha256 -T 2000000000 "$TOTP_SHA256_SECRET" +case_eq 38618901 ./otpcli -h sha512 -T 2000000000 "$TOTP_SHA512_SECRET" +case_eq 65353130 ./otpcli -T 20000000000 "$TOTP_SECRET" +case_eq 77737706 ./otpcli -h sha256 -T 20000000000 "$TOTP_SHA256_SECRET" +case_eq 47863826 ./otpcli -h sha512 -T 20000000000 "$TOTP_SHA512_SECRET" if [ $_test_rc -eq 0 ]; then printf "All %u tests completed successfully!\n" "$_test_nr" >&2