Botan  1.11.15
Public Types | Public Member Functions | Static Public Member Functions
Botan::PKCS5_PBKDF2 Class Reference

#include <pbkdf2.h>

Inheritance diagram for Botan::PKCS5_PBKDF2:
Botan::PBKDF

List of all members.

Public Types

typedef SCAN_Name Spec

Public Member Functions

PBKDFclone () const override
OctetString derive_key (size_t out_len, const std::string &passphrase, const byte salt[], size_t salt_len, size_t iterations) const
template<typename Alloc >
OctetString derive_key (size_t out_len, const std::string &passphrase, const std::vector< byte, Alloc > &salt, size_t iterations) const
OctetString derive_key (size_t out_len, const std::string &passphrase, const byte salt[], size_t salt_len, std::chrono::milliseconds msec, size_t &iterations) const
template<typename Alloc >
OctetString derive_key (size_t out_len, const std::string &passphrase, const std::vector< byte, Alloc > &salt, std::chrono::milliseconds msec, size_t &iterations) const
std::string name () const override
size_t pbkdf (byte output_buf[], size_t output_len, const std::string &passphrase, const byte salt[], size_t salt_len, size_t iterations, std::chrono::milliseconds msec) const override
void pbkdf_iterations (byte out[], size_t out_len, const std::string &passphrase, const byte salt[], size_t salt_len, size_t iterations) const
secure_vector< bytepbkdf_iterations (size_t out_len, const std::string &passphrase, const byte salt[], size_t salt_len, size_t iterations) const
void pbkdf_timed (byte out[], size_t out_len, const std::string &passphrase, const byte salt[], size_t salt_len, std::chrono::milliseconds msec, size_t &iterations) const
secure_vector< bytepbkdf_timed (size_t out_len, const std::string &passphrase, const byte salt[], size_t salt_len, std::chrono::milliseconds msec, size_t &iterations) const
 PKCS5_PBKDF2 (MessageAuthenticationCode *mac_fn)

Static Public Member Functions

static PKCS5_PBKDF2make (const Spec &spec)

Detailed Description

PKCS #5 PBKDF2

Definition at line 28 of file pbkdf2.h.


Member Typedef Documentation

typedef SCAN_Name Botan::PBKDF::Spec [inherited]

Definition at line 28 of file pbkdf.h.


Constructor & Destructor Documentation

Create a PKCS #5 instance using the specified message auth code

Parameters:
mac_fnthe MAC object to use as PRF

Definition at line 51 of file pbkdf2.h.

Referenced by make().

: mac(mac_fn) {}

Member Function Documentation

PBKDF* Botan::PKCS5_PBKDF2::clone ( ) const [inline, override, virtual]
Returns:
new instance of this same algorithm

Implements Botan::PBKDF.

Definition at line 36 of file pbkdf2.h.

References mac.

         {
         return new PKCS5_PBKDF2(mac->clone());
         }
OctetString Botan::PBKDF::derive_key ( size_t  out_len,
const std::string &  passphrase,
const byte  salt[],
size_t  salt_len,
size_t  iterations 
) const [inline, inherited]

Derive a key from a passphrase

Parameters:
out_lenthe desired length of the key to produce
passphrasethe password to derive the key from
salta randomly chosen salt
salt_lenlength of salt in bytes
iterationsthe number of iterations to use (use 10K or more)

Definition at line 89 of file pbkdf.h.

Referenced by Botan::check_passhash9(), Botan::CryptoBox::decrypt(), Botan::CryptoBox::encrypt(), Botan::generate_passhash9(), Botan::pbes2_decrypt(), and Botan::pbes2_encrypt().

         {
         return pbkdf_iterations(out_len, passphrase, salt, salt_len, iterations);
         }
template<typename Alloc >
OctetString Botan::PBKDF::derive_key ( size_t  out_len,
const std::string &  passphrase,
const std::vector< byte, Alloc > &  salt,
size_t  iterations 
) const [inline, inherited]

Derive a key from a passphrase

Parameters:
out_lenthe desired length of the key to produce
passphrasethe password to derive the key from
salta randomly chosen salt
iterationsthe number of iterations to use (use 10K or more)

Definition at line 105 of file pbkdf.h.

         {
         return pbkdf_iterations(out_len, passphrase, &salt[0], salt.size(), iterations);
         }
OctetString Botan::PBKDF::derive_key ( size_t  out_len,
const std::string &  passphrase,
const byte  salt[],
size_t  salt_len,
std::chrono::milliseconds  msec,
size_t &  iterations 
) const [inline, inherited]

Derive a key from a passphrase

Parameters:
out_lenthe desired length of the key to produce
passphrasethe password to derive the key from
salta randomly chosen salt
salt_lenlength of salt in bytes
msecis how long to run the PBKDF
iterationsis set to the number of iterations used

Definition at line 122 of file pbkdf.h.

         {
         return pbkdf_timed(out_len, passphrase, salt, salt_len, msec, iterations);
         }
