diff options
author | Jack Lloyd <[email protected]> | 2017-12-28 12:18:09 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-12-28 12:18:09 -0500 |
commit | eeaa03b1a2b435c6ed01a85305e356df7bc7017e (patch) | |
tree | b896ce5bdb93a96a8229bad5199e22060efc621a /src/tests | |
parent | deaa16feab1a525c90647c59dc96e877dffa812a (diff) |
Add passhash9 tests for edge cases
And correct exception message which referred to bcrypt
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/test_passhash.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/tests/test_passhash.cpp b/src/tests/test_passhash.cpp index 7f42bce4a..be194b553 100644 --- a/src/tests/test_passhash.cpp +++ b/src/tests/test_passhash.cpp @@ -98,7 +98,7 @@ class Passhash9_Tests final : public Text_Based_Test for(uint8_t alg_id = 0; alg_id <= 4; ++alg_id) { if(Botan::is_passhash9_alg_supported(alg_id)) - { + { const std::string gen_hash = Botan::generate_passhash9(password, Test::rng(), 2, alg_id); if(!result.test_eq("generated hash accepted", Botan::check_passhash9(password, gen_hash), true)) @@ -125,6 +125,23 @@ class Passhash9_Tests final : public Text_Based_Test return result; } + + std::vector<Test::Result> run_final_tests() override + { + Test::Result result("passhash9"); + + result.confirm("Unknown algorithm is unknown", + Botan::is_passhash9_alg_supported(255) == false); + + result.test_throws("Throws if algorithm not supported", + "Invalid argument Passhash9: Algorithm id 255 is not defined", + []() { Botan::generate_passhash9("pass", Test::rng(), 3, 255); }); + + result.test_throws("Throws if iterations is too high", + "Invalid argument Requested passhash9 work factor 513 is too large", + []() { Botan::check_passhash9("floof", "$9$AgIB3c5J3kvAuML84sZ5hWT9WzJtiYRPLCEARaujS7I6IKbNCwp0"); }); + return {result}; + } }; BOTAN_REGISTER_TEST("passhash9", Passhash9_Tests); |