diff options
author | lloyd <[email protected]> | 2010-02-14 02:23:43 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-02-14 02:23:43 +0000 |
commit | f4e81d7cd80272aa08f10c7e47d2bae72585bd77 (patch) | |
tree | 62f8cfe36496559f2fcfdc5454a464fea3163ccd /checks/validate.cpp | |
parent | a4124ddf481bfc56859007b34dea646ecb7f8a25 (diff) | |
parent | f2d80a2266e8c3e4ca862a4f36a0d3e874f79dfd (diff) |
propagate from branch 'net.randombit.botan' (head dd33b7150f3f49d795e4eb962d8d41d1ada58d8d)
to branch 'net.randombit.botan.ssl' (head 1452205423962b664263fd2a35149122dfc94d37)
Diffstat (limited to 'checks/validate.cpp')
-rw-r--r-- | checks/validate.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/checks/validate.cpp b/checks/validate.cpp index 9500589ca..b0a877b94 100644 --- a/checks/validate.cpp +++ b/checks/validate.cpp @@ -18,6 +18,11 @@ #include <botan/exceptn.h> #include <botan/selftest.h> #include <botan/libstate.h> + +#if defined(BOTAN_HAS_PASSHASH9) + #include <botan/passhash9.h> +#endif + using namespace Botan; #include "validate.h" @@ -61,6 +66,27 @@ std::vector<std::string> parse(const std::string&); void strip(std::string&); Botan::SecureVector<byte> decode_hex(const std::string&); +bool test_passhash(RandomNumberGenerator& rng) + { +#if defined(BOTAN_HAS_PASSHASH9) + + const std::string input = "secret"; + const std::string fixed_hash = + "$9$AAAKhiHXTIUhNhbegwBXJvk03XXJdzFMy+i3GFMIBYKtthTTmXZA"; + + if(!check_passhash9(input, fixed_hash)) + return false; + + std::string gen_hash = generate_passhash9(input, rng, 5); + + if(!check_passhash9(input, gen_hash)) + return false; + +#endif + + return true; + } + u32bit do_validation_tests(const std::string& filename, RandomNumberGenerator& rng, bool should_pass) @@ -179,6 +205,13 @@ u32bit do_validation_tests(const std::string& filename, } } + + if(should_pass && !test_passhash(rng)) + { + std::cout << "Passhash9 tests failed" << std::endl; + errors++; + } + if(should_pass) std::cout << std::endl; return errors; |