diff options
| author | StormBytePP <stormbyte@gmail.com> | 2015-08-23 23:20:09 +0200 |
|---|---|---|
| committer | StormBytePP <stormbyte@gmail.com> | 2015-08-24 03:38:54 +0200 |
| commit | 405f823f68621352e48810c33f1f9dbd36904ff8 (patch) | |
| tree | bedb57ef459c8c17d690253160e4f9d2a40a1b0b /src/server/shared | |
| parent | 603f49a55134de21b6c02b3cfcd9cb32b44c5f7b (diff) | |
Core/BuildSystem: Merged crypto and gitrevision into common, cleaned include directory lists (to mimic 6.x buildsystem)
Diffstat (limited to 'src/server/shared')
| -rw-r--r-- | src/server/shared/CMakeLists.txt | 25 | ||||
| -rw-r--r-- | src/server/shared/Cryptography/ARC4.cpp | 51 | ||||
| -rw-r--r-- | src/server/shared/Cryptography/ARC4.h | 37 | ||||
| -rw-r--r-- | src/server/shared/Cryptography/Authentication/AuthCrypt.cpp | 75 | ||||
| -rw-r--r-- | src/server/shared/Cryptography/Authentication/AuthCrypt.h | 42 | ||||
| -rw-r--r-- | src/server/shared/Cryptography/BigNumber.cpp | 201 | ||||
| -rw-r--r-- | src/server/shared/Cryptography/BigNumber.h | 100 | ||||
| -rw-r--r-- | src/server/shared/Cryptography/HMACSHA1.cpp | 57 | ||||
| -rw-r--r-- | src/server/shared/Cryptography/HMACSHA1.h | 47 | ||||
| -rw-r--r-- | src/server/shared/Cryptography/OpenSSLCrypto.cpp | 59 | ||||
| -rw-r--r-- | src/server/shared/Cryptography/OpenSSLCrypto.h | 33 | ||||
| -rw-r--r-- | src/server/shared/Cryptography/SHA1.cpp | 69 | ||||
| -rw-r--r-- | src/server/shared/Cryptography/SHA1.h | 50 | ||||
| -rw-r--r-- | src/server/shared/Cryptography/WardenKeyGeneration.h | 81 | ||||
| -rw-r--r-- | src/server/shared/GitRevision.cpp | 68 | ||||
| -rw-r--r-- | src/server/shared/GitRevision.h | 38 |
16 files changed, 2 insertions, 1031 deletions
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 <http://www.trinitycore.org/> - * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#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 <http://www.trinitycore.org/> - * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef _AUTH_SARC4_H -#define _AUTH_SARC4_H - -#include <openssl/evp.h> -#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 <http://www.trinitycore.org/> - * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#include "AuthCrypt.h" -#include "Cryptography/HMACSHA1.h" -#include "Cryptography/BigNumber.h" - -#include <cstring> - -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 <http://www.trinitycore.org/> - * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#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 <http://www.trinitycore.org/> - * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#include "Cryptography/BigNumber.h" -#include <openssl/bn.h> -#include <cstring> -#include <algorithm> -#include <memory> - -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<uint8[]> 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<uint8[]> 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 <http://www.trinitycore.org/> - * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef _AUTH_BIGNUMBER_H -#define _AUTH_BIGNUMBER_H - -#include <memory> -#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<uint8[]> 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 <http://www.trinitycore.org/> - * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#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 <http://www.trinitycore.org/> - * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef _AUTH_HMAC_H -#define _AUTH_HMAC_H - -#include "Define.h" -#include <string> -#include <openssl/hmac.h> -#include <openssl/sha.h> - -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 <http://www.trinitycore.org/> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#include <OpenSSLCrypto.h> -#include <openssl/crypto.h> -#include <vector> -#include <thread> -#include <mutex> - -std::vector<std::mutex*> 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::thread::id>()(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 <http://www.trinitycore.org/> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#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 <http://www.trinitycore.org/> - * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#include "SHA1.h" -#include "BigNumber.h" -#include <cstring> -#include <stdarg.h> - -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 <http://www.trinitycore.org/> - * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef _AUTH_SHA1_H -#define _AUTH_SHA1_H - -#include "Define.h" -#include <string> -#include <openssl/sha.h> - -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 <http://www.trinitycore.org/> - * Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#include "SHA1.h" - -#include <cstring> - -#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 <http://www.trinitycore.org/> - * - * 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 <http://www.gnu.org/licenses/>. - */ - -#ifndef __GITREVISION_H__ -#define __GITREVISION_H__ - -#include <string> - -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 |
