AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Acore::Crypto::Argon2 Struct Reference

#include "Argon2.h"

Static Public Member Functions

static Optional< std::string > Hash (std::string const &password, BigNumber const &salt, uint32 nIterations=DEFAULT_ITERATIONS, uint32 kibMemoryCost=DEFAULT_MEMORY_COST)
 
static bool Verify (std::string const &password, std::string const &hash)
 

Static Public Attributes

static constexpr uint32 HASH_LEN = 16
 
static constexpr uint32 ENCODED_HASH_LEN = 100
 
static constexpr uint32 DEFAULT_ITERATIONS = 10
 
static constexpr uint32 DEFAULT_MEMORY_COST = (1u << 17)
 
static constexpr uint32 PARALLELISM = 1
 

Detailed Description

Member Function Documentation

◆ Hash()

Optional< std::string > Acore::Crypto::Argon2::Hash ( std::string const &  password,
BigNumber const &  salt,
uint32  nIterations = DEFAULT_ITERATIONS,
uint32  kibMemoryCost = DEFAULT_MEMORY_COST 
)
static
22{
23 char buf[ENCODED_HASH_LEN];
24 std::vector<uint8> saltBytes = salt.ToByteVector();
25 int status = argon2id_hash_encoded(
26 nIterations,
27 kibMemoryCost,
29 password.c_str(), password.length(),
30 saltBytes.data(), saltBytes.size(),
32 );
33
34 if (status == ARGON2_OK)
35 return std::string(buf);
36
37 return {};
38}
static constexpr uint32 ENCODED_HASH_LEN
Definition: Argon2.h:29
static constexpr uint32 PARALLELISM
Definition: Argon2.h:32
static constexpr uint32 HASH_LEN
Definition: Argon2.h:28

References ENCODED_HASH_LEN, HASH_LEN, PARALLELISM, and BigNumber::ToByteVector().

Referenced by SecretMgr::AttemptTransition().

◆ Verify()

bool Acore::Crypto::Argon2::Verify ( std::string const &  password,
std::string const &  hash 
)
static
41{
42 int status = argon2id_verify(hash.c_str(), password.c_str(), password.length());
43 return (status == ARGON2_OK);
44}

Referenced by SecretMgr::AttemptLoad().

Member Data Documentation

◆ DEFAULT_ITERATIONS

constexpr uint32 Acore::Crypto::Argon2::DEFAULT_ITERATIONS = 10
staticconstexpr

◆ DEFAULT_MEMORY_COST

constexpr uint32 Acore::Crypto::Argon2::DEFAULT_MEMORY_COST = (1u << 17)
staticconstexpr

◆ ENCODED_HASH_LEN

constexpr uint32 Acore::Crypto::Argon2::ENCODED_HASH_LEN = 100
staticconstexpr

Referenced by Hash().

◆ HASH_LEN

constexpr uint32 Acore::Crypto::Argon2::HASH_LEN = 16
staticconstexpr

Referenced by Hash().

◆ PARALLELISM

constexpr uint32 Acore::Crypto::Argon2::PARALLELISM = 1
staticconstexpr

Referenced by Hash().