diff options
Diffstat (limited to 'src/tests/kat_kdf.cpp')
-rw-r--r-- | src/tests/kat_kdf.cpp | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/src/tests/kat_kdf.cpp b/src/tests/kat_kdf.cpp index 86b3ea5c4..0fc627673 100644 --- a/src/tests/kat_kdf.cpp +++ b/src/tests/kat_kdf.cpp @@ -7,37 +7,24 @@ using namespace Botan; -namespace { - -secure_vector<byte> kdf(const std::string& algo, - size_t outlen, - const secure_vector<byte>& secret, - const secure_vector<byte>& salt) - { - std::unique_ptr<KDF> kdf(get_kdf(algo)); - return kdf->derive_key(outlen, secret, salt); - } - -std::string kdf_test(const std::string& algo, - size_t outlen, - const std::string& secret, - const std::string& salt) +size_t test_kdf() { - return hex_encode(kdf(algo, outlen, - hex_decode_locked(secret), - hex_decode_locked(salt))); - } + 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"]); -size_t test_kdf() - { - std::ifstream vec(TEST_DATA_DIR "/kdf.vec"); + const auto key = kdf->derive_key(outlen, secret, salt); - return run_tests(vec, "KDF", "Output", true, - [](std::map<std::string, std::string> m) - { - return kdf_test(m["KDF"], to_u32bit(m["OutputLen"]), - m["Secret"], m["Salt"]); + return hex_encode(key); }); + }; + + return run_tests_in_dir(TEST_DATA_DIR "kdf", test); } |