7#include <botan/pwdhash.h>
9#include <botan/assert.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>
21#if defined(BOTAN_HAS_SCRYPT)
22 #include <botan/scrypt.h>
25#if defined(BOTAN_HAS_ARGON2)
26 #include <botan/argon2.h>
29#if defined(BOTAN_HAS_PBKDF_BCRYPT)
30 #include <botan/bcrypt_pbkdf.h>
33#if defined(BOTAN_HAS_PKCS12_KDF)
34 #include <botan/internal/pkcs12_kdf.h>
48 size_t key_len)
const {
51 if(ad_len == 0 && key_len == 0) {
52 return this->
derive_key(out, out_len, password, password_len, salt, salt_len);
61#if defined(BOTAN_HAS_PBKDF2)
63 if(provider.empty() || provider ==
"base") {
65 return std::make_unique<PBKDF2_Family>(std::move(mac));
69 return std::make_unique<PBKDF2_Family>(std::move(mac));
77#if defined(BOTAN_HAS_SCRYPT)
79 return std::make_unique<Scrypt_Family>();
83#if defined(BOTAN_HAS_ARGON2)
85 return std::make_unique<Argon2_Family>(
static_cast<uint8_t
>(0));
87 return std::make_unique<Argon2_Family>(
static_cast<uint8_t
>(1));
88 }
else if(req.
algo_name() ==
"Argon2id") {
89 return std::make_unique<Argon2_Family>(
static_cast<uint8_t
>(2));
93#if defined(BOTAN_HAS_PBKDF_BCRYPT)
95 return std::make_unique<Bcrypt_PBKDF_Family>();
99#if defined(BOTAN_HAS_PGP_S2K)
102 return std::make_unique<RFC4880_S2K_Family>(std::move(hash));
107#if defined(BOTAN_HAS_PKCS12_KDF)
111 return std::make_unique<PKCS12_KDF_Family>(std::move(hash), id_param);
124 std::string_view provider) {
128 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
size_t arg_as_integer(size_t i, size_t def_value) const
std::vector< std::string > probe_providers_of(std::string_view algo_spec, const std::vector< std::string > &possible={"base"})