diff options
author | Jack Lloyd <[email protected]> | 2017-03-24 12:31:55 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-03-24 12:31:55 -0400 |
commit | d6ae3dccc2909e03c550ebdf7630a4fc3893557e (patch) | |
tree | 9fc893ae4323fa617fb05c6e230832a5c2abf960 /src | |
parent | fcb23077fbd06db5d49be2f67e9c4aa31d8af359 (diff) |
Avoid long tests for each bcrypt password
Diffstat (limited to 'src')
-rw-r--r-- | src/tests/test_passhash.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/tests/test_passhash.cpp b/src/tests/test_passhash.cpp index 1e83b8d4c..05f53780a 100644 --- a/src/tests/test_passhash.cpp +++ b/src/tests/test_passhash.cpp @@ -36,7 +36,25 @@ 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 : 7); + // 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); + } + + 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) { @@ -44,7 +62,9 @@ class Bcrypt_Tests : public Text_Based_Test result.test_eq("generated hash accepted", Botan::check_bcrypt(password, gen_hash), true); } - return result; + result.set_ns_consumed(Test::timestamp() - start); + + return {result}; } }; |