aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_pbkdf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/test_pbkdf.cpp')
-rw-r--r--src/tests/test_pbkdf.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/tests/test_pbkdf.cpp b/src/tests/test_pbkdf.cpp
index 37d3c3125..6694e0522 100644
--- a/src/tests/test_pbkdf.cpp
+++ b/src/tests/test_pbkdf.cpp
@@ -14,6 +14,10 @@
#include <botan/pgp_s2k.h>
#endif
+#if defined(BOTAN_HAS_SCRYPT)
+ #include <botan/scrypt.h>
+#endif
+
namespace Botan_Tests {
namespace {
@@ -57,6 +61,43 @@ BOTAN_REGISTER_TEST("pbkdf", PBKDF_KAT_Tests);
#endif
+#if defined(BOTAN_HAS_SCRYPT)
+
+class Scrypt_KAT_Tests final : public Text_Based_Test
+ {
+ public:
+ Scrypt_KAT_Tests() : Text_Based_Test("scrypt.vec", "Passphrase,Salt,N,R,P,Output") {}
+
+ Test::Result run_one_test(const std::string&, const VarMap& vars) override
+ {
+ const size_t N = get_req_sz(vars, "N");
+ const size_t R = get_req_sz(vars, "R");
+ const size_t P = get_req_sz(vars, "P");
+ const std::vector<uint8_t> salt = get_req_bin(vars, "Salt");
+ const std::string passphrase = get_req_str(vars, "Passphrase");
+ const std::vector<uint8_t> expected = get_req_bin(vars, "Output");
+
+ Test::Result result("scrypt");
+
+ if(N >= 1048576 && Test::run_long_tests() == false)
+ return result;
+
+ std::vector<uint8_t> output(expected.size());
+ Botan::scrypt(output.data(), output.size(),
+ passphrase, salt.data(), salt.size(),
+ N, R, P);
+
+ result.test_eq("derived key", output, expected);
+
+ return result;
+ }
+
+ };
+
+BOTAN_REGISTER_TEST("scrypt", Scrypt_KAT_Tests);
+
+#endif
+
#if defined(BOTAN_HAS_PGP_S2K)
class PGP_S2K_Iter_Test final : public Test