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 "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

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

Function Documentation

◆ GetHexFromConfig()

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

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().