From 405f823f68621352e48810c33f1f9dbd36904ff8 Mon Sep 17 00:00:00 2001 From: StormBytePP Date: Sun, 23 Aug 2015 23:20:09 +0200 Subject: Core/BuildSystem: Merged crypto and gitrevision into common, cleaned include directory lists (to mimic 6.x buildsystem) --- src/CMakeLists.txt | 1 - src/common/CMakeLists.txt | 64 +++---- src/common/Collision/Management/MMapManager.cpp | 2 +- src/common/Collision/Maps/MapDefines.h | 36 ++++ src/common/Cryptography/ARC4.cpp | 51 ++++++ src/common/Cryptography/ARC4.h | 37 ++++ .../Cryptography/Authentication/AuthCrypt.cpp | 75 ++++++++ src/common/Cryptography/Authentication/AuthCrypt.h | 42 +++++ src/common/Cryptography/BigNumber.cpp | 201 +++++++++++++++++++++ src/common/Cryptography/BigNumber.h | 100 ++++++++++ src/common/Cryptography/HMACSHA1.cpp | 57 ++++++ src/common/Cryptography/HMACSHA1.h | 47 +++++ src/common/Cryptography/OpenSSLCrypto.cpp | 59 ++++++ src/common/Cryptography/OpenSSLCrypto.h | 33 ++++ src/common/Cryptography/SHA1.cpp | 69 +++++++ src/common/Cryptography/SHA1.h | 50 +++++ src/common/Cryptography/WardenKeyGeneration.h | 81 +++++++++ src/common/GitRevision.cpp | 78 ++++++++ src/common/GitRevision.h | 40 ++++ src/server/CMakeLists.txt | 1 - src/server/authserver/CMakeLists.txt | 30 ++- src/server/database/CMakeLists.txt | 31 ++-- src/server/game/CMakeLists.txt | 71 +++----- src/server/game/Miscellaneous/SharedDefines.h | 29 --- src/server/game/Movement/PathGenerator.h | 2 +- src/server/scripts/CMakeLists.txt | 47 ++--- src/server/shared/CMakeLists.txt | 25 +-- src/server/shared/Cryptography/ARC4.cpp | 51 ------ src/server/shared/Cryptography/ARC4.h | 37 ---- .../Cryptography/Authentication/AuthCrypt.cpp | 75 -------- .../shared/Cryptography/Authentication/AuthCrypt.h | 42 ----- src/server/shared/Cryptography/BigNumber.cpp | 201 --------------------- src/server/shared/Cryptography/BigNumber.h | 100 ---------- src/server/shared/Cryptography/HMACSHA1.cpp | 57 ------ src/server/shared/Cryptography/HMACSHA1.h | 47 ----- src/server/shared/Cryptography/OpenSSLCrypto.cpp | 59 ------ src/server/shared/Cryptography/OpenSSLCrypto.h | 33 ---- src/server/shared/Cryptography/SHA1.cpp | 69 ------- src/server/shared/Cryptography/SHA1.h | 50 ----- .../shared/Cryptography/WardenKeyGeneration.h | 81 --------- src/server/shared/GitRevision.cpp | 68 ------- src/server/shared/GitRevision.h | 38 ---- src/server/worldserver/CMakeLists.txt | 93 +++------- 43 files changed, 1181 insertions(+), 1279 deletions(-) create mode 100644 src/common/Collision/Maps/MapDefines.h create mode 100644 src/common/Cryptography/ARC4.cpp create mode 100644 src/common/Cryptography/ARC4.h create mode 100644 src/common/Cryptography/Authentication/AuthCrypt.cpp create mode 100644 src/common/Cryptography/Authentication/AuthCrypt.h create mode 100644 src/common/Cryptography/BigNumber.cpp create mode 100644 src/common/Cryptography/BigNumber.h create mode 100644 src/common/Cryptography/HMACSHA1.cpp create mode 100644 src/common/Cryptography/HMACSHA1.h create mode 100644 src/common/Cryptography/OpenSSLCrypto.cpp create mode 100644 src/common/Cryptography/OpenSSLCrypto.h create mode 100644 src/common/Cryptography/SHA1.cpp create mode 100644 src/common/Cryptography/SHA1.h create mode 100644 src/common/Cryptography/WardenKeyGeneration.h create mode 100644 src/common/GitRevision.cpp create mode 100644 src/common/GitRevision.h delete mode 100644 src/server/shared/Cryptography/ARC4.cpp delete mode 100644 src/server/shared/Cryptography/ARC4.h delete mode 100644 src/server/shared/Cryptography/Authentication/AuthCrypt.cpp delete mode 100644 src/server/shared/Cryptography/Authentication/AuthCrypt.h delete mode 100644 src/server/shared/Cryptography/BigNumber.cpp delete mode 100644 src/server/shared/Cryptography/BigNumber.h delete mode 100644 src/server/shared/Cryptography/HMACSHA1.cpp delete mode 100644 src/server/shared/Cryptography/HMACSHA1.h delete mode 100644 src/server/shared/Cryptography/OpenSSLCrypto.cpp delete mode 100644 src/server/shared/Cryptography/OpenSSLCrypto.h delete mode 100644 src/server/shared/Cryptography/SHA1.cpp delete mode 100644 src/server/shared/Cryptography/SHA1.h delete mode 100644 src/server/shared/Cryptography/WardenKeyGeneration.h delete mode 100644 src/server/shared/GitRevision.cpp delete mode 100644 src/server/shared/GitRevision.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a2c50828d37..914ad31ad06 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,4 +18,3 @@ endif(SERVERS) if(TOOLS) add_subdirectory(tools) endif(TOOLS) - diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 010a4f9ac43..2339399e022 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -18,6 +18,9 @@ file(GLOB_RECURSE sources_Threading Threading/*.cpp Threading/*.h) file(GLOB_RECURSE sources_Utilities Utilities/*.cpp Utilities/*.h) file(GLOB_RECURSE sources_Configuration Configuration/*.cpp Configuration/*.h) file(GLOB_RECURSE sources_Logging Logging/*.cpp Logging/*.h) +if (SERVERS) + file(GLOB_RECURSE sources_Cryptography Cryptography/*.cpp Cryptography/*.h) +endif (SERVERS) # Manually set sources for Debugging directory as we don't want to include WheatyExceptionReport in common project # It needs to be included both in authserver and worldserver for the static global variable to be properly initialized @@ -28,7 +31,7 @@ file(GLOB sources_localdir *.cpp *.h) if (USE_COREPCH) set(common_STAT_PCH_HDR PrecompiledHeaders/commonPCH.h) set(common_STAT_PCH_SRC PrecompiledHeaders/commonPCH.cpp) -endif () +endif (USE_COREPCH) set(common_STAT_SRCS ${common_STAT_SRCS} @@ -39,58 +42,37 @@ set(common_STAT_SRCS ${sources_Debugging} ${sources_Configuration} ${sources_Logging} + ${sources_Cryptography} ${sources_localdir} ) +# Do NOT add any extra include directory here, as we don't want the common +# library to depend on anything else than TC deps, and itself. +# This way we ensure that if either a PR does that without modifying this file, +# a compile error will be generated, either this file will be modified so it +# is detected more easily. +# While it is OK to include files from other libs as long as they don't require +# linkage (enums, defines...) it is discouraged to do so unless necessary, as it will pullute +# include_directories leading to further unnoticed dependency aditions +# Linker Depencency requirements: none include_directories( ${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/dep/utf8cpp - ${CMAKE_SOURCE_DIR}/dep/SFMT - ${CMAKE_SOURCE_DIR}/dep/g3dlite/include - ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour - ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour/Include - ${CMAKE_SOURCE_DIR}/dep/cppformat - ${CMAKE_SOURCE_DIR}/src/server/database - ${CMAKE_SOURCE_DIR}/src/server/database/Database - ${CMAKE_SOURCE_DIR}/src/server/shared - ${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic - ${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic/LinkedReference - ${CMAKE_SOURCE_DIR}/src/server/shared/Packets - ${CMAKE_SOURCE_DIR}/src/server/shared/DataStores - ${CMAKE_SOURCE_DIR}/src/server/game/Addons - ${CMAKE_SOURCE_DIR}/src/server/game/Conditions - ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Item - ${CMAKE_SOURCE_DIR}/src/server/game/Entities/GameObject - ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Creature - ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Object - ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Object/Updates - ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Unit - ${CMAKE_SOURCE_DIR}/src/server/game/Combat - ${CMAKE_SOURCE_DIR}/src/server/game/Loot - ${CMAKE_SOURCE_DIR}/src/server/game/Miscellaneous - ${CMAKE_SOURCE_DIR}/src/server/game/Grids - ${CMAKE_SOURCE_DIR}/src/server/game/Grids/Cells - ${CMAKE_SOURCE_DIR}/src/server/game/Grids/Notifiers - ${CMAKE_SOURCE_DIR}/src/server/game/Maps - ${CMAKE_SOURCE_DIR}/src/server/game/DataStores - ${CMAKE_SOURCE_DIR}/src/server/game/Movement/Waypoints - ${CMAKE_SOURCE_DIR}/src/server/game/Movement/Spline - ${CMAKE_SOURCE_DIR}/src/server/game/Movement - ${CMAKE_SOURCE_DIR}/src/server/game/Server - ${CMAKE_SOURCE_DIR}/src/server/game/Server/Protocol - ${CMAKE_SOURCE_DIR}/src/server/game/World - ${CMAKE_SOURCE_DIR}/src/server/game/Spells - ${CMAKE_SOURCE_DIR}/src/server/game/Spells/Auras ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/Threading - ${CMAKE_CURRENT_SOURCE_DIR}/Debugging ${CMAKE_CURRENT_SOURCE_DIR}/Collision ${CMAKE_CURRENT_SOURCE_DIR}/Collision/Management ${CMAKE_CURRENT_SOURCE_DIR}/Collision/Maps ${CMAKE_CURRENT_SOURCE_DIR}/Collision/Models - ${CMAKE_CURRENT_SOURCE_DIR}/Utilities ${CMAKE_CURRENT_SOURCE_DIR}/Configuration + ${CMAKE_CURRENT_SOURCE_DIR}/Cryptography + ${CMAKE_CURRENT_SOURCE_DIR}/Debugging ${CMAKE_CURRENT_SOURCE_DIR}/Logging + ${CMAKE_CURRENT_SOURCE_DIR}/Utilities + ${CMAKE_SOURCE_DIR}/dep/cppformat + ${CMAKE_SOURCE_DIR}/dep/g3dlite/include + ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour/Include + ${CMAKE_SOURCE_DIR}/dep/SFMT + ${CMAKE_SOURCE_DIR}/dep/utf8cpp + ${OPENSSL_INCLUDE_DIR} ${VALGRIND_INCLUDE_DIR} ) diff --git a/src/common/Collision/Management/MMapManager.cpp b/src/common/Collision/Management/MMapManager.cpp index c93d4e0e751..a5685c65d9c 100644 --- a/src/common/Collision/Management/MMapManager.cpp +++ b/src/common/Collision/Management/MMapManager.cpp @@ -19,7 +19,7 @@ #include "MMapManager.h" #include "Log.h" #include "Config.h" -#include "SharedDefines.h" +#include "MapDefines.h" namespace MMAP { diff --git a/src/common/Collision/Maps/MapDefines.h b/src/common/Collision/Maps/MapDefines.h new file mode 100644 index 00000000000..538a78a38d4 --- /dev/null +++ b/src/common/Collision/Maps/MapDefines.h @@ -0,0 +1,36 @@ +#ifndef _MAPDEFINES_H +#define _MAPDEFINES_H + +#include "Define.h" +#include "DetourNavMesh.h" + +const uint32 MMAP_MAGIC = 0x4d4d4150; // 'MMAP' +#define MMAP_VERSION 5 + +struct MmapTileHeader +{ + uint32 mmapMagic; + uint32 dtVersion; + uint32 mmapVersion; + uint32 size; + bool usesLiquids : 1; + + MmapTileHeader() : mmapMagic(MMAP_MAGIC), dtVersion(DT_NAVMESH_VERSION), + mmapVersion(MMAP_VERSION), size(0), usesLiquids(true) { } +}; + +enum NavTerrain +{ + NAV_EMPTY = 0x00, + NAV_GROUND = 0x01, + NAV_MAGMA = 0x02, + NAV_SLIME = 0x04, + NAV_WATER = 0x08, + NAV_UNUSED1 = 0x10, + NAV_UNUSED2 = 0x20, + NAV_UNUSED3 = 0x40, + NAV_UNUSED4 = 0x80 + // we only have 8 bits +}; + +#endif diff --git a/src/common/Cryptography/ARC4.cpp b/src/common/Cryptography/ARC4.cpp new file mode 100644 index 00000000000..d1082b39347 --- /dev/null +++ b/src/common/Cryptography/ARC4.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2008-2015 TrinityCore + * Copyright (C) 2005-2009 MaNGOS + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "ARC4.h" + +ARC4::ARC4(uint8 len) : m_ctx() +{ + EVP_CIPHER_CTX_init(&m_ctx); + EVP_EncryptInit_ex(&m_ctx, EVP_rc4(), NULL, NULL, NULL); + EVP_CIPHER_CTX_set_key_length(&m_ctx, len); +} + +ARC4::ARC4(uint8 *seed, uint8 len) : m_ctx() +{ + EVP_CIPHER_CTX_init(&m_ctx); + EVP_EncryptInit_ex(&m_ctx, EVP_rc4(), NULL, NULL, NULL); + EVP_CIPHER_CTX_set_key_length(&m_ctx, len); + EVP_EncryptInit_ex(&m_ctx, NULL, NULL, seed, NULL); +} + +ARC4::~ARC4() +{ + EVP_CIPHER_CTX_cleanup(&m_ctx); +} + +void ARC4::Init(uint8 *seed) +{ + EVP_EncryptInit_ex(&m_ctx, NULL, NULL, seed, NULL); +} + +void ARC4::UpdateData(int len, uint8 *data) +{ + int outlen = 0; + EVP_EncryptUpdate(&m_ctx, data, &outlen, data, len); + EVP_EncryptFinal_ex(&m_ctx, data, &outlen); +} diff --git a/src/common/Cryptography/ARC4.h b/src/common/Cryptography/ARC4.h new file mode 100644 index 00000000000..16a0cb92eb9 --- /dev/null +++ b/src/common/Cryptography/ARC4.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2008-2015 TrinityCore + * Copyright (C) 2005-2009 MaNGOS + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef _AUTH_SARC4_H +#define _AUTH_SARC4_H + +#include +#include "Define.h" + +class ARC4 +{ + public: + ARC4(uint8 len); + ARC4(uint8 *seed, uint8 len); + ~ARC4(); + void Init(uint8 *seed); + void UpdateData(int len, uint8 *data); + private: + EVP_CIPHER_CTX m_ctx; +}; + +#endif diff --git a/src/common/Cryptography/Authentication/AuthCrypt.cpp b/src/common/Cryptography/Authentication/AuthCrypt.cpp new file mode 100644 index 00000000000..153726e6950 --- /dev/null +++ b/src/common/Cryptography/Authentication/AuthCrypt.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2008-2015 TrinityCore + * Copyright (C) 2005-2009 MaNGOS + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "AuthCrypt.h" +#include "Cryptography/HMACSHA1.h" +#include "Cryptography/BigNumber.h" + +#include + +AuthCrypt::AuthCrypt() : + _clientDecrypt(SHA_DIGEST_LENGTH), _serverEncrypt(SHA_DIGEST_LENGTH), + _initialized(false) +{ } + +void AuthCrypt::Init(BigNumber* K) +{ + uint8 ServerEncryptionKey[SEED_KEY_SIZE] = { 0xCC, 0x98, 0xAE, 0x04, 0xE8, 0x97, 0xEA, 0xCA, 0x12, 0xDD, 0xC0, 0x93, 0x42, 0x91, 0x53, 0x57 }; + HmacHash serverEncryptHmac(SEED_KEY_SIZE, (uint8*)ServerEncryptionKey); + uint8 *encryptHash = serverEncryptHmac.ComputeHash(K); + + uint8 ServerDecryptionKey[SEED_KEY_SIZE] = { 0xC2, 0xB3, 0x72, 0x3C, 0xC6, 0xAE, 0xD9, 0xB5, 0x34, 0x3C, 0x53, 0xEE, 0x2F, 0x43, 0x67, 0xCE }; + HmacHash clientDecryptHmac(SEED_KEY_SIZE, (uint8*)ServerDecryptionKey); + uint8 *decryptHash = clientDecryptHmac.ComputeHash(K); + + //ARC4 _serverDecrypt(encryptHash); + _clientDecrypt.Init(decryptHash); + _serverEncrypt.Init(encryptHash); + //ARC4 _clientEncrypt(decryptHash); + + // Drop first 1024 bytes, as WoW uses ARC4-drop1024. + uint8 syncBuf[1024]; + memset(syncBuf, 0, 1024); + + _serverEncrypt.UpdateData(1024, syncBuf); + //_clientEncrypt.UpdateData(1024, syncBuf); + + memset(syncBuf, 0, 1024); + + //_serverDecrypt.UpdateData(1024, syncBuf); + _clientDecrypt.UpdateData(1024, syncBuf); + + _initialized = true; +} + +void AuthCrypt::DecryptRecv(uint8 *data, size_t len) +{ + if (!_initialized) + return; + + _clientDecrypt.UpdateData(len, data); +} + +void AuthCrypt::EncryptSend(uint8 *data, size_t len) +{ + if (!_initialized) + return; + + _serverEncrypt.UpdateData(len, data); +} + diff --git a/src/common/Cryptography/Authentication/AuthCrypt.h b/src/common/Cryptography/Authentication/AuthCrypt.h new file mode 100644 index 00000000000..b8913c95a2c --- /dev/null +++ b/src/common/Cryptography/Authentication/AuthCrypt.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2008-2015 TrinityCore + * Copyright (C) 2005-2009 MaNGOS + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef _AUTHCRYPT_H +#define _AUTHCRYPT_H + +#include "Cryptography/ARC4.h" + +class BigNumber; + +class AuthCrypt +{ + public: + AuthCrypt(); + + void Init(BigNumber* K); + void DecryptRecv(uint8 *, size_t); + void EncryptSend(uint8 *, size_t); + + bool IsInitialized() const { return _initialized; } + + private: + ARC4 _clientDecrypt; + ARC4 _serverEncrypt; + bool _initialized; +}; +#endif diff --git a/src/common/Cryptography/BigNumber.cpp b/src/common/Cryptography/BigNumber.cpp new file mode 100644 index 00000000000..720e8e30441 --- /dev/null +++ b/src/common/Cryptography/BigNumber.cpp @@ -0,0 +1,201 @@ +/* + * Copyright (C) 2008-2015 TrinityCore + * Copyright (C) 2005-2009 MaNGOS + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "Cryptography/BigNumber.h" +#include +#include +#include +#include + +BigNumber::BigNumber() + : _bn(BN_new()) +{ } + +BigNumber::BigNumber(BigNumber const& bn) + : _bn(BN_dup(bn._bn)) +{ } + +BigNumber::BigNumber(uint32 val) + : _bn(BN_new()) +{ + BN_set_word(_bn, val); +} + +BigNumber::~BigNumber() +{ + BN_free(_bn); +} + +void BigNumber::SetDword(uint32 val) +{ + BN_set_word(_bn, val); +} + +void BigNumber::SetQword(uint64 val) +{ + BN_set_word(_bn, (uint32)(val >> 32)); + BN_lshift(_bn, _bn, 32); + BN_add_word(_bn, (uint32)(val & 0xFFFFFFFF)); +} + +void BigNumber::SetBinary(uint8 const* bytes, int32 len) +{ + uint8* array = new uint8[len]; + + for (int i = 0; i < len; i++) + array[i] = bytes[len - 1 - i]; + + BN_bin2bn(array, len, _bn); + + delete[] array; +} + +void BigNumber::SetHexStr(char const* str) +{ + BN_hex2bn(&_bn, str); +} + +void BigNumber::SetRand(int32 numbits) +{ + BN_rand(_bn, numbits, 0, 1); +} + +BigNumber& BigNumber::operator=(BigNumber const& bn) +{ + if (this == &bn) + return *this; + + BN_copy(_bn, bn._bn); + return *this; +} + +BigNumber BigNumber::operator+=(BigNumber const& bn) +{ + BN_add(_bn, _bn, bn._bn); + return *this; +} + +BigNumber BigNumber::operator-=(BigNumber const& bn) +{ + BN_sub(_bn, _bn, bn._bn); + return *this; +} + +BigNumber BigNumber::operator*=(BigNumber const& bn) +{ + BN_CTX *bnctx; + + bnctx = BN_CTX_new(); + BN_mul(_bn, _bn, bn._bn, bnctx); + BN_CTX_free(bnctx); + + return *this; +} + +BigNumber BigNumber::operator/=(BigNumber const& bn) +{ + BN_CTX *bnctx; + + bnctx = BN_CTX_new(); + BN_div(_bn, NULL, _bn, bn._bn, bnctx); + BN_CTX_free(bnctx); + + return *this; +} + +BigNumber BigNumber::operator%=(BigNumber const& bn) +{ + BN_CTX *bnctx; + + bnctx = BN_CTX_new(); + BN_mod(_bn, _bn, bn._bn, bnctx); + BN_CTX_free(bnctx); + + return *this; +} + +BigNumber BigNumber::Exp(BigNumber const& bn) +{ + BigNumber ret; + BN_CTX *bnctx; + + bnctx = BN_CTX_new(); + BN_exp(ret._bn, _bn, bn._bn, bnctx); + BN_CTX_free(bnctx); + + return ret; +} + +BigNumber BigNumber::ModExp(BigNumber const& bn1, BigNumber const& bn2) +{ + BigNumber ret; + BN_CTX *bnctx; + + bnctx = BN_CTX_new(); + BN_mod_exp(ret._bn, _bn, bn1._bn, bn2._bn, bnctx); + BN_CTX_free(bnctx); + + return ret; +} + +int32 BigNumber::GetNumBytes(void) +{ + return BN_num_bytes(_bn); +} + +uint32 BigNumber::AsDword() +{ + return (uint32)BN_get_word(_bn); +} + +bool BigNumber::isZero() const +{ + return BN_is_zero(_bn); +} + +std::unique_ptr BigNumber::AsByteArray(int32 minSize, bool littleEndian) +{ + int numBytes = GetNumBytes(); + int length = (minSize >= numBytes) ? minSize : numBytes; + + uint8* array = new uint8[length]; + + // If we need more bytes than length of BigNumber set the rest to 0 + if (length > numBytes) + memset((void*)array, 0, length); + + BN_bn2bin(_bn, (unsigned char *)array); + + // openssl's BN stores data internally in big endian format, reverse if little endian desired + if (littleEndian) + std::reverse(array, array + numBytes); + + std::unique_ptr ret(array); + return ret; +} + +char * BigNumber::AsHexStr() const +{ + return BN_bn2hex(_bn); +} + +char * BigNumber::AsDecStr() const +{ + return BN_bn2dec(_bn); +} + diff --git a/src/common/Cryptography/BigNumber.h b/src/common/Cryptography/BigNumber.h new file mode 100644 index 00000000000..e6a056b5baa --- /dev/null +++ b/src/common/Cryptography/BigNumber.h @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2008-2015 TrinityCore + * Copyright (C) 2005-2009 MaNGOS + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef _AUTH_BIGNUMBER_H +#define _AUTH_BIGNUMBER_H + +#include +#include "Define.h" + +struct bignum_st; + +class BigNumber +{ + public: + BigNumber(); + BigNumber(BigNumber const& bn); + BigNumber(uint32); + ~BigNumber(); + + void SetDword(uint32); + void SetQword(uint64); + void SetBinary(uint8 const* bytes, int32 len); + void SetHexStr(char const* str); + + void SetRand(int32 numbits); + + BigNumber& operator=(BigNumber const& bn); + + BigNumber operator+=(BigNumber const& bn); + BigNumber operator+(BigNumber const& bn) + { + BigNumber t(*this); + return t += bn; + } + + BigNumber operator-=(BigNumber const& bn); + BigNumber operator-(BigNumber const& bn) + { + BigNumber t(*this); + return t -= bn; + } + + BigNumber operator*=(BigNumber const& bn); + BigNumber operator*(BigNumber const& bn) + { + BigNumber t(*this); + return t *= bn; + } + + BigNumber operator/=(BigNumber const& bn); + BigNumber operator/(BigNumber const& bn) + { + BigNumber t(*this); + return t /= bn; + } + + BigNumber operator%=(BigNumber const& bn); + BigNumber operator%(BigNumber const& bn) + { + BigNumber t(*this); + return t %= bn; + } + + bool isZero() const; + + BigNumber ModExp(BigNumber const& bn1, BigNumber const& bn2); + BigNumber Exp(BigNumber const&); + + int32 GetNumBytes(void); + + struct bignum_st *BN() { return _bn; } + + uint32 AsDword(); + + std::unique_ptr AsByteArray(int32 minSize = 0, bool littleEndian = true); + + char * AsHexStr() const; + char * AsDecStr() const; + + private: + struct bignum_st *_bn; + +}; +#endif + diff --git a/src/common/Cryptography/HMACSHA1.cpp b/src/common/Cryptography/HMACSHA1.cpp new file mode 100644 index 00000000000..304633cbc03 --- /dev/null +++ b/src/common/Cryptography/HMACSHA1.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2008-2015 TrinityCore + * Copyright (C) 2005-2009 MaNGOS + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "HMACSHA1.h" +#include "BigNumber.h" +#include "Common.h" + +HmacHash::HmacHash(uint32 len, uint8 *seed) +{ + HMAC_CTX_init(&m_ctx); + HMAC_Init_ex(&m_ctx, seed, len, EVP_sha1(), NULL); + memset(m_digest, 0, sizeof(m_digest)); +} + +HmacHash::~HmacHash() +{ + HMAC_CTX_cleanup(&m_ctx); +} + +void HmacHash::UpdateData(const std::string &str) +{ + HMAC_Update(&m_ctx, (uint8 const*)str.c_str(), str.length()); +} + +void HmacHash::UpdateData(const uint8* data, size_t len) +{ + HMAC_Update(&m_ctx, data, len); +} + +void HmacHash::Finalize() +{ + uint32 length = 0; + HMAC_Final(&m_ctx, (uint8*)m_digest, &length); + ASSERT(length == SHA_DIGEST_LENGTH); +} + +uint8 *HmacHash::ComputeHash(BigNumber* bn) +{ + HMAC_Update(&m_ctx, bn->AsByteArray().get(), bn->GetNumBytes()); + Finalize(); + return (uint8*)m_digest; +} diff --git a/src/common/Cryptography/HMACSHA1.h b/src/common/Cryptography/HMACSHA1.h new file mode 100644 index 00000000000..66cf214d9b1 --- /dev/null +++ b/src/common/Cryptography/HMACSHA1.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2008-2015 TrinityCore + * Copyright (C) 2005-2009 MaNGOS + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef _AUTH_HMAC_H +#define _AUTH_HMAC_H + +#include "Define.h" +#include +#include +#include + +class BigNumber; + +#define SEED_KEY_SIZE 16 + +class HmacHash +{ + public: + HmacHash(uint32 len, uint8 *seed); + ~HmacHash(); + void UpdateData(const std::string &str); + void UpdateData(const uint8* data, size_t len); + void Finalize(); + uint8 *ComputeHash(BigNumber* bn); + uint8 *GetDigest() { return (uint8*)m_digest; } + int GetLength() const { return SHA_DIGEST_LENGTH; } + private: + HMAC_CTX m_ctx; + uint8 m_digest[SHA_DIGEST_LENGTH]; +}; +#endif + diff --git a/src/common/Cryptography/OpenSSLCrypto.cpp b/src/common/Cryptography/OpenSSLCrypto.cpp new file mode 100644 index 00000000000..f122888292f --- /dev/null +++ b/src/common/Cryptography/OpenSSLCrypto.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2008-2015 TrinityCore + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include +#include +#include +#include +#include + +std::vector cryptoLocks; + +static void lockingCallback(int mode, int type, const char* /*file*/, int /*line*/) +{ + if (mode & CRYPTO_LOCK) + cryptoLocks[type]->lock(); + else + cryptoLocks[type]->unlock(); +} + +static void threadIdCallback(CRYPTO_THREADID * id) +{ + CRYPTO_THREADID_set_numeric(id, std::hash()(std::this_thread::get_id())); +} + +void OpenSSLCrypto::threadsSetup() +{ + cryptoLocks.resize(CRYPTO_num_locks()); + for(int i = 0 ; i < CRYPTO_num_locks(); ++i) + { + cryptoLocks[i] = new std::mutex; + } + CRYPTO_THREADID_set_callback(threadIdCallback); + CRYPTO_set_locking_callback(lockingCallback); +} + +void OpenSSLCrypto::threadsCleanup() +{ + CRYPTO_set_locking_callback(NULL); + CRYPTO_THREADID_set_callback(NULL); + for(int i = 0 ; i < CRYPTO_num_locks(); ++i) + { + delete cryptoLocks[i]; + } + cryptoLocks.resize(0); +} diff --git a/src/common/Cryptography/OpenSSLCrypto.h b/src/common/Cryptography/OpenSSLCrypto.h new file mode 100644 index 00000000000..0daa20c4780 --- /dev/null +++ b/src/common/Cryptography/OpenSSLCrypto.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2008-2015 TrinityCore + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef OPENSSL_CRYPTO_H +#define OPENSSL_CRYPTO_H + +/** +* A group of functions which setup openssl crypto module to work properly in multithreaded enviroment +* If not setup properly - it will crash +*/ +namespace OpenSSLCrypto +{ + /// Needs to be called before threads using openssl are spawned + void threadsSetup(); + /// Needs to be called after threads using openssl are despawned + void threadsCleanup(); +} + +#endif \ No newline at end of file diff --git a/src/common/Cryptography/SHA1.cpp b/src/common/Cryptography/SHA1.cpp new file mode 100644 index 00000000000..bd7101075de --- /dev/null +++ b/src/common/Cryptography/SHA1.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2008-2015 TrinityCore + * Copyright (C) 2005-2009 MaNGOS + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "SHA1.h" +#include "BigNumber.h" +#include +#include + +SHA1Hash::SHA1Hash() +{ + SHA1_Init(&mC); + memset(mDigest, 0, SHA_DIGEST_LENGTH * sizeof(uint8)); +} + +SHA1Hash::~SHA1Hash() +{ + SHA1_Init(&mC); +} + +void SHA1Hash::UpdateData(const uint8 *dta, int len) +{ + SHA1_Update(&mC, dta, len); +} + +void SHA1Hash::UpdateData(const std::string &str) +{ + UpdateData((uint8 const*)str.c_str(), str.length()); +} + +void SHA1Hash::UpdateBigNumbers(BigNumber* bn0, ...) +{ + va_list v; + BigNumber* bn; + + va_start(v, bn0); + bn = bn0; + while (bn) + { + UpdateData(bn->AsByteArray().get(), bn->GetNumBytes()); + bn = va_arg(v, BigNumber*); + } + va_end(v); +} + +void SHA1Hash::Initialize() +{ + SHA1_Init(&mC); +} + +void SHA1Hash::Finalize(void) +{ + SHA1_Final(mDigest, &mC); +} + diff --git a/src/common/Cryptography/SHA1.h b/src/common/Cryptography/SHA1.h new file mode 100644 index 00000000000..f59bdc25556 --- /dev/null +++ b/src/common/Cryptography/SHA1.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2008-2015 TrinityCore + * Copyright (C) 2005-2009 MaNGOS + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef _AUTH_SHA1_H +#define _AUTH_SHA1_H + +#include "Define.h" +#include +#include + +class BigNumber; + +class SHA1Hash +{ + public: + SHA1Hash(); + ~SHA1Hash(); + + void UpdateBigNumbers(BigNumber* bn0, ...); + + void UpdateData(const uint8 *dta, int len); + void UpdateData(const std::string &str); + + void Initialize(); + void Finalize(); + + uint8 *GetDigest(void) { return mDigest; } + int GetLength(void) const { return SHA_DIGEST_LENGTH; } + + private: + SHA_CTX mC; + uint8 mDigest[SHA_DIGEST_LENGTH]; +}; +#endif + diff --git a/src/common/Cryptography/WardenKeyGeneration.h b/src/common/Cryptography/WardenKeyGeneration.h new file mode 100644 index 00000000000..bfa0337d347 --- /dev/null +++ b/src/common/Cryptography/WardenKeyGeneration.h @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2008-2015 TrinityCore + * Copyright (C) 2005-2011 MaNGOS + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "SHA1.h" + +#include + +#ifndef _WARDEN_KEY_GENERATION_H +#define _WARDEN_KEY_GENERATION_H + +class SHA1Randx +{ +public: + SHA1Randx(uint8* buff, uint32 size) + { + uint32 halfSize = size / 2; + + sh.Initialize(); + sh.UpdateData(buff, halfSize); + sh.Finalize(); + + memcpy(o1, sh.GetDigest(), 20); + + sh.Initialize(); + sh.UpdateData(buff + halfSize, size - halfSize); + sh.Finalize(); + + memcpy(o2, sh.GetDigest(), 20); + + memset(o0, 0x00, 20); + + FillUp(); + } + + void Generate(uint8* buf, uint32 sz) + { + for (uint32 i = 0; i < sz; ++i) + { + if (taken == 20) + FillUp(); + + buf[i] = o0[taken]; + taken++; + } + } + +private: + void FillUp() + { + sh.Initialize(); + sh.UpdateData(o1, 20); + sh.UpdateData(o0, 20); + sh.UpdateData(o2, 20); + sh.Finalize(); + + memcpy(o0, sh.GetDigest(), 20); + + taken = 0; + } + + SHA1Hash sh; + uint32 taken; + uint8 o0[20], o1[20], o2[20]; +}; + +#endif diff --git a/src/common/GitRevision.cpp b/src/common/GitRevision.cpp new file mode 100644 index 00000000000..d0719c09959 --- /dev/null +++ b/src/common/GitRevision.cpp @@ -0,0 +1,78 @@ +#include "GitRevision.h" +#include "CompilerDefs.h" +#include "revision_data.h" + +char const* GitRevision::GetHash() +{ + return _HASH; +} + +char const* GitRevision::GetDate() +{ + return _DATE; +} + +char const* GitRevision::GetBranch() +{ + return _BRANCH; +} + +char const* GitRevision::GetSourceDirectory() +{ + return _SOURCE_DIRECTORY; +} + +char const* GitRevision::GetMySQLExecutable() +{ + return _MYSQL_EXECUTABLE; +} + +char const* GitRevision::GetFullDatabase() +{ + return _FULL_DATABASE; +} + +#define _PACKAGENAME "TrinityCore" + +char const* GitRevision::GetFullVersion() +{ +#if PLATFORM == PLATFORM_WINDOWS +# ifdef _WIN64 + return _PACKAGENAME " rev. " VER_PRODUCTVERSION_STR " (Win64, " _BUILD_DIRECTIVE ")"; +# else + return _PACKAGENAME " rev. " VER_PRODUCTVERSION_STR " (Win32, " _BUILD_DIRECTIVE ")"; +# endif +#else + return _PACKAGENAME " rev. " VER_PRODUCTVERSION_STR " (Unix, " _BUILD_DIRECTIVE ")"; +#endif +} + +char const* GitRevision::GetCompanyNameStr() +{ + return VER_COMPANYNAME_STR; +} + +char const* GitRevision::GetLegalCopyrightStr() +{ + return VER_LEGALCOPYRIGHT_STR; +} + +char const* GitRevision::GetFileVersionStr() +{ + return VER_FILEVERSION_STR; +} + +char const* GitRevision::GetProductVersionStr() +{ + return VER_PRODUCTVERSION_STR; +} + +char const* GitRevision::GetCompilerCFlags() +{ + return COMPILER_C_FLAGS; +} + +char const* GitRevision::GetCompilerCXXFlags() +{ + return COMPILER_CXX_FLAGS; +} diff --git a/src/common/GitRevision.h b/src/common/GitRevision.h new file mode 100644 index 00000000000..d9b292031f6 --- /dev/null +++ b/src/common/GitRevision.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2008-2015 TrinityCore + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef __GITREVISION_H__ +#define __GITREVISION_H__ + +#include + +namespace GitRevision +{ + char const* GetHash(); + char const* GetDate(); + char const* GetBranch(); + char const* GetSourceDirectory(); + char const* GetMySQLExecutable(); + char const* GetFullDatabase(); + char const* GetFullVersion(); + char const* GetCompanyNameStr(); + char const* GetLegalCopyrightStr(); + char const* GetFileVersionStr(); + char const* GetProductVersionStr(); + char const* GetCompilerCFlags(); + char const* GetCompilerCXXFlags(); +} + +#endif diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt index 5d3daef05d8..e89a33c4376 100644 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -28,4 +28,3 @@ add_subdirectory(game) add_subdirectory(authserver) add_subdirectory(scripts) add_subdirectory(worldserver) - diff --git a/src/server/authserver/CMakeLists.txt b/src/server/authserver/CMakeLists.txt index 24a2dc35fce..a8e35a8d9ef 100644 --- a/src/server/authserver/CMakeLists.txt +++ b/src/server/authserver/CMakeLists.txt @@ -43,31 +43,23 @@ endif() include_directories( ${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/dep/cppformat - ${CMAKE_SOURCE_DIR}/dep/process - ${CMAKE_SOURCE_DIR}/src/server/database - ${CMAKE_SOURCE_DIR}/src/server/database/Database - ${CMAKE_SOURCE_DIR}/src/server/database/Logging - ${CMAKE_SOURCE_DIR}/src/server/database/Updater - ${CMAKE_SOURCE_DIR}/src/server/shared - ${CMAKE_SOURCE_DIR}/src/server/shared/Packets - ${CMAKE_SOURCE_DIR}/src/server/shared/Cryptography - ${CMAKE_SOURCE_DIR}/src/server/shared/Cryptography/Authentication - ${CMAKE_SOURCE_DIR}/src/server/shared/Networking - ${CMAKE_SOURCE_DIR}/src/server/shared/Service - ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/Authentication ${CMAKE_CURRENT_SOURCE_DIR}/Realms ${CMAKE_CURRENT_SOURCE_DIR}/Server + ${CMAKE_SOURCE_DIR}/dep/cppformat ${CMAKE_SOURCE_DIR}/src/common/ - ${CMAKE_SOURCE_DIR}/src/common/Collision - ${CMAKE_SOURCE_DIR}/src/common/Collision/Management - ${CMAKE_SOURCE_DIR}/src/common/Collision/Models - ${CMAKE_SOURCE_DIR}/src/common/Debugging - ${CMAKE_SOURCE_DIR}/src/common/Utilities - ${CMAKE_SOURCE_DIR}/src/common/Threading ${CMAKE_SOURCE_DIR}/src/common/Configuration + ${CMAKE_SOURCE_DIR}/src/common/Cryptography + ${CMAKE_SOURCE_DIR}/src/common/Debugging ${CMAKE_SOURCE_DIR}/src/common/Logging + ${CMAKE_SOURCE_DIR}/src/common/Threading + ${CMAKE_SOURCE_DIR}/src/common/Utilities + ${CMAKE_SOURCE_DIR}/src/server/database + ${CMAKE_SOURCE_DIR}/src/server/database/Database + ${CMAKE_SOURCE_DIR}/src/server/database/Logging + ${CMAKE_SOURCE_DIR}/src/server/shared/Networking + ${CMAKE_SOURCE_DIR}/src/server/shared/Packets + ${CMAKE_SOURCE_DIR}/src/server/shared/Service ${MYSQL_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${VALGRIND_INCLUDE_DIR} diff --git a/src/server/database/CMakeLists.txt b/src/server/database/CMakeLists.txt index 3fa7ed10aaf..2375f18d7b5 100644 --- a/src/server/database/CMakeLists.txt +++ b/src/server/database/CMakeLists.txt @@ -8,6 +8,8 @@ # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +find_package(MySQL REQUIRED) + if( USE_COREPCH ) include_directories(${CMAKE_CURRENT_BINARY_DIR}) endif() @@ -34,30 +36,29 @@ set(database_STAT_SRCS ${sources_Updater} ) +# Do NOT add any extra include directory unless it does not create unneeded extra dependencies, +# and specially, not add any dependency to neither of these: shared, game, scripts +# This way we ensure that if either a PR does that without modifying this file, +# a compile error will be generated, either this file will be modified so it +# is detected more easily. +# While it is OK to include files from other libs as long as they don't require +# linkage (enums, defines...) it is discouraged to do so unless necessary, as it will pullute +# include_directories leading to further unnoticed dependency aditions +# Linker Depencency requirements: common include_directories( - ${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour - ${CMAKE_SOURCE_DIR}/dep/SFMT - ${CMAKE_SOURCE_DIR}/dep/cppformat - ${CMAKE_SOURCE_DIR}/dep/utf8cpp - ${CMAKE_SOURCE_DIR}/dep/process - ${CMAKE_SOURCE_DIR}/src/server ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/Database - ${CMAKE_CURRENT_SOURCE_DIR}/Logging ${CMAKE_CURRENT_SOURCE_DIR}/Updater + ${CMAKE_SOURCE_DIR}/dep/cppformat + ${CMAKE_SOURCE_DIR}/dep/process ${CMAKE_SOURCE_DIR}/src/common/ - ${CMAKE_SOURCE_DIR}/src/common/Collision - ${CMAKE_SOURCE_DIR}/src/common/Collision/Management - ${CMAKE_SOURCE_DIR}/src/common/Collision/Models + ${CMAKE_SOURCE_DIR}/src/common/Configuration ${CMAKE_SOURCE_DIR}/src/common/Debugging + ${CMAKE_SOURCE_DIR}/src/common/Logging ${CMAKE_SOURCE_DIR}/src/common/Threading ${CMAKE_SOURCE_DIR}/src/common/Utilities - ${CMAKE_SOURCE_DIR}/src/common/Configuration - ${CMAKE_SOURCE_DIR}/src/common/Logging - ${CMAKE_SOURCE_DIR}/src/server/shared ${MYSQL_INCLUDE_DIR} - ${OPENSSL_INCLUDE_DIR} # seems needed for Windows build + ${OPENSSL_INCLUDE_DIR} ${VALGRIND_INCLUDE_DIR} ) diff --git a/src/server/game/CMakeLists.txt b/src/server/game/CMakeLists.txt index ccc69b3ef68..6455e3a7e29 100644 --- a/src/server/game/CMakeLists.txt +++ b/src/server/game/CMakeLists.txt @@ -103,38 +103,6 @@ set(game_STAT_SRCS ) include_directories( - ${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour - ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour/Include - ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Recast - ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Recast/Include - ${CMAKE_SOURCE_DIR}/dep/g3dlite/include - ${CMAKE_SOURCE_DIR}/dep/SFMT - ${CMAKE_SOURCE_DIR}/dep/cppformat - ${CMAKE_SOURCE_DIR}/dep/zlib - ${CMAKE_SOURCE_DIR}/src/common - ${CMAKE_SOURCE_DIR}/src/common/Collision - ${CMAKE_SOURCE_DIR}/src/common/Collision/Management - ${CMAKE_SOURCE_DIR}/src/common/Collision/Models - ${CMAKE_SOURCE_DIR}/src/common/Collision/Maps - ${CMAKE_SOURCE_DIR}/src/common/Debugging - ${CMAKE_SOURCE_DIR}/src/common/Utilities - ${CMAKE_SOURCE_DIR}/src/common/Threading - ${CMAKE_SOURCE_DIR}/src/common/Configuration - ${CMAKE_SOURCE_DIR}/src/common/Logging - ${CMAKE_SOURCE_DIR}/src/server/database - ${CMAKE_SOURCE_DIR}/src/server/database/Database - ${CMAKE_SOURCE_DIR}/src/server/database/Logging - ${CMAKE_SOURCE_DIR}/src/server/database/Updater - ${CMAKE_SOURCE_DIR}/src/server/shared - ${CMAKE_SOURCE_DIR}/src/server/shared/Cryptography - ${CMAKE_SOURCE_DIR}/src/server/shared/Cryptography/Authentication - ${CMAKE_SOURCE_DIR}/src/server/shared/DataStores - ${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic/LinkedReference - ${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic - ${CMAKE_SOURCE_DIR}/src/server/shared/Networking - ${CMAKE_SOURCE_DIR}/src/server/shared/Packets - ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/Accounts ${CMAKE_CURRENT_SOURCE_DIR}/Achievements ${CMAKE_CURRENT_SOURCE_DIR}/Addons @@ -155,9 +123,8 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/Conditions ${CMAKE_CURRENT_SOURCE_DIR}/DataStores ${CMAKE_CURRENT_SOURCE_DIR}/DungeonFinding - ${CMAKE_CURRENT_SOURCE_DIR}/Entities - ${CMAKE_CURRENT_SOURCE_DIR}/Entities/Creature ${CMAKE_CURRENT_SOURCE_DIR}/Entities/Corpse + ${CMAKE_CURRENT_SOURCE_DIR}/Entities/Creature ${CMAKE_CURRENT_SOURCE_DIR}/Entities/DynamicObject ${CMAKE_CURRENT_SOURCE_DIR}/Entities/GameObject ${CMAKE_CURRENT_SOURCE_DIR}/Entities/Item @@ -167,14 +134,14 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/Entities/Pet ${CMAKE_CURRENT_SOURCE_DIR}/Entities/Player ${CMAKE_CURRENT_SOURCE_DIR}/Entities/Totem + ${CMAKE_CURRENT_SOURCE_DIR}/Entities/Transport ${CMAKE_CURRENT_SOURCE_DIR}/Entities/Unit ${CMAKE_CURRENT_SOURCE_DIR}/Entities/Vehicle - ${CMAKE_CURRENT_SOURCE_DIR}/Entities/Transport ${CMAKE_CURRENT_SOURCE_DIR}/Events ${CMAKE_CURRENT_SOURCE_DIR}/Globals + ${CMAKE_CURRENT_SOURCE_DIR}/Grids ${CMAKE_CURRENT_SOURCE_DIR}/Grids/Cells ${CMAKE_CURRENT_SOURCE_DIR}/Grids/Notifiers - ${CMAKE_CURRENT_SOURCE_DIR}/Grids ${CMAKE_CURRENT_SOURCE_DIR}/Groups ${CMAKE_CURRENT_SOURCE_DIR}/Guilds ${CMAKE_CURRENT_SOURCE_DIR}/Handlers @@ -184,28 +151,50 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/Maps ${CMAKE_CURRENT_SOURCE_DIR}/Miscellaneous ${CMAKE_CURRENT_SOURCE_DIR}/Movement - ${CMAKE_CURRENT_SOURCE_DIR}/Movement/Spline ${CMAKE_CURRENT_SOURCE_DIR}/Movement/MovementGenerators + ${CMAKE_CURRENT_SOURCE_DIR}/Movement/Spline ${CMAKE_CURRENT_SOURCE_DIR}/Movement/Waypoints ${CMAKE_CURRENT_SOURCE_DIR}/OutdoorPvP ${CMAKE_CURRENT_SOURCE_DIR}/Pools - ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders ${CMAKE_CURRENT_SOURCE_DIR}/Quests ${CMAKE_CURRENT_SOURCE_DIR}/Reputation ${CMAKE_CURRENT_SOURCE_DIR}/Scripting - ${CMAKE_CURRENT_SOURCE_DIR}/Server/Protocol ${CMAKE_CURRENT_SOURCE_DIR}/Server + ${CMAKE_CURRENT_SOURCE_DIR}/Server/Protocol ${CMAKE_CURRENT_SOURCE_DIR}/Skills ${CMAKE_CURRENT_SOURCE_DIR}/Spells ${CMAKE_CURRENT_SOURCE_DIR}/Spells/Auras ${CMAKE_CURRENT_SOURCE_DIR}/Texts - ${CMAKE_CURRENT_SOURCE_DIR}/Tools ${CMAKE_CURRENT_SOURCE_DIR}/Tickets + ${CMAKE_CURRENT_SOURCE_DIR}/Tools ${CMAKE_CURRENT_SOURCE_DIR}/Warden ${CMAKE_CURRENT_SOURCE_DIR}/Warden/Modules ${CMAKE_CURRENT_SOURCE_DIR}/Weather ${CMAKE_CURRENT_SOURCE_DIR}/World - ${CMAKE_SOURCE_DIR}/src/server/scripts/PrecompiledHeaders + ${CMAKE_SOURCE_DIR}/dep/cppformat + ${CMAKE_SOURCE_DIR}/dep/g3dlite/include + ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour/Include + ${CMAKE_SOURCE_DIR}/dep/zlib + ${CMAKE_SOURCE_DIR}/src/common + ${CMAKE_SOURCE_DIR}/src/common/Collision + ${CMAKE_SOURCE_DIR}/src/common/Collision/Management + ${CMAKE_SOURCE_DIR}/src/common/Collision/Maps + ${CMAKE_SOURCE_DIR}/src/common/Collision/Models + ${CMAKE_SOURCE_DIR}/src/common/Configuration + ${CMAKE_SOURCE_DIR}/src/common/Cryptography + ${CMAKE_SOURCE_DIR}/src/common/Cryptography/Authentication + ${CMAKE_SOURCE_DIR}/src/common/Debugging + ${CMAKE_SOURCE_DIR}/src/common/Logging + ${CMAKE_SOURCE_DIR}/src/common/Threading + ${CMAKE_SOURCE_DIR}/src/common/Utilities + ${CMAKE_SOURCE_DIR}/src/server/database + ${CMAKE_SOURCE_DIR}/src/server/database/Database + ${CMAKE_SOURCE_DIR}/src/server/shared + ${CMAKE_SOURCE_DIR}/src/server/shared/DataStores + ${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic + ${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic/LinkedReference + ${CMAKE_SOURCE_DIR}/src/server/shared/Networking + ${CMAKE_SOURCE_DIR}/src/server/shared/Packets ${MYSQL_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${VALGRIND_INCLUDE_DIR} diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index 06c58a408da..ac16a83e6a7 100644 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -3560,35 +3560,6 @@ enum PartyResult ERR_PARTY_LFG_TELEPORT_IN_COMBAT = 30 }; -const uint32 MMAP_MAGIC = 0x4d4d4150; // 'MMAP' -#define MMAP_VERSION 5 - -struct MmapTileHeader -{ - uint32 mmapMagic; - uint32 dtVersion; - uint32 mmapVersion; - uint32 size; - bool usesLiquids : 1; - - MmapTileHeader() : mmapMagic(MMAP_MAGIC), dtVersion(DT_NAVMESH_VERSION), - mmapVersion(MMAP_VERSION), size(0), usesLiquids(true) { } -}; - -enum NavTerrain -{ - NAV_EMPTY = 0x00, - NAV_GROUND = 0x01, - NAV_MAGMA = 0x02, - NAV_SLIME = 0x04, - NAV_WATER = 0x08, - NAV_UNUSED1 = 0x10, - NAV_UNUSED2 = 0x20, - NAV_UNUSED3 = 0x40, - NAV_UNUSED4 = 0x80 - // we only have 8 bits -}; - enum DiminishingLevels { DIMINISHING_LEVEL_1 = 0, diff --git a/src/server/game/Movement/PathGenerator.h b/src/server/game/Movement/PathGenerator.h index a9a13c37251..71e0e88f0b2 100644 --- a/src/server/game/Movement/PathGenerator.h +++ b/src/server/game/Movement/PathGenerator.h @@ -19,7 +19,7 @@ #ifndef _PATH_GENERATOR_H #define _PATH_GENERATOR_H -#include "SharedDefines.h" +#include "MapDefines.h" #include "DetourNavMesh.h" #include "DetourNavMeshQuery.h" #include "MoveSplineInitArgs.h" diff --git a/src/server/scripts/CMakeLists.txt b/src/server/scripts/CMakeLists.txt index db15ce8c36d..3668a2b0dac 100644 --- a/src/server/scripts/CMakeLists.txt +++ b/src/server/scripts/CMakeLists.txt @@ -43,35 +43,20 @@ message(STATUS "SCRIPT PREPARATION COMPLETE") message("") include_directories( - ${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour - ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour/Include - ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Recast - ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Recast/Include - ${CMAKE_SOURCE_DIR}/dep/g3dlite/include - ${CMAKE_SOURCE_DIR}/dep/SFMT ${CMAKE_SOURCE_DIR}/dep/cppformat - ${CMAKE_SOURCE_DIR}/dep/zlib - ${CMAKE_SOURCE_DIR}/src/server/database - ${CMAKE_SOURCE_DIR}/src/server/database/Database - ${CMAKE_SOURCE_DIR}/src/server/database/Logging - ${CMAKE_SOURCE_DIR}/src/server/database/Updater - ${CMAKE_SOURCE_DIR}/src/server/shared - ${CMAKE_SOURCE_DIR}/src/server/shared/Cryptography - ${CMAKE_SOURCE_DIR}/src/server/shared/DataStores - ${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic/LinkedReference - ${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic - ${CMAKE_SOURCE_DIR}/src/server/shared/Packets + ${CMAKE_SOURCE_DIR}/dep/g3dlite/include + ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour/Include ${CMAKE_SOURCE_DIR}/src/common/ ${CMAKE_SOURCE_DIR}/src/common/Collision ${CMAKE_SOURCE_DIR}/src/common/Collision/Management + ${CMAKE_SOURCE_DIR}/src/common/Collision/Maps ${CMAKE_SOURCE_DIR}/src/common/Collision/Models - ${CMAKE_SOURCE_DIR}/src/common/Debugging - ${CMAKE_SOURCE_DIR}/src/common/Utilities - ${CMAKE_SOURCE_DIR}/src/common/Threading ${CMAKE_SOURCE_DIR}/src/common/Configuration + ${CMAKE_SOURCE_DIR}/src/common/Debugging ${CMAKE_SOURCE_DIR}/src/common/Logging - ${CMAKE_SOURCE_DIR}/src/server/shared + ${CMAKE_SOURCE_DIR}/src/common/Threading + ${CMAKE_SOURCE_DIR}/src/common/Utilities + ${CMAKE_SOURCE_DIR}/src/server/database/Database ${CMAKE_SOURCE_DIR}/src/server/game/Accounts ${CMAKE_SOURCE_DIR}/src/server/game/Achievements ${CMAKE_SOURCE_DIR}/src/server/game/Addons @@ -85,20 +70,18 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/server/game/Battlefield/Zones ${CMAKE_SOURCE_DIR}/src/server/game/Battlegrounds ${CMAKE_SOURCE_DIR}/src/server/game/Battlegrounds/Zones - ${CMAKE_SOURCE_DIR}/src/server/game/Calendar ${CMAKE_SOURCE_DIR}/src/server/game/Chat ${CMAKE_SOURCE_DIR}/src/server/game/Chat/Channels - ${CMAKE_SOURCE_DIR}/src/server/game/Conditions - ${CMAKE_SOURCE_DIR}/src/server/shared/Configuration ${CMAKE_SOURCE_DIR}/src/server/game/Combat + ${CMAKE_SOURCE_DIR}/src/server/game/Conditions ${CMAKE_SOURCE_DIR}/src/server/game/DataStores ${CMAKE_SOURCE_DIR}/src/server/game/DungeonFinding ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Corpse ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Creature ${CMAKE_SOURCE_DIR}/src/server/game/Entities/DynamicObject + ${CMAKE_SOURCE_DIR}/src/server/game/Entities/GameObject ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Item ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Item/Container - ${CMAKE_SOURCE_DIR}/src/server/game/Entities/GameObject ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Object ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Object/Updates ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Pet @@ -115,19 +98,16 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/server/game/Guilds ${CMAKE_SOURCE_DIR}/src/server/game/Handlers ${CMAKE_SOURCE_DIR}/src/server/game/Instances - ${CMAKE_SOURCE_DIR}/src/server/game/LookingForGroup ${CMAKE_SOURCE_DIR}/src/server/game/Loot ${CMAKE_SOURCE_DIR}/src/server/game/Mails - ${CMAKE_SOURCE_DIR}/src/server/game/Miscellaneous ${CMAKE_SOURCE_DIR}/src/server/game/Maps + ${CMAKE_SOURCE_DIR}/src/server/game/Miscellaneous ${CMAKE_SOURCE_DIR}/src/server/game/Movement ${CMAKE_SOURCE_DIR}/src/server/game/Movement/MovementGenerators ${CMAKE_SOURCE_DIR}/src/server/game/Movement/Spline ${CMAKE_SOURCE_DIR}/src/server/game/Movement/Waypoints - ${CMAKE_SOURCE_DIR}/src/server/game/Opcodes ${CMAKE_SOURCE_DIR}/src/server/game/OutdoorPvP ${CMAKE_SOURCE_DIR}/src/server/game/Pools - ${CMAKE_SOURCE_DIR}/src/server/game/PrecompiledHeaders ${CMAKE_SOURCE_DIR}/src/server/game/Quests ${CMAKE_SOURCE_DIR}/src/server/game/Reputation ${CMAKE_SOURCE_DIR}/src/server/game/Scripting @@ -140,10 +120,13 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/server/game/Tickets ${CMAKE_SOURCE_DIR}/src/server/game/Tools ${CMAKE_SOURCE_DIR}/src/server/game/Warden - ${CMAKE_SOURCE_DIR}/src/server/game/Warden/Modules ${CMAKE_SOURCE_DIR}/src/server/game/Weather ${CMAKE_SOURCE_DIR}/src/server/game/World - ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders + ${CMAKE_SOURCE_DIR}/src/server/shared + ${CMAKE_SOURCE_DIR}/src/server/shared/DataStores + ${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic + ${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic/LinkedReference + ${CMAKE_SOURCE_DIR}/src/server/shared/Packets ${MYSQL_INCLUDE_DIR} ${VALGRIND_INCLUDE_DIR} ) diff --git a/src/server/shared/CMakeLists.txt b/src/server/shared/CMakeLists.txt index 1653d605faa..b43abb60481 100644 --- a/src/server/shared/CMakeLists.txt +++ b/src/server/shared/CMakeLists.txt @@ -12,7 +12,6 @@ if( USE_COREPCH ) include_directories(${CMAKE_CURRENT_BINARY_DIR}) endif() -file(GLOB_RECURSE sources_Cryptography Cryptography/*.cpp Cryptography/*.h) file(GLOB_RECURSE sources_DataStores DataStores/*.cpp DataStores/*.h) file(GLOB_RECURSE sources_Dynamic Dynamic/*.cpp Dynamic/*.h) file(GLOB_RECURSE sources_Networking Networking/*.cpp Networking/*.h) @@ -33,7 +32,6 @@ endif() set(shared_STAT_SRCS ${shared_STAT_SRCS} - ${sources_Cryptography} ${sources_DataStores} ${sources_Dynamic} ${sources_Networking} @@ -44,32 +42,13 @@ set(shared_STAT_SRCS ) include_directories( - ${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour - ${CMAKE_SOURCE_DIR}/dep/SFMT - ${CMAKE_SOURCE_DIR}/dep/cppformat - ${CMAKE_SOURCE_DIR}/dep/utf8cpp - ${CMAKE_SOURCE_DIR}/dep/process - ${CMAKE_SOURCE_DIR}/src/server - ${CMAKE_SOURCE_DIR}/src/server/database - ${CMAKE_SOURCE_DIR}/src/server/database/Database - ${CMAKE_SOURCE_DIR}/src/server/database/Logging - ${CMAKE_SOURCE_DIR}/src/server/database/Updater - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/Cryptography - ${CMAKE_CURRENT_SOURCE_DIR}/DataStores ${CMAKE_CURRENT_SOURCE_DIR}/Dynamic ${CMAKE_CURRENT_SOURCE_DIR}/Networking - ${CMAKE_CURRENT_SOURCE_DIR}/Packets - ${CMAKE_CURRENT_SOURCE_DIR}/Service + ${CMAKE_SOURCE_DIR}/dep/cppformat ${CMAKE_SOURCE_DIR}/src/common/ - ${CMAKE_SOURCE_DIR}/src/common/Collision - ${CMAKE_SOURCE_DIR}/src/common/Collision/Management - ${CMAKE_SOURCE_DIR}/src/common/Collision/Models ${CMAKE_SOURCE_DIR}/src/common/Debugging - ${CMAKE_SOURCE_DIR}/src/common/Utilities - ${CMAKE_SOURCE_DIR}/src/common/Configuration ${CMAKE_SOURCE_DIR}/src/common/Logging + ${CMAKE_SOURCE_DIR}/src/common/Utilities ${MYSQL_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${VALGRIND_INCLUDE_DIR} diff --git a/src/server/shared/Cryptography/ARC4.cpp b/src/server/shared/Cryptography/ARC4.cpp deleted file mode 100644 index d1082b39347..00000000000 --- a/src/server/shared/Cryptography/ARC4.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2008-2015 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "ARC4.h" - -ARC4::ARC4(uint8 len) : m_ctx() -{ - EVP_CIPHER_CTX_init(&m_ctx); - EVP_EncryptInit_ex(&m_ctx, EVP_rc4(), NULL, NULL, NULL); - EVP_CIPHER_CTX_set_key_length(&m_ctx, len); -} - -ARC4::ARC4(uint8 *seed, uint8 len) : m_ctx() -{ - EVP_CIPHER_CTX_init(&m_ctx); - EVP_EncryptInit_ex(&m_ctx, EVP_rc4(), NULL, NULL, NULL); - EVP_CIPHER_CTX_set_key_length(&m_ctx, len); - EVP_EncryptInit_ex(&m_ctx, NULL, NULL, seed, NULL); -} - -ARC4::~ARC4() -{ - EVP_CIPHER_CTX_cleanup(&m_ctx); -} - -void ARC4::Init(uint8 *seed) -{ - EVP_EncryptInit_ex(&m_ctx, NULL, NULL, seed, NULL); -} - -void ARC4::UpdateData(int len, uint8 *data) -{ - int outlen = 0; - EVP_EncryptUpdate(&m_ctx, data, &outlen, data, len); - EVP_EncryptFinal_ex(&m_ctx, data, &outlen); -} diff --git a/src/server/shared/Cryptography/ARC4.h b/src/server/shared/Cryptography/ARC4.h deleted file mode 100644 index 16a0cb92eb9..00000000000 --- a/src/server/shared/Cryptography/ARC4.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2008-2015 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef _AUTH_SARC4_H -#define _AUTH_SARC4_H - -#include -#include "Define.h" - -class ARC4 -{ - public: - ARC4(uint8 len); - ARC4(uint8 *seed, uint8 len); - ~ARC4(); - void Init(uint8 *seed); - void UpdateData(int len, uint8 *data); - private: - EVP_CIPHER_CTX m_ctx; -}; - -#endif diff --git a/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp b/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp deleted file mode 100644 index 153726e6950..00000000000 --- a/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2008-2015 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "AuthCrypt.h" -#include "Cryptography/HMACSHA1.h" -#include "Cryptography/BigNumber.h" - -#include - -AuthCrypt::AuthCrypt() : - _clientDecrypt(SHA_DIGEST_LENGTH), _serverEncrypt(SHA_DIGEST_LENGTH), - _initialized(false) -{ } - -void AuthCrypt::Init(BigNumber* K) -{ - uint8 ServerEncryptionKey[SEED_KEY_SIZE] = { 0xCC, 0x98, 0xAE, 0x04, 0xE8, 0x97, 0xEA, 0xCA, 0x12, 0xDD, 0xC0, 0x93, 0x42, 0x91, 0x53, 0x57 }; - HmacHash serverEncryptHmac(SEED_KEY_SIZE, (uint8*)ServerEncryptionKey); - uint8 *encryptHash = serverEncryptHmac.ComputeHash(K); - - uint8 ServerDecryptionKey[SEED_KEY_SIZE] = { 0xC2, 0xB3, 0x72, 0x3C, 0xC6, 0xAE, 0xD9, 0xB5, 0x34, 0x3C, 0x53, 0xEE, 0x2F, 0x43, 0x67, 0xCE }; - HmacHash clientDecryptHmac(SEED_KEY_SIZE, (uint8*)ServerDecryptionKey); - uint8 *decryptHash = clientDecryptHmac.ComputeHash(K); - - //ARC4 _serverDecrypt(encryptHash); - _clientDecrypt.Init(decryptHash); - _serverEncrypt.Init(encryptHash); - //ARC4 _clientEncrypt(decryptHash); - - // Drop first 1024 bytes, as WoW uses ARC4-drop1024. - uint8 syncBuf[1024]; - memset(syncBuf, 0, 1024); - - _serverEncrypt.UpdateData(1024, syncBuf); - //_clientEncrypt.UpdateData(1024, syncBuf); - - memset(syncBuf, 0, 1024); - - //_serverDecrypt.UpdateData(1024, syncBuf); - _clientDecrypt.UpdateData(1024, syncBuf); - - _initialized = true; -} - -void AuthCrypt::DecryptRecv(uint8 *data, size_t len) -{ - if (!_initialized) - return; - - _clientDecrypt.UpdateData(len, data); -} - -void AuthCrypt::EncryptSend(uint8 *data, size_t len) -{ - if (!_initialized) - return; - - _serverEncrypt.UpdateData(len, data); -} - diff --git a/src/server/shared/Cryptography/Authentication/AuthCrypt.h b/src/server/shared/Cryptography/Authentication/AuthCrypt.h deleted file mode 100644 index b8913c95a2c..00000000000 --- a/src/server/shared/Cryptography/Authentication/AuthCrypt.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2008-2015 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef _AUTHCRYPT_H -#define _AUTHCRYPT_H - -#include "Cryptography/ARC4.h" - -class BigNumber; - -class AuthCrypt -{ - public: - AuthCrypt(); - - void Init(BigNumber* K); - void DecryptRecv(uint8 *, size_t); - void EncryptSend(uint8 *, size_t); - - bool IsInitialized() const { return _initialized; } - - private: - ARC4 _clientDecrypt; - ARC4 _serverEncrypt; - bool _initialized; -}; -#endif diff --git a/src/server/shared/Cryptography/BigNumber.cpp b/src/server/shared/Cryptography/BigNumber.cpp deleted file mode 100644 index 720e8e30441..00000000000 --- a/src/server/shared/Cryptography/BigNumber.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (C) 2008-2015 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "Cryptography/BigNumber.h" -#include -#include -#include -#include - -BigNumber::BigNumber() - : _bn(BN_new()) -{ } - -BigNumber::BigNumber(BigNumber const& bn) - : _bn(BN_dup(bn._bn)) -{ } - -BigNumber::BigNumber(uint32 val) - : _bn(BN_new()) -{ - BN_set_word(_bn, val); -} - -BigNumber::~BigNumber() -{ - BN_free(_bn); -} - -void BigNumber::SetDword(uint32 val) -{ - BN_set_word(_bn, val); -} - -void BigNumber::SetQword(uint64 val) -{ - BN_set_word(_bn, (uint32)(val >> 32)); - BN_lshift(_bn, _bn, 32); - BN_add_word(_bn, (uint32)(val & 0xFFFFFFFF)); -} - -void BigNumber::SetBinary(uint8 const* bytes, int32 len) -{ - uint8* array = new uint8[len]; - - for (int i = 0; i < len; i++) - array[i] = bytes[len - 1 - i]; - - BN_bin2bn(array, len, _bn); - - delete[] array; -} - -void BigNumber::SetHexStr(char const* str) -{ - BN_hex2bn(&_bn, str); -} - -void BigNumber::SetRand(int32 numbits) -{ - BN_rand(_bn, numbits, 0, 1); -} - -BigNumber& BigNumber::operator=(BigNumber const& bn) -{ - if (this == &bn) - return *this; - - BN_copy(_bn, bn._bn); - return *this; -} - -BigNumber BigNumber::operator+=(BigNumber const& bn) -{ - BN_add(_bn, _bn, bn._bn); - return *this; -} - -BigNumber BigNumber::operator-=(BigNumber const& bn) -{ - BN_sub(_bn, _bn, bn._bn); - return *this; -} - -BigNumber BigNumber::operator*=(BigNumber const& bn) -{ - BN_CTX *bnctx; - - bnctx = BN_CTX_new(); - BN_mul(_bn, _bn, bn._bn, bnctx); - BN_CTX_free(bnctx); - - return *this; -} - -BigNumber BigNumber::operator/=(BigNumber const& bn) -{ - BN_CTX *bnctx; - - bnctx = BN_CTX_new(); - BN_div(_bn, NULL, _bn, bn._bn, bnctx); - BN_CTX_free(bnctx); - - return *this; -} - -BigNumber BigNumber::operator%=(BigNumber const& bn) -{ - BN_CTX *bnctx; - - bnctx = BN_CTX_new(); - BN_mod(_bn, _bn, bn._bn, bnctx); - BN_CTX_free(bnctx); - - return *this; -} - -BigNumber BigNumber::Exp(BigNumber const& bn) -{ - BigNumber ret; - BN_CTX *bnctx; - - bnctx = BN_CTX_new(); - BN_exp(ret._bn, _bn, bn._bn, bnctx); - BN_CTX_free(bnctx); - - return ret; -} - -BigNumber BigNumber::ModExp(BigNumber const& bn1, BigNumber const& bn2) -{ - BigNumber ret; - BN_CTX *bnctx; - - bnctx = BN_CTX_new(); - BN_mod_exp(ret._bn, _bn, bn1._bn, bn2._bn, bnctx); - BN_CTX_free(bnctx); - - return ret; -} - -int32 BigNumber::GetNumBytes(void) -{ - return BN_num_bytes(_bn); -} - -uint32 BigNumber::AsDword() -{ - return (uint32)BN_get_word(_bn); -} - -bool BigNumber::isZero() const -{ - return BN_is_zero(_bn); -} - -std::unique_ptr BigNumber::AsByteArray(int32 minSize, bool littleEndian) -{ - int numBytes = GetNumBytes(); - int length = (minSize >= numBytes) ? minSize : numBytes; - - uint8* array = new uint8[length]; - - // If we need more bytes than length of BigNumber set the rest to 0 - if (length > numBytes) - memset((void*)array, 0, length); - - BN_bn2bin(_bn, (unsigned char *)array); - - // openssl's BN stores data internally in big endian format, reverse if little endian desired - if (littleEndian) - std::reverse(array, array + numBytes); - - std::unique_ptr ret(array); - return ret; -} - -char * BigNumber::AsHexStr() const -{ - return BN_bn2hex(_bn); -} - -char * BigNumber::AsDecStr() const -{ - return BN_bn2dec(_bn); -} - diff --git a/src/server/shared/Cryptography/BigNumber.h b/src/server/shared/Cryptography/BigNumber.h deleted file mode 100644 index e6a056b5baa..00000000000 --- a/src/server/shared/Cryptography/BigNumber.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2008-2015 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef _AUTH_BIGNUMBER_H -#define _AUTH_BIGNUMBER_H - -#include -#include "Define.h" - -struct bignum_st; - -class BigNumber -{ - public: - BigNumber(); - BigNumber(BigNumber const& bn); - BigNumber(uint32); - ~BigNumber(); - - void SetDword(uint32); - void SetQword(uint64); - void SetBinary(uint8 const* bytes, int32 len); - void SetHexStr(char const* str); - - void SetRand(int32 numbits); - - BigNumber& operator=(BigNumber const& bn); - - BigNumber operator+=(BigNumber const& bn); - BigNumber operator+(BigNumber const& bn) - { - BigNumber t(*this); - return t += bn; - } - - BigNumber operator-=(BigNumber const& bn); - BigNumber operator-(BigNumber const& bn) - { - BigNumber t(*this); - return t -= bn; - } - - BigNumber operator*=(BigNumber const& bn); - BigNumber operator*(BigNumber const& bn) - { - BigNumber t(*this); - return t *= bn; - } - - BigNumber operator/=(BigNumber const& bn); - BigNumber operator/(BigNumber const& bn) - { - BigNumber t(*this); - return t /= bn; - } - - BigNumber operator%=(BigNumber const& bn); - BigNumber operator%(BigNumber const& bn) - { - BigNumber t(*this); - return t %= bn; - } - - bool isZero() const; - - BigNumber ModExp(BigNumber const& bn1, BigNumber const& bn2); - BigNumber Exp(BigNumber const&); - - int32 GetNumBytes(void); - - struct bignum_st *BN() { return _bn; } - - uint32 AsDword(); - - std::unique_ptr AsByteArray(int32 minSize = 0, bool littleEndian = true); - - char * AsHexStr() const; - char * AsDecStr() const; - - private: - struct bignum_st *_bn; - -}; -#endif - diff --git a/src/server/shared/Cryptography/HMACSHA1.cpp b/src/server/shared/Cryptography/HMACSHA1.cpp deleted file mode 100644 index 304633cbc03..00000000000 --- a/src/server/shared/Cryptography/HMACSHA1.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2008-2015 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "HMACSHA1.h" -#include "BigNumber.h" -#include "Common.h" - -HmacHash::HmacHash(uint32 len, uint8 *seed) -{ - HMAC_CTX_init(&m_ctx); - HMAC_Init_ex(&m_ctx, seed, len, EVP_sha1(), NULL); - memset(m_digest, 0, sizeof(m_digest)); -} - -HmacHash::~HmacHash() -{ - HMAC_CTX_cleanup(&m_ctx); -} - -void HmacHash::UpdateData(const std::string &str) -{ - HMAC_Update(&m_ctx, (uint8 const*)str.c_str(), str.length()); -} - -void HmacHash::UpdateData(const uint8* data, size_t len) -{ - HMAC_Update(&m_ctx, data, len); -} - -void HmacHash::Finalize() -{ - uint32 length = 0; - HMAC_Final(&m_ctx, (uint8*)m_digest, &length); - ASSERT(length == SHA_DIGEST_LENGTH); -} - -uint8 *HmacHash::ComputeHash(BigNumber* bn) -{ - HMAC_Update(&m_ctx, bn->AsByteArray().get(), bn->GetNumBytes()); - Finalize(); - return (uint8*)m_digest; -} diff --git a/src/server/shared/Cryptography/HMACSHA1.h b/src/server/shared/Cryptography/HMACSHA1.h deleted file mode 100644 index 66cf214d9b1..00000000000 --- a/src/server/shared/Cryptography/HMACSHA1.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2008-2015 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef _AUTH_HMAC_H -#define _AUTH_HMAC_H - -#include "Define.h" -#include -#include -#include - -class BigNumber; - -#define SEED_KEY_SIZE 16 - -class HmacHash -{ - public: - HmacHash(uint32 len, uint8 *seed); - ~HmacHash(); - void UpdateData(const std::string &str); - void UpdateData(const uint8* data, size_t len); - void Finalize(); - uint8 *ComputeHash(BigNumber* bn); - uint8 *GetDigest() { return (uint8*)m_digest; } - int GetLength() const { return SHA_DIGEST_LENGTH; } - private: - HMAC_CTX m_ctx; - uint8 m_digest[SHA_DIGEST_LENGTH]; -}; -#endif - diff --git a/src/server/shared/Cryptography/OpenSSLCrypto.cpp b/src/server/shared/Cryptography/OpenSSLCrypto.cpp deleted file mode 100644 index f122888292f..00000000000 --- a/src/server/shared/Cryptography/OpenSSLCrypto.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2008-2015 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include -#include -#include -#include -#include - -std::vector cryptoLocks; - -static void lockingCallback(int mode, int type, const char* /*file*/, int /*line*/) -{ - if (mode & CRYPTO_LOCK) - cryptoLocks[type]->lock(); - else - cryptoLocks[type]->unlock(); -} - -static void threadIdCallback(CRYPTO_THREADID * id) -{ - CRYPTO_THREADID_set_numeric(id, std::hash()(std::this_thread::get_id())); -} - -void OpenSSLCrypto::threadsSetup() -{ - cryptoLocks.resize(CRYPTO_num_locks()); - for(int i = 0 ; i < CRYPTO_num_locks(); ++i) - { - cryptoLocks[i] = new std::mutex; - } - CRYPTO_THREADID_set_callback(threadIdCallback); - CRYPTO_set_locking_callback(lockingCallback); -} - -void OpenSSLCrypto::threadsCleanup() -{ - CRYPTO_set_locking_callback(NULL); - CRYPTO_THREADID_set_callback(NULL); - for(int i = 0 ; i < CRYPTO_num_locks(); ++i) - { - delete cryptoLocks[i]; - } - cryptoLocks.resize(0); -} diff --git a/src/server/shared/Cryptography/OpenSSLCrypto.h b/src/server/shared/Cryptography/OpenSSLCrypto.h deleted file mode 100644 index 0daa20c4780..00000000000 --- a/src/server/shared/Cryptography/OpenSSLCrypto.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2008-2015 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef OPENSSL_CRYPTO_H -#define OPENSSL_CRYPTO_H - -/** -* A group of functions which setup openssl crypto module to work properly in multithreaded enviroment -* If not setup properly - it will crash -*/ -namespace OpenSSLCrypto -{ - /// Needs to be called before threads using openssl are spawned - void threadsSetup(); - /// Needs to be called after threads using openssl are despawned - void threadsCleanup(); -} - -#endif \ No newline at end of file diff --git a/src/server/shared/Cryptography/SHA1.cpp b/src/server/shared/Cryptography/SHA1.cpp deleted file mode 100644 index bd7101075de..00000000000 --- a/src/server/shared/Cryptography/SHA1.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2008-2015 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "SHA1.h" -#include "BigNumber.h" -#include -#include - -SHA1Hash::SHA1Hash() -{ - SHA1_Init(&mC); - memset(mDigest, 0, SHA_DIGEST_LENGTH * sizeof(uint8)); -} - -SHA1Hash::~SHA1Hash() -{ - SHA1_Init(&mC); -} - -void SHA1Hash::UpdateData(const uint8 *dta, int len) -{ - SHA1_Update(&mC, dta, len); -} - -void SHA1Hash::UpdateData(const std::string &str) -{ - UpdateData((uint8 const*)str.c_str(), str.length()); -} - -void SHA1Hash::UpdateBigNumbers(BigNumber* bn0, ...) -{ - va_list v; - BigNumber* bn; - - va_start(v, bn0); - bn = bn0; - while (bn) - { - UpdateData(bn->AsByteArray().get(), bn->GetNumBytes()); - bn = va_arg(v, BigNumber*); - } - va_end(v); -} - -void SHA1Hash::Initialize() -{ - SHA1_Init(&mC); -} - -void SHA1Hash::Finalize(void) -{ - SHA1_Final(mDigest, &mC); -} - diff --git a/src/server/shared/Cryptography/SHA1.h b/src/server/shared/Cryptography/SHA1.h deleted file mode 100644 index f59bdc25556..00000000000 --- a/src/server/shared/Cryptography/SHA1.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2008-2015 TrinityCore - * Copyright (C) 2005-2009 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef _AUTH_SHA1_H -#define _AUTH_SHA1_H - -#include "Define.h" -#include -#include - -class BigNumber; - -class SHA1Hash -{ - public: - SHA1Hash(); - ~SHA1Hash(); - - void UpdateBigNumbers(BigNumber* bn0, ...); - - void UpdateData(const uint8 *dta, int len); - void UpdateData(const std::string &str); - - void Initialize(); - void Finalize(); - - uint8 *GetDigest(void) { return mDigest; } - int GetLength(void) const { return SHA_DIGEST_LENGTH; } - - private: - SHA_CTX mC; - uint8 mDigest[SHA_DIGEST_LENGTH]; -}; -#endif - diff --git a/src/server/shared/Cryptography/WardenKeyGeneration.h b/src/server/shared/Cryptography/WardenKeyGeneration.h deleted file mode 100644 index bfa0337d347..00000000000 --- a/src/server/shared/Cryptography/WardenKeyGeneration.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2008-2015 TrinityCore - * Copyright (C) 2005-2011 MaNGOS - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "SHA1.h" - -#include - -#ifndef _WARDEN_KEY_GENERATION_H -#define _WARDEN_KEY_GENERATION_H - -class SHA1Randx -{ -public: - SHA1Randx(uint8* buff, uint32 size) - { - uint32 halfSize = size / 2; - - sh.Initialize(); - sh.UpdateData(buff, halfSize); - sh.Finalize(); - - memcpy(o1, sh.GetDigest(), 20); - - sh.Initialize(); - sh.UpdateData(buff + halfSize, size - halfSize); - sh.Finalize(); - - memcpy(o2, sh.GetDigest(), 20); - - memset(o0, 0x00, 20); - - FillUp(); - } - - void Generate(uint8* buf, uint32 sz) - { - for (uint32 i = 0; i < sz; ++i) - { - if (taken == 20) - FillUp(); - - buf[i] = o0[taken]; - taken++; - } - } - -private: - void FillUp() - { - sh.Initialize(); - sh.UpdateData(o1, 20); - sh.UpdateData(o0, 20); - sh.UpdateData(o2, 20); - sh.Finalize(); - - memcpy(o0, sh.GetDigest(), 20); - - taken = 0; - } - - SHA1Hash sh; - uint32 taken; - uint8 o0[20], o1[20], o2[20]; -}; - -#endif diff --git a/src/server/shared/GitRevision.cpp b/src/server/shared/GitRevision.cpp deleted file mode 100644 index 0986e13b68f..00000000000 --- a/src/server/shared/GitRevision.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "GitRevision.h" -#include "CompilerDefs.h" -#include "revision_data.h" - -char const* GitRevision::GetHash() -{ - return _HASH; -} - -char const* GitRevision::GetDate() -{ - return _DATE; -} - -char const* GitRevision::GetBranch() -{ - return _BRANCH; -} - -char const* GitRevision::GetSourceDirectory() -{ - return _SOURCE_DIRECTORY; -} - -char const* GitRevision::GetMySQLExecutable() -{ - return _MYSQL_EXECUTABLE; -} - -char const* GitRevision::GetFullDatabase() -{ - return _FULL_DATABASE; -} - -#define _PACKAGENAME "TrinityCore" - -char const* GitRevision::GetFullVersion() -{ -#if PLATFORM == PLATFORM_WINDOWS -# ifdef _WIN64 - return _PACKAGENAME " rev. " VER_PRODUCTVERSION_STR " (Win64, " _BUILD_DIRECTIVE ")"; -# else - return _PACKAGENAME " rev. " VER_PRODUCTVERSION_STR " (Win32, " _BUILD_DIRECTIVE ")"; -# endif -#else - return _PACKAGENAME " rev. " VER_PRODUCTVERSION_STR " (Unix, " _BUILD_DIRECTIVE ")"; -#endif -} - -char const* GitRevision::GetCompanyNameStr() -{ - return VER_COMPANYNAME_STR; -} - -char const* GitRevision::GetLegalCopyrightStr() -{ - return VER_LEGALCOPYRIGHT_STR; -} - -char const* GitRevision::GetFileVersionStr() -{ - return VER_FILEVERSION_STR; -} - -char const* GitRevision::GetProductVersionStr() -{ - return VER_PRODUCTVERSION_STR; -} diff --git a/src/server/shared/GitRevision.h b/src/server/shared/GitRevision.h deleted file mode 100644 index ce941170083..00000000000 --- a/src/server/shared/GitRevision.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2008-2015 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef __GITREVISION_H__ -#define __GITREVISION_H__ - -#include - -namespace GitRevision -{ - char const* GetHash(); - char const* GetDate(); - char const* GetBranch(); - char const* GetSourceDirectory(); - char const* GetMySQLExecutable(); - char const* GetFullDatabase(); - char const* GetFullVersion(); - char const* GetCompanyNameStr(); - char const* GetLegalCopyrightStr(); - char const* GetFileVersionStr(); - char const* GetProductVersionStr(); -} - -#endif diff --git a/src/server/worldserver/CMakeLists.txt b/src/server/worldserver/CMakeLists.txt index f513ba0857f..78f39e077a1 100644 --- a/src/server/worldserver/CMakeLists.txt +++ b/src/server/worldserver/CMakeLists.txt @@ -41,72 +41,48 @@ endif() include_directories( ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/CommandLine + ${CMAKE_CURRENT_SOURCE_DIR}/RemoteAccess + ${CMAKE_CURRENT_SOURCE_DIR}/TCSoap + ${CMAKE_SOURCE_DIR}/dep/cppformat ${CMAKE_SOURCE_DIR}/dep/g3dlite/include - ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour - ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour/Include ${CMAKE_SOURCE_DIR}/dep/gsoap - ${CMAKE_SOURCE_DIR}/dep/sockets/include - ${CMAKE_SOURCE_DIR}/dep/SFMT - ${CMAKE_SOURCE_DIR}/dep/cppformat - ${CMAKE_SOURCE_DIR}/dep/process - ${CMAKE_SOURCE_DIR}/src/server/database - ${CMAKE_SOURCE_DIR}/src/server/database/Database - ${CMAKE_SOURCE_DIR}/src/server/database/Logging - ${CMAKE_SOURCE_DIR}/src/server/database/Updater + ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour/Include + ${CMAKE_SOURCE_DIR}/src/common/ ${CMAKE_SOURCE_DIR}/src/common/Collision - ${CMAKE_SOURCE_DIR}/src/common/Collision/Management ${CMAKE_SOURCE_DIR}/src/common/Collision/Models ${CMAKE_SOURCE_DIR}/src/common/Configuration - ${CMAKE_SOURCE_DIR}/src/server/shared - ${CMAKE_SOURCE_DIR}/src/server/shared/Cryptography - ${CMAKE_SOURCE_DIR}/src/server/shared/Cryptography/Authentication - ${CMAKE_SOURCE_DIR}/src/server/shared/DataStores - ${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic/LinkedReference - ${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic - ${CMAKE_SOURCE_DIR}/src/server/shared/Networking - ${CMAKE_SOURCE_DIR}/src/server/shared/Packets - ${CMAKE_SOURCE_DIR}/src/server/shared/Service + ${CMAKE_SOURCE_DIR}/src/common/Cryptography + ${CMAKE_SOURCE_DIR}/src/common/Cryptography/Authentication + ${CMAKE_SOURCE_DIR}/src/common/Debugging + ${CMAKE_SOURCE_DIR}/src/common/Logging + ${CMAKE_SOURCE_DIR}/src/common/Threading + ${CMAKE_SOURCE_DIR}/src/common/Utilities + ${CMAKE_SOURCE_DIR}/src/server/authserver/Realms + ${CMAKE_SOURCE_DIR}/src/server/database/ + ${CMAKE_SOURCE_DIR}/src/server/database/Database + ${CMAKE_SOURCE_DIR}/src/server/database/Logging ${CMAKE_SOURCE_DIR}/src/server/game ${CMAKE_SOURCE_DIR}/src/server/game/Accounts - ${CMAKE_SOURCE_DIR}/src/server/game/Achievements ${CMAKE_SOURCE_DIR}/src/server/game/Addons - ${CMAKE_SOURCE_DIR}/src/server/game/AI - ${CMAKE_SOURCE_DIR}/src/server/game/AI/CoreAI - ${CMAKE_SOURCE_DIR}/src/server/game/AI/ScriptedAI - ${CMAKE_SOURCE_DIR}/src/server/game/AI/SmartScripts - ${CMAKE_SOURCE_DIR}/src/server/game/AuctionHouse - ${CMAKE_SOURCE_DIR}/src/server/game/AuctionHouse/AuctionHouseBot ${CMAKE_SOURCE_DIR}/src/server/game/Battlegrounds - ${CMAKE_SOURCE_DIR}/src/server/game/Battlegrounds/Zones - ${CMAKE_SOURCE_DIR}/src/server/game/Calendar ${CMAKE_SOURCE_DIR}/src/server/game/Chat - ${CMAKE_SOURCE_DIR}/src/server/game/Chat/Channels ${CMAKE_SOURCE_DIR}/src/server/game/Combat ${CMAKE_SOURCE_DIR}/src/server/game/Conditions ${CMAKE_SOURCE_DIR}/src/server/game/DataStores - ${CMAKE_SOURCE_DIR}/src/server/game/DungeonFinding - ${CMAKE_SOURCE_DIR}/src/server/game/Entities - ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Creature ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Corpse + ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Creature ${CMAKE_SOURCE_DIR}/src/server/game/Entities/DynamicObject ${CMAKE_SOURCE_DIR}/src/server/game/Entities/GameObject ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Item ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Item/Container ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Object ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Object/Updates - ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Pet - ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Player - ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Totem ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Unit ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Vehicle - ${CMAKE_SOURCE_DIR}/src/server/game/Entities/Transport - ${CMAKE_SOURCE_DIR}/src/server/game/Events ${CMAKE_SOURCE_DIR}/src/server/game/Globals - ${CMAKE_SOURCE_DIR}/src/server/game/Grids/Cells - ${CMAKE_SOURCE_DIR}/src/server/game/Grids/Notifiers ${CMAKE_SOURCE_DIR}/src/server/game/Grids - ${CMAKE_SOURCE_DIR}/src/server/game/Groups - ${CMAKE_SOURCE_DIR}/src/server/game/Guilds + ${CMAKE_SOURCE_DIR}/src/server/game/Grids/Cells ${CMAKE_SOURCE_DIR}/src/server/game/Handlers ${CMAKE_SOURCE_DIR}/src/server/game/Instances ${CMAKE_SOURCE_DIR}/src/server/game/Loot @@ -114,38 +90,21 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/server/game/Maps ${CMAKE_SOURCE_DIR}/src/server/game/Miscellaneous ${CMAKE_SOURCE_DIR}/src/server/game/Movement - ${CMAKE_SOURCE_DIR}/src/server/game/Movement/MovementGenerators ${CMAKE_SOURCE_DIR}/src/server/game/Movement/Waypoints - ${CMAKE_SOURCE_DIR}/src/server/game/OutdoorPvP - ${CMAKE_SOURCE_DIR}/src/server/game/Pools - ${CMAKE_SOURCE_DIR}/src/server/game/PrecompiledHeaders ${CMAKE_SOURCE_DIR}/src/server/game/Quests - ${CMAKE_SOURCE_DIR}/src/server/game/Reputation ${CMAKE_SOURCE_DIR}/src/server/game/Scripting - ${CMAKE_SOURCE_DIR}/src/server/game/Server/Protocol ${CMAKE_SOURCE_DIR}/src/server/game/Server - ${CMAKE_SOURCE_DIR}/src/server/game/Skills - ${CMAKE_SOURCE_DIR}/src/server/game/Spells + ${CMAKE_SOURCE_DIR}/src/server/game/Server/Protocol ${CMAKE_SOURCE_DIR}/src/server/game/Spells/Auras - ${CMAKE_SOURCE_DIR}/src/server/game/Tools - ${CMAKE_SOURCE_DIR}/src/server/game/Warden - ${CMAKE_SOURCE_DIR}/src/server/game/Warden/Modules ${CMAKE_SOURCE_DIR}/src/server/game/Weather ${CMAKE_SOURCE_DIR}/src/server/game/World - ${CMAKE_SOURCE_DIR}/src/server/authserver/Server - ${CMAKE_SOURCE_DIR}/src/server/authserver/Realms - ${CMAKE_SOURCE_DIR}/src/common/ - ${CMAKE_SOURCE_DIR}/src/common/Collision - ${CMAKE_SOURCE_DIR}/src/common/Collision/Management - ${CMAKE_SOURCE_DIR}/src/common/Collision/Models - ${CMAKE_SOURCE_DIR}/src/common/Debugging - ${CMAKE_SOURCE_DIR}/src/common/Utilities - ${CMAKE_SOURCE_DIR}/src/common/Threading - ${CMAKE_SOURCE_DIR}/src/common/Logging - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/CommandLine - ${CMAKE_CURRENT_SOURCE_DIR}/RemoteAccess - ${CMAKE_CURRENT_SOURCE_DIR}/TCSoap + ${CMAKE_SOURCE_DIR}/src/server/shared + ${CMAKE_SOURCE_DIR}/src/server/shared/DataStores + ${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic + ${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic/LinkedReference + ${CMAKE_SOURCE_DIR}/src/server/shared/Networking + ${CMAKE_SOURCE_DIR}/src/server/shared/Packets + ${CMAKE_SOURCE_DIR}/src/server/shared/Service ${MYSQL_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${VALGRIND_INCLUDE_DIR} -- cgit v1.2.3