PKCS #5 PBKDF2
Definition at line 19 of file pbkdf2.h.
OctetString Botan::PKCS5_PBKDF2::derive_key |
( |
size_t |
output_len, |
|
|
const std::string & |
passphrase, |
|
|
const byte |
salt[], |
|
|
size_t |
salt_len, |
|
|
size_t |
iterations |
|
) |
| const |
|
virtual |
Derive a key from a passphrase
- Parameters
-
output_len | the desired length of the key to produce |
passphrase | the password to derive the key from |
salt | a randomly chosen salt |
salt_len | length of salt in bytes |
iterations | the number of iterations to use (use 10K or more) |
Implements Botan::PBKDF.
Definition at line 17 of file pbkdf2.cpp.
References Botan::Buffered_Computation::final(), name(), Botan::Buffered_Computation::output_length(), Botan::SymmetricAlgorithm::set_key(), Botan::to_string(), Botan::Buffered_Computation::update(), Botan::Buffered_Computation::update_be(), and Botan::xor_buf().
Referenced by Botan::check_passhash9(), Botan::CryptoBox::decrypt(), Botan::CryptoBox::encrypt(), and Botan::generate_passhash9().
27 mac->
set_key(reinterpret_cast<const byte*>(passphrase.data()),
30 catch(Invalid_Key_Length)
32 throw Exception(
name() +
" cannot accept passphrases of length " +
36 SecureVector<byte> key(key_len);
45 size_t T_size = std::min<size_t>(mac->
output_length(), key_len);
47 mac->
update(salt, salt_size);
53 for(
size_t j = 1; j != iterations; ++j)
std::invalid_argument Invalid_Argument
void set_key(const SymmetricKey &key)
void update(const byte in[], size_t length)
std::runtime_error Exception
std::string to_string(u64bit n, size_t min_len)
void update_be(const T in)
void xor_buf(byte out[], const byte in[], size_t length)
virtual size_t output_length() const =0