aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/manual/contents.rst1
-rw-r--r--doc/manual/otp.rst3
-rw-r--r--src/tests/test_otp.cpp14
3 files changed, 11 insertions, 7 deletions
diff --git a/doc/manual/contents.rst b/doc/manual/contents.rst
index 20bd855a0..23fa218b2 100644
--- a/doc/manual/contents.rst
+++ b/doc/manual/contents.rst
@@ -30,6 +30,7 @@ Contents
compression
pkcs11
tpm
+ otp
ffi
python
cli
diff --git a/doc/manual/otp.rst b/doc/manual/otp.rst
index 1be117478..5c49c4533 100644
--- a/doc/manual/otp.rst
+++ b/doc/manual/otp.rst
@@ -29,6 +29,9 @@ client, so it should be treated with the same security consideration as would be
given to any other symmetric key or plaintext password.
.. cpp:class:: HOTP
+
+ Implement counter-based OTP
+
.. cpp:function:: HOTP(const SymmetricKey& key, const std::string& hash_algo = "SHA-1", size_t digits = 6)
Initialize an HOTP instance with a secret key (specific to each client),
diff --git a/src/tests/test_otp.cpp b/src/tests/test_otp.cpp
index aa899f764..480065194 100644
--- a/src/tests/test_otp.cpp
+++ b/src/tests/test_otp.cpp
@@ -35,7 +35,7 @@ class HOTP_KAT_Tests : public Text_Based_Test
const std::vector<uint8_t> key = get_req_bin(vars, "Key");
const size_t otp = get_req_sz(vars, "OTP");
- const size_t counter = get_req_sz(vars, "Counter");
+ const uint64_t counter = get_req_sz(vars, "Counter");
const size_t digits = get_req_sz(vars, "Digits");
Botan::HOTP hotp(key, hash_algo, digits);
@@ -44,28 +44,28 @@ class HOTP_KAT_Tests : public Text_Based_Test
std::pair<bool, uint64_t> otp_res = hotp.verify_hotp(otp, counter, 0);
result.test_eq("OTP verify result", otp_res.first, true);
- result.test_eq("OTP verify next counter", otp_res.second, counter + 1);
+ result.confirm("OTP verify next counter", otp_res.second == counter + 1);
// Test invalid OTP
otp_res = hotp.verify_hotp(otp + 1, counter, 0);
result.test_eq("OTP verify result", otp_res.first, false);
- result.test_eq("OTP verify next counter", otp_res.second, counter);
+ result.confirm("OTP verify next counter", otp_res.second == counter);
// Test invalid OTP with long range
otp_res = hotp.verify_hotp(otp + 1, counter, 100);
result.test_eq("OTP verify result", otp_res.first, false);
- result.test_eq("OTP verify next counter", otp_res.second, counter);
+ result.confirm("OTP verify next counter", otp_res.second == counter);
// Test valid OTP with long range
otp_res = hotp.verify_hotp(otp, counter - 90, 100);
result.test_eq("OTP verify result", otp_res.first, true);
- result.test_eq("OTP verify next counter", otp_res.second, counter + 1);
+ result.confirm("OTP verify next counter", otp_res.second == counter + 1);
return result;
}
};
-BOTAN_REGISTER_TEST("hotp", HOTP_KAT_Tests);
+BOTAN_REGISTER_TEST("otp_hotp", HOTP_KAT_Tests);
#endif
@@ -124,7 +124,7 @@ class TOTP_KAT_Tests : public Text_Based_Test
}
};
-BOTAN_REGISTER_TEST("totp", TOTP_KAT_Tests);
+BOTAN_REGISTER_TEST("otp_totp", TOTP_KAT_Tests);
#endif
}