diff options
author | Jack Lloyd <[email protected]> | 2018-08-08 16:43:30 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-08-08 16:43:30 -0400 |
commit | a048766b33e88f3ffe5ca71a65105c9f58d55ecf (patch) | |
tree | 1372ad10a75a3d5a5cc3460f32b8d332cc12056b /src/tests/test_passhash.cpp | |
parent | bab49afef583a32b4e084b6a56bb36911b528331 (diff) |
Add test that invalid bcrypt versions are rejected
Diffstat (limited to 'src/tests/test_passhash.cpp')
-rw-r--r-- | src/tests/test_passhash.cpp | 8 |
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}; |