diff options
author | Jack Lloyd <[email protected]> | 2017-03-28 11:49:10 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-03-28 11:49:10 -0400 |
commit | 6378305fb557ddac52b5f0e9ca69eac1d10bb541 (patch) | |
tree | 37119bbef743a949fdd3a713e21b7d432b078ee3 /src/tests/test_passhash.cpp | |
parent | 5c54bff2e4a4c433500dbef77d1088dffb202464 (diff) | |
parent | d6ae3dccc2909e03c550ebdf7630a4fc3893557e (diff) |
Merge GH #938 Fix incorrect bcrypt truncation
Diffstat (limited to 'src/tests/test_passhash.cpp')
-rw-r--r-- | src/tests/test_passhash.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/tests/test_passhash.cpp b/src/tests/test_passhash.cpp index 126b68780..05f53780a 100644 --- a/src/tests/test_passhash.cpp +++ b/src/tests/test_passhash.cpp @@ -36,9 +36,8 @@ class Bcrypt_Tests : public Text_Based_Test Test::Result result("bcrypt"); result.test_eq("correct hash accepted", Botan::check_bcrypt(password, passhash), true); - const size_t max_level = (Test::run_long_tests() ? 14 : 11); - - for(size_t level = 1; level <= max_level; ++level) + // self-test low levels for each test password + for(size_t level = 4; level <= 6; ++level) { const std::string gen_hash = generate_bcrypt(password, Test::rng(), level); result.test_eq("generated hash accepted", Botan::check_bcrypt(password, gen_hash), true); @@ -46,6 +45,27 @@ class Bcrypt_Tests : public Text_Based_Test return result; } + + std::vector<Test::Result> run_final_tests() + { + Test::Result result("bcrypt"); + + uint64_t start = Test::timestamp(); + + const std::string password = "ag00d1_2BE5ur3"; + + const size_t max_level = (Test::run_long_tests() ? 15 : 10); + + for(size_t level = 4; level <= max_level; ++level) + { + const std::string gen_hash = generate_bcrypt(password, Test::rng(), level); + result.test_eq("generated hash accepted", Botan::check_bcrypt(password, gen_hash), true); + } + + result.set_ns_consumed(Test::timestamp() - start); + + return {result}; + } }; BOTAN_REGISTER_TEST("bcrypt", Bcrypt_Tests); |