mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-03-06 01:07:49 +00:00
feat(Core/Crypto): add support OpenSSL 3.0 (#13354)
This commit is contained in:
@@ -25,15 +25,12 @@
|
||||
#include "WardenModuleMac.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
#include <openssl/md5.h>
|
||||
|
||||
WardenMac::WardenMac() : Warden()
|
||||
{
|
||||
}
|
||||
|
||||
WardenMac::~WardenMac()
|
||||
{
|
||||
}
|
||||
WardenMac::~WardenMac() = default;
|
||||
|
||||
void WardenMac::Init(WorldSession* pClient, SessionKey const& K)
|
||||
{
|
||||
@@ -64,29 +61,21 @@ void WardenMac::Init(WorldSession* pClient, SessionKey const& K)
|
||||
|
||||
_module = GetModuleForClient();
|
||||
|
||||
LOG_DEBUG("warden", "Module Key: {}", Acore::Impl::ByteArrayToHexStr(_module->Key, 16));
|
||||
LOG_DEBUG("warden", "Module ID: {}", Acore::Impl::ByteArrayToHexStr(_module->Id, 16));
|
||||
LOG_DEBUG("warden", "Module Key: {}", ByteArrayToHexStr(_module->Key));
|
||||
LOG_DEBUG("warden", "Module ID: {}", ByteArrayToHexStr(_module->Id));
|
||||
RequestModule();
|
||||
}
|
||||
|
||||
ClientWardenModule* WardenMac::GetModuleForClient()
|
||||
{
|
||||
ClientWardenModule* mod = new ClientWardenModule;
|
||||
|
||||
uint32 len = sizeof(Module_0DBBF209A27B1E279A9FEC5C168A15F7_Data);
|
||||
auto mod = new ClientWardenModule;
|
||||
|
||||
// data assign
|
||||
mod->CompressedSize = len;
|
||||
mod->CompressedData = new uint8[len];
|
||||
memcpy(mod->CompressedData, Module_0DBBF209A27B1E279A9FEC5C168A15F7_Data, len);
|
||||
memcpy(mod->Key, Module_0DBBF209A27B1E279A9FEC5C168A15F7_Key, 16);
|
||||
mod->CompressedSize = Module_0DBBF209A27B1E279A9FEC5C168A15F7_Data.size();
|
||||
mod->CompressedData = Module_0DBBF209A27B1E279A9FEC5C168A15F7_Data.data();
|
||||
|
||||
// md5 hash
|
||||
MD5_CTX ctx;
|
||||
MD5_Init(&ctx);
|
||||
MD5_Update(&ctx, mod->CompressedData, len);
|
||||
MD5_Final((uint8*)&mod->Id, &ctx);
|
||||
|
||||
mod->Id = Acore::Crypto::MD5::GetDigestOf(mod->CompressedData, mod->CompressedSize);
|
||||
return mod;
|
||||
}
|
||||
|
||||
@@ -100,7 +89,7 @@ void WardenMac::RequestHash()
|
||||
LOG_DEBUG("warden", "Request hash");
|
||||
|
||||
// Create packet structure
|
||||
WardenHashRequest Request;
|
||||
WardenHashRequest Request{};
|
||||
Request.Command = WARDEN_SMSG_HASH_REQUEST;
|
||||
memcpy(Request.Seed, _seed, 16);
|
||||
|
||||
@@ -242,7 +231,7 @@ void WardenMac::HandleData(ByteBuffer& buff)
|
||||
sha1.UpdateData((uint8*)&magic, 4);
|
||||
sha1.Finalize();
|
||||
|
||||
std::array<uint8, Acore::Crypto::SHA1::DIGEST_LENGTH> sha1Hash;
|
||||
Acore::Crypto::SHA1::Digest sha1Hash{};
|
||||
buff.read(sha1Hash.data(), sha1Hash.size());
|
||||
|
||||
if (sha1Hash != sha1.GetDigest())
|
||||
@@ -251,20 +240,15 @@ void WardenMac::HandleData(ByteBuffer& buff)
|
||||
//found = true;
|
||||
}
|
||||
|
||||
MD5_CTX ctx;
|
||||
MD5_Init(&ctx);
|
||||
MD5_Update(&ctx, str.c_str(), str.size());
|
||||
uint8 ourMD5Hash[16];
|
||||
MD5_Final(ourMD5Hash, &ctx);
|
||||
auto ourMD5Hash = Acore::Crypto::MD5::GetDigestOf(str);
|
||||
Acore::Crypto::MD5::Digest theirsMD5Hash{};
|
||||
buff.read(theirsMD5Hash);
|
||||
|
||||
uint8 theirsMD5Hash[16];
|
||||
buff.read(theirsMD5Hash, 16);
|
||||
|
||||
if (memcmp(ourMD5Hash, theirsMD5Hash, 16))
|
||||
if (ourMD5Hash != theirsMD5Hash)
|
||||
{
|
||||
LOG_DEBUG("warden", "Handle data failed: MD5 hash is wrong!");
|
||||
//found = true;
|
||||
}
|
||||
|
||||
_session->KickPlayer("WardenMac");
|
||||
_session->KickPlayer("WardenMac::HandleData");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user