aboutsummaryrefslogtreecommitdiffstats
path: root/checks/validate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'checks/validate.cpp')
-rw-r--r--checks/validate.cpp33
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;