Botan 2.19.5 Crypto and TLS for C&

Public Member Functions | List of all members
Botan::PBKDF2 Class Referencefinal

`#include <pbkdf2.h>`

Inheritance diagram for Botan::PBKDF2:

## Public Member Functions
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 override
size_t | iterations () const override
virtual size_t | memory_param () const
virtual size_t | parallelism () const
| PBKDF2 (const MessageAuthenticationCode &prf, size_t iter)
| PBKDF2 (const MessageAuthenticationCode &prf, size_t olen, std::chrono::milliseconds msec)
std::string | to_string () const override
virtual size_t | total_memory_usage () const

## Detailed Description

PBKDF2

Definition at line 39 of file pbkdf2.h.

## Constructor & Destructor Documentation

## ◆ PBKDF2() [1/2]

Botan::PBKDF2::PBKDF2 | ( | const MessageAuthenticationCode & | prf,
|  | size_t | iter
| ) |  |
| inline

Definition at line 42 of file pbkdf2.h.

42 :
43 m_prf(prf.clone()),
44 m_iterations(iter)
45 {}

## ◆ PBKDF2() [2/2]

Botan::PBKDF2::PBKDF2 | ( | const MessageAuthenticationCode & | prf,
|  | size_t | olen,
|  | std::chrono::milliseconds | msec
| ) |  |

Definition at line 185 of file pbkdf2.cpp.

185 :
186 m_prf(prf.clone()),
187 m_iterations(tune_pbkdf2(*m_prf, olen, static_cast<uint32_t>(msec.count())))
188 {}

## Member Function Documentation

## ◆ derive_key()

void Botan::PBKDF2::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
| override virtual

Derive a key from a password

Parameters

  out | buffer to store the derived key, must be of out_len bytes
  out_len | the desired length of the key to produce
  password | the password to derive the key from
  password_len | the length of password in bytes
  salt | a randomly chosen salt
  salt_len | length of salt in bytes

This function is const, but is not thread safe. Different threads should either use unique objects, or serialize all access.

Implements Botan::PasswordHash.

Definition at line 195 of file pbkdf2.cpp.

198 {
199 pbkdf2_set_key(*m_prf, password, password_len);
200 pbkdf2(*m_prf, out, out_len, salt, salt_len, m_iterations);
201 }
Botan::pbkdf2
size_t pbkdf2(MessageAuthenticationCode &prf, uint8_t out[], size_t out_len, const std::string &password, const uint8_t salt[], size_t salt_len, size_t iterations, std::chrono::milliseconds msec)
Definition: pbkdf2.cpp:35
salt_len
size_t salt_len
Definition: x509_obj.cpp:25

References Botan::pbkdf2(), and salt_len.

## ◆ iterations()

size_t Botan::PBKDF2::iterations | ( |  | ) | const
| inline override virtual

Most password hashes have some notion of iterations.

Implements Botan::PasswordHash.

Definition at line 49 of file pbkdf2.h.

49{ return m_iterations; }

Referenced by Botan::PKCS5_PBKDF2::pbkdf(), and Botan::pbkdf2().

## ◆ memory_param()

virtual size_t Botan::PasswordHash::memory_param | ( |  | ) | const
| inline virtual inherited

Some password hashing algorithms have a parameter which controls how much memory is used. If not supported by some algorithm, returns 0.

Reimplemented in Botan::Argon2, Botan::Bcrypt_PBKDF, and Botan::Scrypt.

Definition at line 40 of file pwdhash.h.

40{ return 0; }

## ◆ parallelism()

virtual size_t Botan::PasswordHash::parallelism | ( |  | ) | const
| inline virtual inherited

Some password hashing algorithms have a parallelism parameter. If the algorithm does not support this notion, then the function returns zero. This allows distinguishing between a password hash which just does not support parallel operation, vs one that does support parallel operation but which has been configured to use a single lane.

Reimplemented in Botan::Argon2, Botan::Bcrypt_PBKDF, and Botan::Scrypt.

Definition at line 50 of file pwdhash.h.

50{ return 0; }

## ◆ to_string()

std::string Botan::PBKDF2::to_string | ( |  | ) | const
| override virtual

Implements Botan::PasswordHash.

Definition at line 190 of file pbkdf2.cpp.

191 {
192 return "PBKDF2(" + m_prf->name() + "," + std::to_string(m_iterations) + ")";
193 }
Botan::ASN1::to_string
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:213

References Botan::ASN1::to_string().

## ◆ total_memory_usage()

virtual size_t Botan::PasswordHash::total_memory_usage | ( |  | ) | const
| inline virtual inherited

Returns an estimate of the total memory usage required to perform this key derivation.

If this algorithm uses a small and constant amount of memory, with no effort made towards being memory hard, this function returns 0.

Reimplemented in Botan::Argon2, Botan::Bcrypt_PBKDF, and Botan::Scrypt.

Definition at line 59 of file pwdhash.h.

59{ return 0; }

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

- src/lib/pbkdf/pbkdf2/pbkdf2.h
- src/lib/pbkdf/pbkdf2/pbkdf2.cpp