template<typename Alloc >
OctetString Botan::PBKDF::derive_key ( size_t  out_len,
const std::string &  passphrase,
const std::vector< byte, Alloc > &  salt,
std::chrono::milliseconds  msec,
size_t &  iterations 
) const [inline, inherited]

Derive a key from a passphrase using a certain amount of time

Parameters:
out_lenthe desired length of the key to produce
passphrasethe password to derive the key from
salta randomly chosen salt
msecis how long to run the PBKDF
iterationsis set to the number of iterations used

Definition at line 140 of file pbkdf.h.

         {
         return pbkdf_timed(out_len, passphrase, &salt[0], salt.size(), msec, iterations);
         }
PKCS5_PBKDF2 * Botan::PKCS5_PBKDF2::make ( const Spec spec) [static]

Definition at line 18 of file pbkdf2.cpp.

References Botan::SCAN_Name::arg(), and PKCS5_PBKDF2().

   {
   if(auto mac = make_a<MessageAuthenticationCode>(spec.arg(0)))
      return new PKCS5_PBKDF2(mac);

   if(auto mac = make_a<MessageAuthenticationCode>("HMAC(" + spec.arg(0) + ")"))
      return new PKCS5_PBKDF2(mac);

   return nullptr;
   }
std::string Botan::PKCS5_PBKDF2::name ( ) const [inline, override, virtual]

Implements Botan::PBKDF.

Definition at line 31 of file pbkdf2.h.

References mac.

         {
         return "PBKDF2(" + mac->name() + ")";
         }
size_t Botan::PKCS5_PBKDF2::pbkdf ( byte  out[],
size_t  out_len,
const std::string &  passphrase,
const byte  salt[],
size_t  salt_len,
size_t  iterations,
std::chrono::milliseconds  msec 
) const [override, virtual]

Derive a key from a passphrase for a number of iterations specified by either iterations or if iterations == 0 then running until seconds time has elapsed.

Parameters:
out_lenthe desired length of the key to produce
passphrasethe password to derive the key from
salta randomly chosen salt
salt_lenlength of salt in bytes
iterationsthe number of iterations to use (use 10K or more)
msecif iterations is zero, then instead the PBKDF is run until msec milliseconds has passed.
Returns:
the number of iterations performed

Implements Botan::PBKDF.

Definition at line 123 of file pbkdf2.cpp.

References Botan::pbkdf2().

   {
   return pbkdf2(*mac.get(), key, key_len, passphrase, salt, salt_len, iterations, msec);
   }
void Botan::PBKDF::pbkdf_iterations ( byte  out[],
size_t  out_len,
const std::string &  passphrase,
const byte  salt[],
size_t  salt_len,
size_t  iterations 
) const [inherited]

Definition at line 22 of file pbkdf.cpp.

References BOTAN_ASSERT_EQUAL, Botan::PBKDF::name(), and Botan::PBKDF::pbkdf().

Referenced by Botan::PBKDF::pbkdf_iterations().

   {
   if(iterations == 0)
      throw std::invalid_argument(name() + ": Invalid iteration count");

   const size_t iterations_run = pbkdf(out, out_len, passphrase,
                                       salt, salt_len, iterations,
                                       std::chrono::milliseconds(0));
   BOTAN_ASSERT_EQUAL(iterations, iterations_run, "Expected PBKDF iterations");
   }
secure_vector< byte > Botan::PBKDF::pbkdf_iterations ( size_t  out_len,
const std::string &  passphrase,
const byte  salt[],
size_t  salt_len,
size_t  iterations 
) const [inherited]

Definition at line 36 of file pbkdf.cpp.

References Botan::PBKDF::pbkdf_iterations().

   {
   secure_vector<byte> out(out_len);
   pbkdf_iterations(&out[0], out_len, passphrase, salt, salt_len, iterations);
   return out;
   }
void Botan::PBKDF::pbkdf_timed ( byte  out[],
size_t  out_len,
const std::string &  passphrase,
const byte  salt[],
size_t  salt_len,
std::chrono::milliseconds  msec,
size_t &  iterations 
) const [inherited]

Definition at line 13 of file pbkdf.cpp.

References Botan::PBKDF::pbkdf().

Referenced by Botan::PBKDF::pbkdf_timed().

   {
   iterations = pbkdf(out, out_len, passphrase, salt, salt_len, 0, msec);
   }
secure_vector< byte > Botan::PBKDF::pbkdf_timed ( size_t  out_len,
const std::string &  passphrase,
const byte  salt[],
size_t  salt_len,
std::chrono::milliseconds  msec,
size_t &  iterations 
) const [inherited]

Definition at line 46 of file pbkdf.cpp.

References Botan::PBKDF::pbkdf_timed().

   {
   secure_vector<byte> out(out_len);
   pbkdf_timed(&out[0], out_len, passphrase, salt, salt_len, msec, iterations);
   return out;
   }

The documentation for this class was generated from the following files: