blob: 39340e8a70868e43deddbc335b78159e0ea28b7d (
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
31
32
33
34
35
36
37
38
39
|
/*
* (C) 2014,2015 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#include "tests.h"
#include <botan/pbkdf.h>
#include <botan/lookup.h>
#include <botan/hex.h>
#include <iostream>
#include <fstream>
using namespace Botan;
size_t test_pbkdf()
{
auto test = [](const std::string& input)
{
return run_tests(input, "PBKDF", "Output", true,
[](std::map<std::string, std::string> vec)
{
std::unique_ptr<PBKDF> pbkdf(get_pbkdf(vec["PBKDF"]));
const size_t iterations = to_u32bit(vec["Iterations"]);
const size_t outlen = to_u32bit(vec["OutputLen"]);
const auto salt = hex_decode(vec["Salt"]);
const std::string pass = vec["Passphrase"];
const auto key = pbkdf->derive_key(outlen, pass,
&salt[0], salt.size(),
iterations).bits_of();
return hex_encode(key);
});
};
return run_tests_in_dir(TEST_DATA_DIR "pbkdf", test);
}
|