Botan  2.11.0
Crypto and TLS for C++11
Public Member Functions | List of all members
Botan::Argon2 Class Referencefinal

#include <argon2.h>

Inheritance diagram for Botan::Argon2:
Botan::PasswordHash

Public Member Functions

 Argon2 (uint8_t family, size_t M, size_t t, size_t p)
 
 Argon2 (const Argon2 &other)=default
 
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
 
size_t M () const
 
size_t memory_param () const override
 
Argon2operator= (const Argon2 &)=default
 
size_t p () const
 
size_t parallelism () const override
 
size_t t () const
 
std::string to_string () const override
 
size_t total_memory_usage () const override
 

Detailed Description

Argon2 key derivation function

Definition at line 19 of file argon2.h.

Constructor & Destructor Documentation

◆ Argon2() [1/2]

Botan::Argon2::Argon2 ( uint8_t  family,
size_t  M,
size_t  t,
size_t  p 
)

Definition at line 14 of file argon2pwhash.cpp.

14  :
15  m_family(family),
16  m_M(M),
17  m_t(t),
18  m_p(p)
19  {}
size_t M() const
Definition: argon2.h:36
size_t p() const
Definition: argon2.h:38
size_t t() const
Definition: argon2.h:37

◆ Argon2() [2/2]

Botan::Argon2::Argon2 ( const Argon2 other)
default

Member Function Documentation

◆ derive_key()

void Botan::Argon2::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
overridevirtual

Derive a new key under the current Argon2 parameter set

Implements Botan::PasswordHash.

Definition at line 21 of file argon2pwhash.cpp.

References Botan::argon2(), and salt_len.

24  {
25  argon2(output, output_len,
26  password, password_len,
27  salt, salt_len,
28  nullptr, 0,
29  nullptr, 0,
30  m_family, m_p, m_M, m_t);
31  }
size_t salt_len
Definition: x509_obj.cpp:26
void argon2(uint8_t output[], size_t output_len, const char *password, size_t password_len, const uint8_t salt[], size_t salt_len, const uint8_t key[], size_t key_len, const uint8_t ad[], size_t ad_len, uint8_t mode, size_t threads, size_t M, size_t t)
Definition: argon2.cpp:381

◆ iterations()

size_t Botan::Argon2::iterations ( ) const
inlineoverridevirtual

Most password hashes have some notion of iterations.

Implements Botan::PasswordHash.

Definition at line 40 of file argon2.h.

40 { return t(); }
size_t t() const
Definition: argon2.h:37

◆ M()

size_t Botan::Argon2::M ( ) const
inline

Definition at line 36 of file argon2.h.

36 { return m_M; }

◆ memory_param()

size_t Botan::Argon2::memory_param ( ) const
inlineoverridevirtual

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

Reimplemented from Botan::PasswordHash.

Definition at line 44 of file argon2.h.

44 { return M(); }
size_t M() const
Definition: argon2.h:36

◆ operator=()

Argon2& Botan::Argon2::operator= ( const Argon2 )
default

◆ p()

size_t Botan::Argon2::p ( ) const
inline

Definition at line 38 of file argon2.h.

38 { return m_p; }

◆ parallelism()

size_t Botan::Argon2::parallelism ( ) const
inlineoverridevirtual

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 from Botan::PasswordHash.

Definition at line 42 of file argon2.h.

42 { return p(); }
size_t p() const
Definition: argon2.h:38

◆ t()

size_t Botan::Argon2::t ( ) const
inline

Definition at line 37 of file argon2.h.

37 { return m_t; }

◆ to_string()

std::string Botan::Argon2::to_string ( ) const
overridevirtual

Implements Botan::PasswordHash.

Definition at line 52 of file argon2pwhash.cpp.

References Botan::ASN1::to_string().

53  {
54  return argon2_family_name(m_family) + "(" +
55  std::to_string(m_M) + "," +
56  std::to_string(m_t) + "," +
57  std::to_string(m_p) + ")";
58  }
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:213

◆ total_memory_usage()

size_t Botan::Argon2::total_memory_usage ( ) const
inlineoverridevirtual

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 from Botan::PasswordHash.

Definition at line 46 of file argon2.h.

46 { return M() * 1024; }
size_t M() const
Definition: argon2.h:36

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