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>
44 size_t key_len)
const {
47 if(ad_len == 0 && key_len == 0) {
48 return this->
derive_key(out, out_len, password, password_len, salt, salt_len);
57#if defined(BOTAN_HAS_PBKDF2)
59 if(provider.empty() || provider ==
"base") {
61 return std::make_unique<PBKDF2_Family>(std::move(mac));
65 return std::make_unique<PBKDF2_Family>(std::move(mac));
73#if defined(BOTAN_HAS_SCRYPT)
75 return std::make_unique<Scrypt_Family>();
79#if defined(BOTAN_HAS_ARGON2)
81 return std::make_unique<Argon2_Family>(
static_cast<uint8_t
>(0));
83 return std::make_unique<Argon2_Family>(
static_cast<uint8_t
>(1));
84 }
else if(req.
algo_name() ==
"Argon2id") {
85 return std::make_unique<Argon2_Family>(
static_cast<uint8_t
>(2));
89#if defined(BOTAN_HAS_PBKDF_BCRYPT)
91 return std::make_unique<Bcrypt_PBKDF_Family>();
95#if defined(BOTAN_HAS_PGP_S2K)
98 return std::make_unique<RFC4880_S2K_Family>(std::move(hash));
111 std::string_view provider) {
115 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"})