aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/kat_kdf.cpp
blob: 0fc62767393dd3dc2d95a7d68b9e22e7049e974c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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);
   }