#include <pgp_s2k.h>
OpenPGP's S2K
Definition at line 19 of file pgp_s2k.h.
- Parameters
-
hash_in | the hash function to use |
Definition at line 25 of file pgp_s2k.h.
Botan::OpenPGP_S2K::~OpenPGP_S2K |
( |
| ) |
|
|
inline |
void Botan::PBKDF::clear |
( |
| ) |
|
|
inlinevirtualinherited |
PBKDF* Botan::OpenPGP_S2K::clone |
( |
| ) |
const |
|
inlinevirtual |
- Returns
- new instance of this same algorithm
Implements Botan::PBKDF.
Definition at line 34 of file pgp_s2k.h.
OpenPGP_S2K(HashFunction *hash_in)
virtual HashFunction * clone() const =0
OctetString Botan::OpenPGP_S2K::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 15 of file pgp_s2k.cpp.
References Botan::Algorithm::clear(), Botan::Buffered_Computation::final(), Botan::Buffered_Computation::output_length(), Botan::MemoryRegion< T >::size(), and Botan::Buffered_Computation::update().
20 SecureVector<byte> key(key_len), hash_buf;
22 size_t pass = 0, generated = 0,
23 total_size = passphrase.size() + salt_size;
24 size_t to_hash = std::max(iterations, total_size);
27 while(key_len > generated)
29 for(
size_t j = 0; j != pass; ++j)
32 size_t left = to_hash;
33 while(left >= total_size)
35 hash->
update(salt_buf, salt_size);
40 hash->
update(salt_buf, left);
43 hash->
update(salt_buf, salt_size);
45 hash->
update(reinterpret_cast<const byte*>(passphrase.data()), left);
48 hash_buf = hash->
final();
void update(const byte in[], size_t length)
virtual size_t output_length() const =0
std::string Botan::OpenPGP_S2K::name |
( |
| ) |
const |
|
inlinevirtual |
- Returns
- name of this algorithm
Implements Botan::Algorithm.
Definition at line 29 of file pgp_s2k.h.
31 return "OpenPGP-S2K(" + hash->
name() +
")";
virtual std::string name() const =0
The documentation for this class was generated from the following files: