aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_kdf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/test_kdf.cpp')
-rw-r--r--src/tests/test_kdf.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/tests/test_kdf.cpp b/src/tests/test_kdf.cpp
new file mode 100644
index 000000000..0fc627673
--- /dev/null
+++ b/src/tests/test_kdf.cpp
@@ -0,0 +1,30 @@
+#include "tests.h"
+
+#include <botan/lookup.h>
+#include <botan/hex.h>
+#include <iostream>
+#include <fstream>
+
+using namespace Botan;
+
+size_t test_kdf()
+ {
+ auto test = [](const std::string& input)
+ {
+ return run_tests(input, "KDF", "Output", true,
+ [](std::map<std::string, std::string> vec)
+ {
+ std::unique_ptr<KDF> kdf(get_kdf(vec["KDF"]));
+
+ const size_t outlen = to_u32bit(vec["OutputLen"]);
+ const auto salt = hex_decode(vec["Salt"]);
+ const auto secret = hex_decode(vec["Secret"]);
+
+ const auto key = kdf->derive_key(outlen, secret, salt);
+
+ return hex_encode(key);
+ });
+ };
+
+ return run_tests_in_dir(TEST_DATA_DIR "kdf", test);
+ }