aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_passhash.cpp
diff options
context:
space:
mode:
authorRenĂ© Korthaus <[email protected]>2017-08-18 14:18:27 +0200
committerRenĂ© Korthaus <[email protected]>2017-08-18 14:18:27 +0200
commitfc1a9b50cd49a76dd88460d4e1b3a415c72b638f (patch)
treedbe94f0f789fe1064659f937e671752184264a17 /src/tests/test_passhash.cpp
parent3ecd0b2185c47452b19004d0f4d2782cb29c1bba (diff)
Add guards for MAC and hash algo used in passhash9 tests
Previously, passhash9 tests would fail if for example blowfish was not part of the build. Adds guards for the different MAC and hash algorithms used in passhash9 for calls to generate_passhash9(). For check_passhash9(), there is no way to know that an algorithm is not supported, but at least we improve the situation a bit here.
Diffstat (limited to 'src/tests/test_passhash.cpp')
-rw-r--r--src/tests/test_passhash.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/tests/test_passhash.cpp b/src/tests/test_passhash.cpp
index 5497e35fc..a8877ab3e 100644
--- a/src/tests/test_passhash.cpp
+++ b/src/tests/test_passhash.cpp
@@ -90,7 +90,22 @@ class Passhash9_Tests : public Text_Based_Test
Test::Result result("passhash9");
result.test_eq("correct hash accepted", Botan::check_passhash9(password, passhash), true);
- for(uint8_t alg_id = 0; alg_id <= 4; ++alg_id)
+ std::vector<uint8_t> alg_ids;
+#if defined(BOTAN_HAS_HMAC) && defined(BOTAN_HAS_SHA1)
+ alg_ids.push_back(0);
+#endif
+#if defined(BOTAN_HAS_HMAC) && defined(BOTAN_HAS_SHA2_32)
+ alg_ids.push_back(1);
+#endif
+#if defined(BOTAN_HAS_CMAC) && defined(BOTAN_HAS_BLOWFISH)
+ alg_ids.push_back(2);
+#endif
+#if defined(BOTAN_HAS_HMAC) && defined(BOTAN_HAS_SHA2_64)
+ alg_ids.push_back(3);
+ alg_ids.push_back(4);
+#endif
+
+ for(const auto& alg_id : alg_ids)
{
const std::string gen_hash = Botan::generate_passhash9(password, Test::rng(), 2, alg_id);