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.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/tests/test_kdf.cpp b/src/tests/test_kdf.cpp
index 775f5b5ac..c85f2880f 100644
--- a/src/tests/test_kdf.cpp
+++ b/src/tests/test_kdf.cpp
@@ -10,6 +10,10 @@
#include <botan/kdf.h>
#endif
+#if defined(BOTAN_HAS_HKDF)
+ #include <botan/hkdf.h>
+#endif
+
namespace Botan_Tests {
namespace {
@@ -55,6 +59,40 @@ BOTAN_REGISTER_TEST("kdf", KDF_KAT_Tests);
#endif
+#if defined(BOTAN_HAS_HKDF)
+class HKDF_Expand_Label_Tests final : public Text_Based_Test
+ {
+ public:
+ HKDF_Expand_Label_Tests() :
+ Text_Based_Test("hkdf_label.vec", "Secret,Label,HashValue,Output") {}
+
+ Test::Result run_one_test(const std::string& hash_name, const VarMap& vars) override
+ {
+ Test::Result result("HKDF-Expand-Label(" + hash_name + ")");
+
+ const std::vector<uint8_t> secret = get_req_bin(vars, "Secret");
+ const std::vector<uint8_t> hashval = get_req_bin(vars, "HashValue");
+ const std::string label = get_req_str(vars, "Label");
+ const std::vector<uint8_t> expected = get_req_bin(vars, "Output");
+
+ Botan::secure_vector<uint8_t> output =
+ Botan::hkdf_expand_label(hash_name,
+ secret.data(), secret.size(),
+ label,
+ hashval.data(), hashval.size(),
+ expected.size());
+
+ result.test_eq("Output matches", output, expected);
+
+ return result;
+ }
+
+ };
+
+BOTAN_REGISTER_TEST("hkdf_expand_label", HKDF_Expand_Label_Tests);
+
+#endif
+
}
}