10#include <botan/exceptn.h>
11#include <botan/pwdhash.h>
13#if defined(BOTAN_HAS_ARGON2_FMT)
14 #include <botan/argon2fmt.h>
21class RandomNumberGenerator;
28 Argon2(uint8_t family,
size_t M,
size_t t,
size_t p);
41 size_t salt_len)
const override;
52 size_t key_len)
const override;
56 size_t M()
const {
return m_M; }
58 size_t t()
const {
return m_t; }
60 size_t p()
const {
return m_p; }
77 static void blamka(uint64_t N[128], uint64_t
T[128]);
80#if defined(BOTAN_HAS_ARGON2_AVX2)
81 static void blamka_avx2(uint64_t N[128], uint64_t
T[128]);
84#if defined(BOTAN_HAS_ARGON2_SSSE3)
85 static void blamka_ssse3(uint64_t N[128], uint64_t
T[128]);
88 void argon2(uint8_t output[],
100 size_t m_M, m_t, m_p;
107 std::string
name()
const override;
109 std::unique_ptr<PasswordHash> tune(
size_t output_length,
110 std::chrono::milliseconds msec,
112 std::chrono::milliseconds tune_msec)
const override;
114 std::unique_ptr<PasswordHash> default_params()
const override;
116 std::unique_ptr<PasswordHash> from_iterations(
size_t iter)
const override;
118 std::unique_ptr<PasswordHash> from_params(
size_t M,
size_t t,
size_t p)
const override;
121 const uint8_t m_family;
144inline
void argon2(uint8_t output[],
146 const
char* password,
148 const uint8_t salt[],
158 auto pwdhash_fam = PasswordHashFamily::create_or_throw([y] {
170 auto pwdhash = pwdhash_fam->from_params(M, t, p);
171 pwdhash->derive_key(output, output_len, password, password_len, salt, salt_len, ad, ad_len, key, key_len);
bool supports_keyed_operation() const override
size_t iterations() const override
size_t total_memory_usage() const override
Argon2 & operator=(const Argon2 &)=default
size_t parallelism() const override
bool supports_associated_data() const override
Argon2(const Argon2 &other)=default
size_t memory_param() const override
virtual 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 =0
virtual std::string to_string() const =0
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
#define BOTAN_DEPRECATED(msg)
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 y, size_t p, size_t M, size_t t)