#include "validate.h" #include #include #include #include #include using namespace Botan; namespace { secure_vector pbkdf(const std::string& algo, const std::string& pass, const secure_vector& salt, size_t iterations, size_t outlen) { std::unique_ptr pbkdf(get_pbkdf(algo)); return pbkdf->derive_key(outlen, pass, &salt[0], salt.size(), iterations).bits_of(); } std::string pbkdf_test(const std::string& algo, const std::string& pass, const std::string& salt, size_t iterations, size_t outlen) { return hex_encode(pbkdf(algo, pass, hex_decode_locked(salt), iterations, outlen)); } } void test_pbkdf() { std::ifstream vec("checks/pbkdf.vec"); run_tests(vec, "PBKDF", "Output", true, [](std::map m) { return pbkdf_test(m["PBKDF"], m["Passphrase"], m["Salt"], to_u32bit(m["Iterations"]), to_u32bit(m["OutputLen"])); }); }