AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
SecretMgr.cpp File Reference
#include "SecretMgr.h"
#include "AES.h"
#include "Argon2.h"
#include "Config.h"
#include "CryptoGenerics.h"
#include "DatabaseEnv.h"
#include "Errors.h"
#include "Log.h"
#include "QueryResult.h"
#include "SharedDefines.h"

Go to the source code of this file.

Classes

struct  SecretInfo
 

Macros

#define SECRET_FLAG_FOR(key, val, server)   server ## _ ## key = (val ## ull << (16*SERVER_PROCESS_ ## server))
 
#define SECRET_FLAG(key, val)   SECRET_FLAG_ ## key = val, SECRET_FLAG_FOR(key, val, AUTHSERVER), SECRET_FLAG_FOR(key, val, WORLDSERVER)
 

Enumerations

enum  SecretFlags : uint64
 

Functions

static Optional< BigNumberGetHexFromConfig (char const *configKey, int bits)
 

Variables

static constexpr SecretInfo secret_info [NUM_SECRETS]
 

Macro Definition Documentation

◆ SECRET_FLAG

#define SECRET_FLAG (   key,
  val 
)    SECRET_FLAG_ ## key = val, SECRET_FLAG_FOR(key, val, AUTHSERVER), SECRET_FLAG_FOR(key, val, WORLDSERVER)

◆ SECRET_FLAG_FOR

#define SECRET_FLAG_FOR (   key,
  val,
  server 
)    server ## _ ## key = (val ## ull << (16*SERVER_PROCESS_ ## server))

Enumeration Type Documentation

◆ SecretFlags

32{
33 SECRET_FLAG(DEFER_LOAD, 0x1)
34};
#define SECRET_FLAG(key, val)
Definition: SecretMgr.cpp:30

Function Documentation

◆ GetHexFromConfig()

static Optional< BigNumber > GetHexFromConfig ( char const *  configKey,
int  bits 
)
static
60{
61 ASSERT(bits > 0);
62 std::string str = sConfigMgr->GetOption<std::string>(configKey, "");
63 if (str.empty())
64 return {};
65
66 BigNumber secret;
67 if (!secret.SetHexStr(str.c_str()))
68 {
69 LOG_FATAL("server.loading", "Invalid value for '{}' - specify a hexadecimal integer of up to {} bits with no prefix.", configKey, bits);
70 ABORT();
71 }
72
73 BigNumber threshold(2);
74 threshold <<= bits;
75 if (!((BigNumber(0) <= secret) && (secret < threshold)))
76 {
77 LOG_ERROR("server.loading", "Value for '{}' is out of bounds (should be an integer of up to {} bits with no prefix). Truncated to {} bits.", configKey, bits, bits);
78 secret %= threshold;
79 }
80 ASSERT(((BigNumber(0) <= secret) && (secret < threshold)));
81
82 return secret;
83}
#define ABORT
Definition: Errors.h:76
#define ASSERT
Definition: Errors.h:68
#define LOG_FATAL(filterType__,...)
Definition: Log.h:153
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
#define sConfigMgr
Definition: Config.h:74
Definition: BigNumber.h:29
bool SetHexStr(char const *str)
Definition: BigNumber.cpp:65

References ABORT, ASSERT, LOG_ERROR, LOG_FATAL, sConfigMgr, and BigNumber::SetHexStr().

Referenced by SecretMgr::AttemptLoad().

Variable Documentation

◆ secret_info

constexpr SecretInfo secret_info[NUM_SECRETS]
staticconstexpr
Initial value:
=
{
{ "TOTPMasterSecret", "TOTPOldMasterSecret", 128, SERVER_PROCESS_AUTHSERVER, WORLDSERVER_DEFER_LOAD }
}
@ SERVER_PROCESS_AUTHSERVER
Definition: SharedDefines.h:3738

Referenced by SecretMgr::AttemptLoad(), SecretMgr::AttemptTransition(), and SecretMgr::Initialize().