#include <pwdhash.h>
Definition at line 79 of file pwdhash.h.
virtual Botan::PasswordHashFamily::~PasswordHashFamily |
( |
| ) |
|
|
virtualdefault |
std::unique_ptr< PasswordHashFamily > Botan::PasswordHashFamily::create |
( |
const std::string & |
algo_spec, |
|
|
const std::string & |
provider = "" |
|
) |
| |
|
static |
Create an instance based on a name If provider is empty then best available is chosen.
- Parameters
-
algo_spec | algorithm name |
provider | provider implementation to choose |
- Returns
- a null pointer if the algo/provider combination cannot be found
Definition at line 33 of file pwdhash.cpp.
References Botan::SCAN_Name::algo_name(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_count(), BOTAN_UNUSED, Botan::HashFunction::create(), Botan::MessageAuthenticationCode::create(), and hash.
Referenced by botan_pwdhash(), botan_pwdhash_timed(), and create_or_throw().
36 const SCAN_Name req(algo_spec);
38 #if defined(BOTAN_HAS_PBKDF2)
39 if(req.algo_name() ==
"PBKDF2")
43 if(provider.empty() || provider ==
"base")
46 return std::unique_ptr<PasswordHashFamily>(
new PBKDF2_Family(mac.release()));
49 return std::unique_ptr<PasswordHashFamily>(
new PBKDF2_Family(mac.release()));
56 #if defined(BOTAN_HAS_SCRYPT)
57 if(req.algo_name() ==
"Scrypt")
59 return std::unique_ptr<PasswordHashFamily>(
new Scrypt_Family);
63 #if defined(BOTAN_HAS_ARGON2)
64 if(req.algo_name() ==
"Argon2d")
66 return std::unique_ptr<PasswordHashFamily>(
new Argon2_Family(0));
68 else if(req.algo_name() ==
"Argon2i")
70 return std::unique_ptr<PasswordHashFamily>(
new Argon2_Family(1));
72 else if(req.algo_name() ==
"Argon2id")
74 return std::unique_ptr<PasswordHashFamily>(
new Argon2_Family(2));
78 #if defined(BOTAN_HAS_PBKDF_BCRYPT)
79 if(req.algo_name() ==
"Bcrypt-PBKDF")
81 return std::unique_ptr<PasswordHashFamily>(
new Bcrypt_PBKDF_Family);
85 #if defined(BOTAN_HAS_PGP_S2K)
86 if(req.algo_name() ==
"OpenPGP-S2K" && req.arg_count() == 1)
90 return std::unique_ptr<PasswordHashFamily>(
new RFC4880_S2K_Family(
hash.release()));
static std::unique_ptr< MessageAuthenticationCode > create(const std::string &algo_spec, const std::string &provider="")
static std::unique_ptr< HashFunction > create(const std::string &algo_spec, const std::string &provider="")
#define BOTAN_UNUSED(...)
std::unique_ptr< PasswordHashFamily > Botan::PasswordHashFamily::create_or_throw |
( |
const std::string & |
algo_spec, |
|
|
const std::string & |
provider = "" |
|
) |
| |
|
static |
Create an instance based on a name, or throw if the algo/provider combination cannot be found. If provider is empty then best available is chosen.
Definition at line 103 of file pwdhash.cpp.
References create().
110 throw Lookup_Error(
"PasswordHashFamily", algo, provider);
static std::unique_ptr< PasswordHashFamily > create(const std::string &algo_spec, const std::string &provider="")
virtual std::unique_ptr<PasswordHash> Botan::PasswordHashFamily::default_params |
( |
| ) |
const |
|
pure virtual |
virtual std::unique_ptr<PasswordHash> Botan::PasswordHashFamily::from_iterations |
( |
size_t |
iterations | ) |
const |
|
pure virtual |
virtual std::unique_ptr<PasswordHash> Botan::PasswordHashFamily::from_params |
( |
size_t |
i1, |
|
|
size_t |
i2 = 0 , |
|
|
size_t |
i3 = 0 |
|
) |
| const |
|
pure virtual |
Create a password hash using some scheme specific format. Eg PBKDF2 and PGP-S2K set iterations in i1 Scrypt uses N,r,p in i{1-3} Bcrypt-PBKDF just has iterations Argon2{i,d,id} would use iterations, memory, parallelism for i{1-3}, and Argon2 type is part of the family.
Values not needed should be set to 0
Implemented in Botan::RFC4880_S2K_Family, Botan::PBKDF2_Family, Botan::Argon2_Family, Botan::Scrypt_Family, and Botan::Bcrypt_PBKDF_Family.
virtual std::string Botan::PasswordHashFamily::name |
( |
| ) |
const |
|
pure virtual |
std::vector< std::string > Botan::PasswordHashFamily::providers |
( |
const std::string & |
algo_spec | ) |
|
|
static |
- Returns
- list of available providers for this algorithm, empty if not available
Definition at line 113 of file pwdhash.cpp.
115 return probe_providers_of<PasswordHashFamily>(algo_spec, {
"base",
"openssl" });
virtual std::unique_ptr<PasswordHash> Botan::PasswordHashFamily::tune |
( |
size_t |
output_length, |
|
|
std::chrono::milliseconds |
msec, |
|
|
size_t |
max_memory_usage_mb = 0 |
|
) |
| const |
|
pure virtual |
Return a new parameter set tuned for this machine
- Parameters
-
output_length | how long the output length will be |
msec | the desired execution time in milliseconds |
max_memory_usage_mb | some password hash functions can use a tunable amount of memory, in this case max_memory_usage limits the amount of RAM the returned parameters will require, in mebibytes (2**20 bytes). It may require some small amount above the request. Set to zero to place no limit at all. |
Implemented in Botan::RFC4880_S2K_Family, Botan::PBKDF2_Family, Botan::Argon2_Family, Botan::Scrypt_Family, and Botan::Bcrypt_PBKDF_Family.
The documentation for this class was generated from the following files: