8#include <botan/pbkdf.h>
10#include <botan/exceptn.h>
11#include <botan/internal/scan_name.h>
13#if defined(BOTAN_HAS_PBKDF2)
14 #include <botan/pbkdf2.h>
17#if defined(BOTAN_HAS_PGP_S2K)
18 #include <botan/pgp_s2k.h>
23std::unique_ptr<PBKDF>
PBKDF::create(std::string_view algo_spec, std::string_view provider) {
26#if defined(BOTAN_HAS_PBKDF2)
30 if(provider.empty() || provider ==
"base") {
32 return std::make_unique<PKCS5_PBKDF2>(std::move(mac));
36 return std::make_unique<PKCS5_PBKDF2>(std::move(mac));
44#if defined(BOTAN_HAS_PGP_S2K)
47 return std::make_unique<OpenPGP_S2K>(std::move(hash));
72 std::string_view passphrase,
75 std::chrono::milliseconds msec,
76 size_t& iterations)
const {
77 iterations =
pbkdf(out, out_len, passphrase, salt, salt_len, 0, msec);
82 std::string_view passphrase,
85 size_t iterations)
const {
90 const size_t iterations_run =
91 pbkdf(out, out_len, passphrase, salt, salt_len, iterations, std::chrono::milliseconds(0));
96 size_t out_len, std::string_view passphrase,
const uint8_t salt[],
size_t salt_len,
size_t iterations)
const {
98 pbkdf_iterations(out.data(), out_len, passphrase, salt, salt_len, iterations);
103 std::string_view passphrase,
104 const uint8_t salt[],
106 std::chrono::milliseconds msec,
107 size_t& iterations)
const {
109 pbkdf_timed(out.data(), out_len, passphrase, salt, salt_len, msec, iterations);
#define BOTAN_ASSERT_EQUAL(expr1, expr2, assertion_made)
static std::unique_ptr< HashFunction > create(std::string_view algo_spec, std::string_view provider="")
static std::unique_ptr< MessageAuthenticationCode > create(std::string_view algo_spec, std::string_view provider="")
static std::vector< std::string > providers(std::string_view algo_spec)
static std::unique_ptr< PBKDF > create_or_throw(std::string_view algo_spec, std::string_view provider="")
virtual size_t pbkdf(uint8_t out[], size_t out_len, std::string_view passphrase, const uint8_t salt[], size_t salt_len, size_t iterations, std::chrono::milliseconds msec) const =0
void pbkdf_iterations(uint8_t out[], size_t out_len, std::string_view passphrase, const uint8_t salt[], size_t salt_len, size_t iterations) const
void pbkdf_timed(uint8_t out[], size_t out_len, std::string_view passphrase, const uint8_t salt[], size_t salt_len, std::chrono::milliseconds msec, size_t &iterations) const
virtual std::string name() const =0
static std::unique_ptr< PBKDF > create(std::string_view algo_spec, std::string_view provider="")
std::string arg(size_t i) const
const std::string & algo_name() const
std::vector< std::string > probe_providers_of(std::string_view algo_spec, const std::vector< std::string > &possible={"base"})
std::vector< T, secure_allocator< T > > secure_vector