7#include <botan/pwdhash.h>
8#include <botan/exceptn.h>
9#include <botan/internal/scan_name.h>
11#if defined(BOTAN_HAS_PBKDF2)
12 #include <botan/pbkdf2.h>
15#if defined(BOTAN_HAS_PGP_S2K)
16 #include <botan/pgp_s2k.h>
19#if defined(BOTAN_HAS_SCRYPT)
20 #include <botan/scrypt.h>
23#if defined(BOTAN_HAS_ARGON2)
24 #include <botan/argon2.h>
27#if defined(BOTAN_HAS_PBKDF_BCRYPT)
28 #include <botan/bcrypt_pbkdf.h>
34 const char* password,
size_t password_len,
35 const uint8_t salt[],
size_t salt_len,
36 const uint8_t ad[],
size_t ad_len,
37 const uint8_t key[],
size_t key_len)
const
41 if(ad_len == 0 && key_len == 0)
43 password, password_len,
49std::unique_ptr<PasswordHashFamily>
51 std::string_view provider)
55#if defined(BOTAN_HAS_PBKDF2)
58 if(provider.empty() || provider ==
"base")
61 return std::make_unique<PBKDF2_Family>(std::move(mac));
64 return std::make_unique<PBKDF2_Family>(std::move(mac));
71#if defined(BOTAN_HAS_SCRYPT)
74 return std::make_unique<Scrypt_Family>();
78#if defined(BOTAN_HAS_ARGON2)
81 return std::make_unique<Argon2_Family>(
static_cast<uint8_t
>(0));
85 return std::make_unique<Argon2_Family>(
static_cast<uint8_t
>(1));
89 return std::make_unique<Argon2_Family>(
static_cast<uint8_t
>(2));
93#if defined(BOTAN_HAS_PBKDF_BCRYPT)
96 return std::make_unique<Bcrypt_PBKDF_Family>();
100#if defined(BOTAN_HAS_PGP_S2K)
105 return std::make_unique<RFC4880_S2K_Family>(std::move(hash));
117std::unique_ptr<PasswordHashFamily>
119 std::string_view provider)
125 throw Lookup_Error(
"PasswordHashFamily", algo, provider);
130 return probe_providers_of<PasswordHashFamily>(algo_spec);
#define BOTAN_UNUSED(...)
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