7#include <botan/pwdhash.h>
9#include <botan/exceptn.h>
10#include <botan/internal/scan_name.h>
12#if defined(BOTAN_HAS_PBKDF2)
13 #include <botan/pbkdf2.h>
16#if defined(BOTAN_HAS_PGP_S2K)
17 #include <botan/pgp_s2k.h>
20#if defined(BOTAN_HAS_SCRYPT)
21 #include <botan/scrypt.h>
24#if defined(BOTAN_HAS_ARGON2)
25 #include <botan/argon2.h>
28#if defined(BOTAN_HAS_PBKDF_BCRYPT)
29 #include <botan/bcrypt_pbkdf.h>
43 size_t key_len)
const {
46 if(ad_len == 0 && key_len == 0) {
47 return this->
derive_key(out, out_len, password, password_len, salt, salt_len);
56#if defined(BOTAN_HAS_PBKDF2)
58 if(provider.empty() || provider ==
"base") {
60 return std::make_unique<PBKDF2_Family>(std::move(mac));
64 return std::make_unique<PBKDF2_Family>(std::move(mac));
72#if defined(BOTAN_HAS_SCRYPT)
74 return std::make_unique<Scrypt_Family>();
78#if defined(BOTAN_HAS_ARGON2)
80 return std::make_unique<Argon2_Family>(
static_cast<uint8_t
>(0));
82 return std::make_unique<Argon2_Family>(
static_cast<uint8_t
>(1));
83 }
else if(req.
algo_name() ==
"Argon2id") {
84 return std::make_unique<Argon2_Family>(
static_cast<uint8_t
>(2));
88#if defined(BOTAN_HAS_PBKDF_BCRYPT)
90 return std::make_unique<Bcrypt_PBKDF_Family>();
94#if defined(BOTAN_HAS_PGP_S2K)
97 return std::make_unique<RFC4880_S2K_Family>(std::move(hash));
110 std::string_view provider) {
114 throw Lookup_Error(
"PasswordHashFamily", algo, provider);
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::unique_ptr< PasswordHashFamily > create_or_throw(std::string_view algo_spec, std::string_view provider="")
static std::vector< std::string > providers(std::string_view algo_spec)
static std::unique_ptr< PasswordHashFamily > create(std::string_view algo_spec, std::string_view provider="")
virtual void derive_key(uint8_t out[], size_t out_len, const char *password, size_t password_len, const uint8_t salt[], size_t salt_len) const =0
virtual std::string to_string() const =0
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"})