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

Classes

class  AES
 
class  ARC4
 
struct  Argon2
 
struct  Constants
 
class  SRP6
 
struct  TOTP
 

Typedefs

using MD5 = Acore::Impl::GenericHash< EVP_md5, Constants::MD5_DIGEST_LENGTH_BYTES >
 
using SHA1 = Acore::Impl::GenericHash< EVP_sha1, Constants::SHA1_DIGEST_LENGTH_BYTES >
 
using SHA256 = Acore::Impl::GenericHash< EVP_sha256, Constants::SHA256_DIGEST_LENGTH_BYTES >
 
using HMAC_SHA1 = Acore::Impl::GenericHMAC< EVP_sha1, Constants::SHA1_DIGEST_LENGTH_BYTES >
 
using HMAC_SHA256 = Acore::Impl::GenericHMAC< EVP_sha256, Constants::SHA256_DIGEST_LENGTH_BYTES >
 

Functions

template<typename Cipher >
void AEEncryptWithRandomIV (std::vector< uint8 > &data, typename Cipher::Key const &key)
 
template<typename Cipher >
void AEEncryptWithRandomIV (std::vector< uint8 > &data, BigNumber const &key)
 
template<typename Cipher >
bool AEDecrypt (std::vector< uint8 > &data, typename Cipher::Key const &key)
 
template<typename Cipher >
bool AEDecrypt (std::vector< uint8 > &data, BigNumber const &key)
 
AC_COMMON_API void GetRandomBytes (uint8 *buf, size_t len)
 
template<typename Container >
void GetRandomBytes (Container &c)
 
template<size_t S>
std::array< uint8, S > GetRandomBytes ()
 

Typedef Documentation

◆ HMAC_SHA1

◆ HMAC_SHA256

◆ MD5

◆ SHA1

◆ SHA256

Function Documentation

◆ AEDecrypt() [1/2]

template<typename Cipher >
bool Acore::Crypto::AEDecrypt ( std::vector< uint8 > &  data,
BigNumber const &  key 
)
107 {
108 return AEDecrypt<Cipher>(data, key.ToByteArray<Cipher::KEY_SIZE_BYTES>());
109 }

References BigNumber::ToByteArray().

◆ AEDecrypt() [2/2]

template<typename Cipher >
bool Acore::Crypto::AEDecrypt ( std::vector< uint8 > &  data,
typename Cipher::Key const &  key 
)
89 {
90 using IV = typename Cipher::IV;
91 using Tag = typename Cipher::Tag;
92
93 // extract trailing IV and tag
94 IV iv;
95 Tag tag;
98
99 // decrypt data
100 Cipher cipher(false);
101 cipher.Init(key);
102 return cipher.Process(iv, data.data(), data.size(), tag);
103 }
static void SplitFromBack(std::vector< uint8 > &data, Container &tail)
Definition: CryptoGenerics.h:47

References Acore::Impl::CryptoGenericsImpl::SplitFromBack().

◆ AEEncryptWithRandomIV() [1/2]

template<typename Cipher >
void Acore::Crypto::AEEncryptWithRandomIV ( std::vector< uint8 > &  data,
BigNumber const &  key 
)
83 {
84 AEEncryptWithRandomIV<Cipher>(data, key.ToByteArray<Cipher::KEY_SIZE_BYTES>());
85 }

References BigNumber::ToByteArray().

◆ AEEncryptWithRandomIV() [2/2]

template<typename Cipher >
void Acore::Crypto::AEEncryptWithRandomIV ( std::vector< uint8 > &  data,
typename Cipher::Key const &  key 
)
63 {
64 using IV = typename Cipher::IV;
65 using Tag = typename Cipher::Tag;
66 // select random IV
67 IV iv = Acore::Impl::CryptoGenericsImpl::GenerateRandomIV<Cipher>();
68 Tag tag;
69
70 // encrypt data
71 Cipher cipher(true);
72 cipher.Init(key);
73 bool success = cipher.Process(iv, data.data(), data.size(), tag);
74 ASSERT(success);
75
76 // append trailing IV and tag
79 }
#define ASSERT
Definition: Errors.h:68
static void AppendToBack(std::vector< uint8 > &data, Container const &tail)
Definition: CryptoGenerics.h:41

References Acore::Impl::CryptoGenericsImpl::AppendToBack(), and ASSERT.

◆ GetRandomBytes() [1/3]

template<size_t S>
std::array< uint8, S > Acore::Crypto::GetRandomBytes ( )
36 {
37 std::array<uint8, S> arr;
38 GetRandomBytes(arr);
39 return arr;
40 }
AC_COMMON_API void GetRandomBytes(uint8 *buf, size_t len)
Definition: CryptoRandom.cpp:22

References GetRandomBytes().

Referenced by Acore::Impl::CryptoGenericsImpl::GenerateRandomIV(), GetRandomBytes(), account_commandscript::HandleAccount2FASetupCommand(), Acore::Crypto::SRP6::MakeRegistrationData(), AuthSession::ReconnectChallengeCallback(), and WorldSocket::WorldSocket().

◆ GetRandomBytes() [2/3]

template<typename Container >
void Acore::Crypto::GetRandomBytes ( Container c)
30 {
31 GetRandomBytes(std::data(c), std::size(c));
32 }

References GetRandomBytes().

◆ GetRandomBytes() [3/3]

void Acore::Crypto::GetRandomBytes ( uint8 buf,
size_t  len 
)
23{
24 int result = RAND_bytes(buf, len);
25 ASSERT(result == 1, "Not enough randomness in OpenSSL's entropy pool. What in the world are you running on?");
26}

References ASSERT.