aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-08-08 16:43:30 -0400
committerJack Lloyd <[email protected]>2018-08-08 16:43:30 -0400
commita048766b33e88f3ffe5ca71a65105c9f58d55ecf (patch)
tree1372ad10a75a3d5a5cc3460f32b8d332cc12056b
parentbab49afef583a32b4e084b6a56bb36911b528331 (diff)
Add test that invalid bcrypt versions are rejected
-rw-r--r--src/tests/test_passhash.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/tests/test_passhash.cpp b/src/tests/test_passhash.cpp
index 7f8d6a4f9..546dce39e 100644
--- a/src/tests/test_passhash.cpp
+++ b/src/tests/test_passhash.cpp
@@ -39,7 +39,7 @@ class Bcrypt_Tests final : public Text_Based_Test
// self-test low levels for each test password
for(uint16_t level = 4; level <= 6; ++level)
{
- const std::string gen_hash = generate_bcrypt(password, Test::rng(), level);
+ const std::string gen_hash = Botan::generate_bcrypt(password, Test::rng(), level);
result.test_eq("generated hash accepted", Botan::check_bcrypt(password, gen_hash), true);
}
@@ -58,10 +58,14 @@ class Bcrypt_Tests final : public Text_Based_Test
for(uint16_t level = 4; level <= max_level; ++level)
{
- const std::string gen_hash = generate_bcrypt(password, Test::rng(), level);
+ const std::string gen_hash = Botan::generate_bcrypt(password, Test::rng(), level);
result.test_eq("generated hash accepted", Botan::check_bcrypt(password, gen_hash), true);
}
+ result.test_throws("Invalid bcrypt version rejected",
+ "Invalid argument Unknown bcrypt version 'q'",
+ []() { Botan::generate_bcrypt("pass", Test::rng(), 4, 'q'); });
+
result.set_ns_consumed(Test::timestamp() - start);
return {result};