mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/BuildSystem: Merged crypto into common, cleaned include directory lists (to mimic 3.x buildsystem)
This commit is contained in:
@@ -51,30 +51,16 @@ 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_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/src/common/
|
||||
${CMAKE_SOURCE_DIR}/src/common/Configuration
|
||||
${CMAKE_SOURCE_DIR}/src/common/Cryptography
|
||||
${CMAKE_SOURCE_DIR}/src/server/database/
|
||||
${CMAKE_SOURCE_DIR}/src/server/database/Database
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DataStores
|
||||
${CMAKE_SOURCE_DIR}/src/common/Debugging
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Dynamic
|
||||
${CMAKE_SOURCE_DIR}/src/common/Logging
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Networking
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Packets
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Realm
|
||||
${CMAKE_SOURCE_DIR}/dep/cppformat
|
||||
${CMAKE_SOURCE_DIR}/src/common/
|
||||
${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/Updater
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Entities/Object
|
||||
${CMAKE_SOURCE_DIR}/src/server/database
|
||||
${CMAKE_SOURCE_DIR}/src/server/database/Database
|
||||
${MYSQL_INCLUDE_DIR}
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
${VALGRIND_INCLUDE_DIR}
|
||||
|
||||
@@ -1,39 +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 "PacketCrypt.h"
|
||||
|
||||
PacketCrypt::PacketCrypt(uint32 rc4InitSize)
|
||||
: _clientDecrypt(rc4InitSize), _serverEncrypt(rc4InitSize), _initialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
void PacketCrypt::DecryptRecv(uint8* data, size_t len)
|
||||
{
|
||||
if (!_initialized)
|
||||
return;
|
||||
|
||||
_clientDecrypt.UpdateData(len, data);
|
||||
}
|
||||
|
||||
void PacketCrypt::EncryptSend(uint8* data, size_t len)
|
||||
{
|
||||
if (!_initialized)
|
||||
return;
|
||||
|
||||
_serverEncrypt.UpdateData(len, data);
|
||||
}
|
||||
@@ -1,43 +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 _PACKETCRYPT_H
|
||||
#define _PACKETCRYPT_H
|
||||
|
||||
#include "Cryptography/ARC4.h"
|
||||
|
||||
class BigNumber;
|
||||
|
||||
class PacketCrypt
|
||||
{
|
||||
public:
|
||||
PacketCrypt(uint32 rc4InitSize);
|
||||
virtual ~PacketCrypt() { }
|
||||
|
||||
virtual void Init(BigNumber* K) = 0;
|
||||
void DecryptRecv(uint8* data, size_t length);
|
||||
void EncryptSend(uint8* data, size_t length);
|
||||
|
||||
bool IsInitialized() const { return _initialized; }
|
||||
|
||||
protected:
|
||||
ARC4 _clientDecrypt;
|
||||
ARC4 _serverEncrypt;
|
||||
bool _initialized;
|
||||
};
|
||||
|
||||
#endif // _PACKETCRYPT_H
|
||||
@@ -1,58 +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 "WorldPacketCrypt.h"
|
||||
#include "Cryptography/HmacHash.h"
|
||||
#include "Cryptography/BigNumber.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
WorldPacketCrypt::WorldPacketCrypt() : PacketCrypt(SHA_DIGEST_LENGTH)
|
||||
{
|
||||
}
|
||||
|
||||
void WorldPacketCrypt::Init(BigNumber* K)
|
||||
{
|
||||
uint8 ServerEncryptionKey[SEED_KEY_SIZE] = { 0x08, 0xF1, 0x95, 0x9F, 0x47, 0xE5, 0xD2, 0xDB, 0xA1, 0x3D, 0x77, 0x8F, 0x3F, 0x3E, 0xE7, 0x00 };
|
||||
uint8 ServerDecryptionKey[SEED_KEY_SIZE] = { 0x40, 0xAA, 0xD3, 0x92, 0x26, 0x71, 0x43, 0x47, 0x3A, 0x31, 0x08, 0xA6, 0xE7, 0xDC, 0x98, 0x2A };
|
||||
Init(K, ServerEncryptionKey, ServerDecryptionKey);
|
||||
}
|
||||
|
||||
void WorldPacketCrypt::Init(BigNumber* k, uint8 const* serverKey, uint8 const* clientKey)
|
||||
{
|
||||
HmacSha1 serverEncryptHmac(SEED_KEY_SIZE, (uint8*)serverKey);
|
||||
uint8 *encryptHash = serverEncryptHmac.ComputeHash(k);
|
||||
|
||||
HmacSha1 clientDecryptHmac(SEED_KEY_SIZE, (uint8*)clientKey);
|
||||
uint8 *decryptHash = clientDecryptHmac.ComputeHash(k);
|
||||
|
||||
_clientDecrypt.Init(decryptHash);
|
||||
_serverEncrypt.Init(encryptHash);
|
||||
|
||||
// Drop first 1024 bytes, as WoW uses ARC4-drop1024.
|
||||
uint8 syncBuf[1024];
|
||||
memset(syncBuf, 0, 1024);
|
||||
|
||||
_serverEncrypt.UpdateData(1024, syncBuf);
|
||||
|
||||
memset(syncBuf, 0, 1024);
|
||||
|
||||
_clientDecrypt.UpdateData(1024, syncBuf);
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
@@ -1,35 +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 _WORLDPACKETCRYPT_H
|
||||
#define _WORLDPACKETCRYPT_H
|
||||
|
||||
#include "PacketCrypt.h"
|
||||
|
||||
class BigNumber;
|
||||
|
||||
class WorldPacketCrypt : public PacketCrypt
|
||||
{
|
||||
public:
|
||||
WorldPacketCrypt();
|
||||
|
||||
void Init(BigNumber* K) override;
|
||||
void Init(BigNumber* k, uint8 const* serverKey, uint8 const* clientKey);
|
||||
};
|
||||
|
||||
#endif // _WORLDPACKETCRYPT_H
|
||||
Reference in New Issue
Block a user