From 6694281f2243278f5517e97fd1e937a7f2dbd237 Mon Sep 17 00:00:00 2001 From: brainiac Date: Fri, 24 Apr 2026 23:05:32 -0700 Subject: [PATCH 01/10] Fix gcc warnings (#5071) --- CMakeLists.txt | 2 +- common/CMakeLists.txt | 1 + common/compiler_macros.h | 20 +++++++ common/json/jsoncpp.cpp | 8 --- libs/luabind/luabind/adopt_policy.hpp | 2 +- libs/luabind/luabind/class.hpp | 2 +- libs/luabind/luabind/detail/constructor.hpp | 8 +-- .../luabind/detail/has_get_pointer.hpp | 2 +- .../luabind/detail/instance_holder.hpp | 4 +- libs/luabind/luabind/detail/make_instance.hpp | 2 +- libs/luabind/luabind/detail/policy.hpp | 6 +- libs/luabind/luabind/function.hpp | 2 +- libs/luabind/luabind/scope.hpp | 2 +- libs/luabind/src/class.cpp | 10 ++-- libs/luabind/src/scope.cpp | 5 +- loginserver/encryption.cpp | 5 ++ zone/embparser.cpp | 56 ++++++++++--------- zone/lua_packet.cpp | 10 ++++ zone/lua_packet.h | 2 +- zone/lua_ptr.h | 3 +- 20 files changed, 94 insertions(+), 58 deletions(-) create mode 100644 common/compiler_macros.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bbbeda68..d89f370d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ option(EQEMU_BUILD_PCH "Build with precompiled headers (Windows)" ON) if(MSVC) add_compile_options(/bigobj) - add_compile_definitions(_CRT_SECURE_NO_WARNINGS NOMINMAX WIN32_LEAN_AND_MEAN CRASH_LOGGING _HAS_AUTO_PTR_ETC) + add_compile_definitions(_CRT_SECURE_NO_WARNINGS NOMINMAX WIN32_LEAN_AND_MEAN CRASH_LOGGING) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") option(EQEMU_DISABLE_MSVC_WARNINGS "Disable MSVC compile warnings." OFF) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index e9f43cec8..ba3844d39 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -6,6 +6,7 @@ set(common_sources bodytypes.cpp classes.cpp cli/eqemu_command_handler.cpp + compiler_macros.h compression.cpp content/world_content_service.cpp crash.cpp diff --git a/common/compiler_macros.h b/common/compiler_macros.h new file mode 100644 index 000000000..16088a405 --- /dev/null +++ b/common/compiler_macros.h @@ -0,0 +1,20 @@ +#pragma once + +#if defined(_MSC_VER) + #define PUSH_DISABLE_DEPRECATED_WARNINGS() __pragma(warning(push)) \ + __pragma(warning(disable:4996)) + #define POP_DISABLE_DEPRECATED_WARNINGS() __pragma(warning(pop)) +#elif defined(__GNUC__) || defined(__clang__) + #define PUSH_DISABLE_DEPRECATED_WARNINGS() _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") + #define POP_DISABLE_DEPRECATED_WARNINGS() _Pragma("GCC diagnostic pop") +#else + #define PUSH_DISABLE_DEPRECATED_WARNINGS() + #define POP_DISABLE_DEPRECATED_WARNINGS() +#endif + +#if defined(_MSC_VER) && !defined(__clang__) + #define UNREACHABLE() __assume(0) +#else + #define UNREACHABLE() __builtin_unreachable() +#endif \ No newline at end of file diff --git a/common/json/jsoncpp.cpp b/common/json/jsoncpp.cpp index 759e68fa6..eb1bd5a14 100644 --- a/common/json/jsoncpp.cpp +++ b/common/json/jsoncpp.cpp @@ -271,11 +271,7 @@ static size_t const stackLimit_g = JSONCPP_DEPRECATED_STACK_LIMIT; // see readVa namespace Json { -#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520) typedef std::unique_ptr CharReaderPtr; -#else -typedef std::auto_ptr CharReaderPtr; -#endif // Implementation of class Features // //////////////////////////////// @@ -4153,11 +4149,7 @@ Value& Path::make(Value& root) const { namespace Json { -#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520) typedef std::unique_ptr StreamWriterPtr; -#else -typedef std::auto_ptr StreamWriterPtr; -#endif static bool containsControlCharacter(const char* str) { while (*str) { diff --git a/libs/luabind/luabind/adopt_policy.hpp b/libs/luabind/luabind/adopt_policy.hpp index 5e81b948b..dc2426a05 100644 --- a/libs/luabind/luabind/adopt_policy.hpp +++ b/libs/luabind/luabind/adopt_policy.hpp @@ -103,7 +103,7 @@ namespace luabind { namespace detail if (luabind::move_back_reference(L, ptr)) return; - make_instance(L, std::auto_ptr(ptr)); + make_instance(L, std::unique_ptr(ptr)); } }; diff --git a/libs/luabind/luabind/class.hpp b/libs/luabind/luabind/class.hpp index 5b8636b97..a2188b358 100644 --- a/libs/luabind/luabind/class.hpp +++ b/libs/luabind/luabind/class.hpp @@ -335,7 +335,7 @@ namespace luabind template struct default_pointer { - typedef std::auto_ptr type; + typedef std::unique_ptr type; }; template diff --git a/libs/luabind/luabind/detail/constructor.hpp b/libs/luabind/luabind/detail/constructor.hpp index 1cbceb789..c3fc8ba7c 100644 --- a/libs/luabind/luabind/detail/constructor.hpp +++ b/libs/luabind/luabind/detail/constructor.hpp @@ -46,7 +46,7 @@ struct construct_aux<0, T, Pointer, Signature> object_rep* self = touserdata(self_); class_rep* cls = self->crep(); - std::auto_ptr instance(new T); + std::unique_ptr instance(new T); inject_backref(self_.interpreter(), instance.get(), instance.get()); void* naked_ptr = instance.get(); @@ -55,7 +55,7 @@ struct construct_aux<0, T, Pointer, Signature> void* storage = self->allocate(sizeof(holder_type)); self->set_instance(new (storage) holder_type( - ptr, registered_class::id, naked_ptr, cls)); + std::move(ptr), registered_class::id, naked_ptr, cls)); } }; @@ -92,7 +92,7 @@ struct construct_aux object_rep* self = touserdata(self_); class_rep* cls = self->crep(); - std::auto_ptr instance(new T(BOOST_PP_ENUM_PARAMS(N,_))); + std::unique_ptr instance(new T(BOOST_PP_ENUM_PARAMS(N,_))); inject_backref(self_.interpreter(), instance.get(), instance.get()); void* naked_ptr = instance.get(); @@ -101,7 +101,7 @@ struct construct_aux void* storage = self->allocate(sizeof(holder_type)); self->set_instance(new (storage) holder_type( - ptr, registered_class::id, naked_ptr, cls)); + std::move(ptr), registered_class::id, naked_ptr, cls)); } }; diff --git a/libs/luabind/luabind/detail/has_get_pointer.hpp b/libs/luabind/luabind/detail/has_get_pointer.hpp index 8a001ddda..67d6a7639 100644 --- a/libs/luabind/luabind/detail/has_get_pointer.hpp +++ b/libs/luabind/luabind/detail/has_get_pointer.hpp @@ -58,7 +58,7 @@ namespace has_get_pointer_ T* get_pointer(T const volatile*); template - T* get_pointer(std::auto_ptr const&); + T* get_pointer(std::unique_ptr const&); # endif diff --git a/libs/luabind/luabind/detail/instance_holder.hpp b/libs/luabind/luabind/detail/instance_holder.hpp index 456e13e6b..2c1d5d955 100644 --- a/libs/luabind/luabind/detail/instance_holder.hpp +++ b/libs/luabind/luabind/detail/instance_holder.hpp @@ -57,7 +57,7 @@ inline mpl::true_ check_const_pointer(void const*) } template -void release_ownership(std::auto_ptr& p) +void release_ownership(std::unique_ptr& p) { p.release(); } @@ -83,7 +83,7 @@ public: P p, class_id dynamic_id, void* dynamic_ptr, class_rep* cls ) : instance_holder(cls, check_const_pointer(false ? get_pointer(p) : 0)) - , p(p) + , p(std::move(p)) , weak(0) , dynamic_id(dynamic_id) , dynamic_ptr(dynamic_ptr) diff --git a/libs/luabind/luabind/detail/make_instance.hpp b/libs/luabind/luabind/detail/make_instance.hpp index 3150cf048..66d23fbd8 100644 --- a/libs/luabind/luabind/detail/make_instance.hpp +++ b/libs/luabind/luabind/detail/make_instance.hpp @@ -88,7 +88,7 @@ void make_instance(lua_State* L, P p) try { - new (storage) holder_type(p, dynamic.first, dynamic.second, cls); + new (storage) holder_type(std::move(p), dynamic.first, dynamic.second, cls); } catch (...) { diff --git a/libs/luabind/luabind/detail/policy.hpp b/libs/luabind/luabind/detail/policy.hpp index e154507e4..19cd2f1ae 100644 --- a/libs/luabind/luabind/detail/policy.hpp +++ b/libs/luabind/luabind/detail/policy.hpp @@ -169,7 +169,7 @@ namespace luabind { namespace detail { if (get_pointer(x)) { - make_instance(L, x); + make_instance(L, std::move(x)); } else { @@ -180,8 +180,8 @@ namespace luabind { namespace detail template void make_pointee_instance(lua_State* L, T& x, mpl::false_, mpl::true_) { - std::auto_ptr ptr(new T(x)); - make_instance(L, ptr); + std::unique_ptr ptr(new T(x)); + make_instance(L, std::move(ptr)); } template diff --git a/libs/luabind/luabind/function.hpp b/libs/luabind/luabind/function.hpp index e156fbfcb..b93ca2627 100644 --- a/libs/luabind/luabind/function.hpp +++ b/libs/luabind/luabind/function.hpp @@ -46,7 +46,7 @@ namespace detail template scope def(char const* name, F f, Policies const& policies) { - return scope(std::auto_ptr( + return scope(std::unique_ptr( new detail::function_registration(name, f, policies))); } diff --git a/libs/luabind/luabind/scope.hpp b/libs/luabind/luabind/scope.hpp index 3b5f293bf..e2cfaed36 100644 --- a/libs/luabind/luabind/scope.hpp +++ b/libs/luabind/luabind/scope.hpp @@ -56,7 +56,7 @@ namespace luabind { struct LUABIND_API scope { scope(); - explicit scope(std::auto_ptr reg); + explicit scope(std::unique_ptr reg); scope(scope const& other_); ~scope(); diff --git a/libs/luabind/src/class.cpp b/libs/luabind/src/class.cpp index 8a67cf6f3..f42b9a8c0 100644 --- a/libs/luabind/src/class.cpp +++ b/libs/luabind/src/class.cpp @@ -235,7 +235,7 @@ namespace luabind { namespace detail { // -- interface --------------------------------------------------------- class_base::class_base(char const* name) - : scope(std::auto_ptr( + : scope(std::unique_ptr( m_registration = new class_registration(name)) ) { @@ -258,14 +258,14 @@ namespace luabind { namespace detail { void class_base::add_member(registration* member) { - std::auto_ptr ptr(member); - m_registration->m_members.operator,(scope(ptr)); + std::unique_ptr ptr(member); + m_registration->m_members.operator,(scope(std::move(ptr))); } void class_base::add_default_member(registration* member) { - std::auto_ptr ptr(member); - m_registration->m_default_members.operator,(scope(ptr)); + std::unique_ptr ptr(member); + m_registration->m_default_members.operator,(scope(std::move(ptr))); } const char* class_base::name() const diff --git a/libs/luabind/src/scope.cpp b/libs/luabind/src/scope.cpp index 52bd132f9..0333205ce 100644 --- a/libs/luabind/src/scope.cpp +++ b/libs/luabind/src/scope.cpp @@ -49,7 +49,8 @@ namespace luabind { namespace detail { { } - scope::scope(std::auto_ptr reg) + + scope::scope(std::unique_ptr reg) : m_chain(reg.release()) { } @@ -193,7 +194,7 @@ namespace luabind { }; namespace_::namespace_(char const* name) - : scope(std::auto_ptr( + : scope(std::unique_ptr( m_registration = new registration_(name))) { } diff --git a/loginserver/encryption.cpp b/loginserver/encryption.cpp index 2ef0713bd..dabbef761 100644 --- a/loginserver/encryption.cpp +++ b/loginserver/encryption.cpp @@ -16,6 +16,7 @@ along with this program. If not, see . */ #include "encryption.h" +#include "common/compiler_macros.h" #ifdef EQEMU_USE_OPENSSL #include @@ -137,7 +138,9 @@ const char *eqcrypt_block(const char *buffer_in, size_t buffer_in_sz, char *buff return nullptr; } + PUSH_DISABLE_DEPRECATED_WARNINGS() DES_ncbc_encrypt((const unsigned char*)buffer_in, (unsigned char*)buffer_out, (long)buffer_in_sz, &k, &v, enc); + POP_DISABLE_DEPRECATED_WARNINGS() #endif return buffer_out; } @@ -164,7 +167,9 @@ std::string eqcrypt_md5(const std::string &msg) unsigned char md5_digest[16]; char tmp[4]; + PUSH_DISABLE_DEPRECATED_WARNINGS() MD5((const unsigned char*)msg.c_str(), msg.length(), md5_digest); + POP_DISABLE_DEPRECATED_WARNINGS() for (int i = 0; i < 16; ++i) { sprintf(&tmp[0], "%02x", md5_digest[i]); diff --git a/zone/embparser.cpp b/zone/embparser.cpp index b617daae7..52863b698 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -17,11 +17,13 @@ */ #ifdef EMBPERL +#include "zone/embparser.h" + +#include "common/compiler_macros.h" #include "common/features.h" #include "common/misc_functions.h" #include "common/seperator.h" #include "common/strings.h" -#include "zone/embparser.h" #include "zone/masterentity.h" #include "zone/qglobals.h" #include "zone/questmgr.h" @@ -398,6 +400,8 @@ int PerlembParser::EventCommon( zone ); } + + return 0; } int PerlembParser::EventNPC( @@ -1211,31 +1215,33 @@ QuestType PerlembParser::GetQuestTypes( event_id == EVENT_SPELL_EFFECT_TRANSLOCATE_COMPLETE ) { return is_global ? QuestType::SpellGlobal : QuestType::Spell; - } else { - if (npc_mob) { - if (!inst) { - if (npc_mob->IsBot()) { - return is_global ? QuestType::BotGlobal : QuestType::Bot; - } else if (npc_mob->IsMerc()) { - return is_global ? QuestType::MercGlobal : QuestType::Merc; - } else if (npc_mob->IsNPC()) { - return is_global ? QuestType::NPCGlobal : QuestType::NPC; - } - } else { - return is_global ? QuestType::ItemGlobal : QuestType::Item; - } - } else if (!npc_mob && mob) { - if (!inst) { - if (mob->IsClient()) { - return is_global ? QuestType::PlayerGlobal : QuestType::Player; - } - } else { - return is_global ? QuestType::ItemGlobal : QuestType::Item; - } - } else if (zone) { - return is_global ? QuestType::ZoneGlobal : QuestType::Zone; - } } + + if (npc_mob) { + if (!inst) { + if (npc_mob->IsBot()) { + return is_global ? QuestType::BotGlobal : QuestType::Bot; + } else if (npc_mob->IsMerc()) { + return is_global ? QuestType::MercGlobal : QuestType::Merc; + } else if (npc_mob->IsNPC()) { + return is_global ? QuestType::NPCGlobal : QuestType::NPC; + } + } else { + return is_global ? QuestType::ItemGlobal : QuestType::Item; + } + } else if (mob) { + if (!inst) { + if (mob->IsClient()) { + return is_global ? QuestType::PlayerGlobal : QuestType::Player; + } + } else { + return is_global ? QuestType::ItemGlobal : QuestType::Item; + } + } else if (zone) { + return is_global ? QuestType::ZoneGlobal : QuestType::Zone; + } + + UNREACHABLE(); } std::string PerlembParser::GetQuestPackageName( diff --git a/zone/lua_packet.cpp b/zone/lua_packet.cpp index 8f231363e..fb2ada0b5 100644 --- a/zone/lua_packet.cpp +++ b/zone/lua_packet.cpp @@ -82,6 +82,16 @@ Lua_Packet::Lua_Packet(const Lua_Packet& o) { } } +Lua_Packet::~Lua_Packet() +{ + if (owned_) { + EQApplicationPacket* ptr = GetLuaPtrData(); + if (ptr) { + delete ptr; + } + } +} + int Lua_Packet::GetSize() { Lua_Safe_Call_Int(); return static_cast(self->size); diff --git a/zone/lua_packet.h b/zone/lua_packet.h index b5b375371..df94b3811 100644 --- a/zone/lua_packet.h +++ b/zone/lua_packet.h @@ -41,7 +41,7 @@ public: Lua_Packet(int opcode, int size, bool raw); Lua_Packet& operator=(const Lua_Packet& o); Lua_Packet(const Lua_Packet& o); - virtual ~Lua_Packet() { if(owned_) { EQApplicationPacket *ptr = GetLuaPtrData(); if(ptr) { delete ptr; } } } + virtual ~Lua_Packet(); int GetSize(); int GetOpcode(); diff --git a/zone/lua_ptr.h b/zone/lua_ptr.h index 7dbf9100c..9333dd9a8 100644 --- a/zone/lua_ptr.h +++ b/zone/lua_ptr.h @@ -48,7 +48,8 @@ public: Lua_Ptr(T *d) : d_(d) { } - ~Lua_Ptr() { + + virtual ~Lua_Ptr() { } T *GetLuaPtrData() { From 6d6cc8ca95c29ee9402b79a90293d666630df3ad Mon Sep 17 00:00:00 2001 From: Knightly <55611098+Knightly1@users.noreply.github.com> Date: Sat, 25 Apr 2026 13:49:03 -1000 Subject: [PATCH 02/10] Update openssl calls to use EVP interface (#5072) --- loginserver/encryption.cpp | 133 ++++++++++++++++++++++++++++--------- loginserver/encryption.h | 10 +++ loginserver/main.cpp | 8 +++ 3 files changed, 119 insertions(+), 32 deletions(-) diff --git a/loginserver/encryption.cpp b/loginserver/encryption.cpp index dabbef761..3fa140768 100644 --- a/loginserver/encryption.cpp +++ b/loginserver/encryption.cpp @@ -19,9 +19,9 @@ #include "common/compiler_macros.h" #ifdef EQEMU_USE_OPENSSL -#include -#include -#include +#include +#include +#include #endif #ifdef EQEMU_USE_MBEDTLS #include @@ -33,6 +33,8 @@ #include #include +#include + #ifdef ENABLE_SECURITY #include @@ -128,23 +130,92 @@ const char *eqcrypt_block(const char *buffer_in, size_t buffer_in_sz, char *buff #endif #ifdef EQEMU_USE_OPENSSL - DES_key_schedule k; - DES_cblock v; - - memset(&k, 0, sizeof(DES_key_schedule)); - memset(&v, 0, sizeof(DES_cblock)); - + // Decrypt requires block-aligned input; encrypt zero-pads a trailing + // partial block to match the legacy DES_ncbc_encrypt semantics the + // game protocol expects. if (!enc && buffer_in_sz && buffer_in_sz % 8 != 0) { return nullptr; } - PUSH_DISABLE_DEPRECATED_WARNINGS() - DES_ncbc_encrypt((const unsigned char*)buffer_in, (unsigned char*)buffer_out, (long)buffer_in_sz, &k, &v, enc); - POP_DISABLE_DEPRECATED_WARNINGS() + unsigned char key[8] = {0}; + unsigned char iv[8] = {0}; + + EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); + if (!ctx) { + return nullptr; + } + + bool result = EVP_CipherInit_ex2(ctx, EVP_des_cbc(), key, iv, enc, nullptr) == 1; + if (result) { + EVP_CIPHER_CTX_set_padding(ctx, 0); + + const unsigned char* src = reinterpret_cast(buffer_in); + size_t src_len = buffer_in_sz; + std::unique_ptr padded; + + if (enc && buffer_in_sz % 8 != 0) { + src_len = ((buffer_in_sz / 8) + 1) * 8; + padded.reset(new unsigned char[src_len]()); + memcpy(padded.get(), buffer_in, buffer_in_sz); + src = padded.get(); + } + + int outl = 0; + int final_len = 0; + result = EVP_CipherUpdate(ctx, reinterpret_cast(buffer_out), &outl, src, static_cast(src_len)) == 1 + && EVP_CipherFinal_ex(ctx, reinterpret_cast(buffer_out) + outl, &final_len) == 1; + } + + EVP_CIPHER_CTX_free(ctx); + if (!result) { + return nullptr; + } #endif return buffer_out; } +#ifdef EQEMU_USE_OPENSSL +static OSSL_PROVIDER *s_legacy_provider = nullptr; +static OSSL_PROVIDER *s_default_provider = nullptr; +#endif + +bool eqcrypt_init() +{ +#ifdef EQEMU_USE_OPENSSL + if (!s_default_provider) { + s_default_provider = OSSL_PROVIDER_load(nullptr, "default"); + } + if (!s_legacy_provider) { + s_legacy_provider = OSSL_PROVIDER_load(nullptr, "legacy"); + } + + if (!s_default_provider || !s_legacy_provider) { + char buf[256]; + while (auto err = ERR_get_error()) { + ERR_error_string_n(err, buf, sizeof(buf)); + LogError("OpenSSL provider load failure: {}", buf); + } + return false; + } +#endif + + return true; +} + +void eqcrypt_shutdown() +{ +#ifdef EQEMU_USE_OPENSSL + if (s_legacy_provider) { + OSSL_PROVIDER_unload(s_legacy_provider); + s_legacy_provider = nullptr; + } + if (s_default_provider) { + OSSL_PROVIDER_unload(s_default_provider); + s_default_provider = nullptr; + } +#endif +} + std::string eqcrypt_md5(const std::string &msg) { std::string ret; @@ -167,14 +238,12 @@ std::string eqcrypt_md5(const std::string &msg) unsigned char md5_digest[16]; char tmp[4]; - PUSH_DISABLE_DEPRECATED_WARNINGS() - MD5((const unsigned char*)msg.c_str(), msg.length(), md5_digest); - POP_DISABLE_DEPRECATED_WARNINGS() - - for (int i = 0; i < 16; ++i) { - sprintf(&tmp[0], "%02x", md5_digest[i]); - ret.push_back(tmp[0]); - ret.push_back(tmp[1]); + if (EVP_Digest(msg.data(), msg.length(), md5_digest, nullptr, EVP_md5(), nullptr) == 1) { + for (int i = 0; i < 16; ++i) { + sprintf(&tmp[0], "%02x", md5_digest[i]); + ret.push_back(tmp[0]); + ret.push_back(tmp[1]); + } } #endif @@ -203,12 +272,12 @@ std::string eqcrypt_sha1(const std::string &msg) unsigned char sha_digest[20]; char tmp[4]; - SHA1((const unsigned char*)msg.c_str(), msg.length(), sha_digest); - - for (int i = 0; i < 20; ++i) { - sprintf(&tmp[0], "%02x", sha_digest[i]); - ret.push_back(tmp[0]); - ret.push_back(tmp[1]); + if (EVP_Digest(msg.data(), msg.length(), sha_digest, nullptr, EVP_sha1(), nullptr) == 1) { + for (int i = 0; i < 20; ++i) { + sprintf(&tmp[0], "%02x", sha_digest[i]); + ret.push_back(tmp[0]); + ret.push_back(tmp[1]); + } } #endif @@ -237,12 +306,12 @@ std::string eqcrypt_sha512(const std::string &msg) unsigned char sha_digest[64]; char tmp[4]; - SHA512((const unsigned char*)msg.c_str(), msg.length(), sha_digest); - - for (int i = 0; i < 64; ++i) { - sprintf(&tmp[0], "%02x", sha_digest[i]); - ret.push_back(tmp[0]); - ret.push_back(tmp[1]); + if (EVP_Digest(msg.data(), msg.length(), sha_digest, nullptr, EVP_sha512(), nullptr) == 1) { + for (int i = 0; i < 64; ++i) { + sprintf(&tmp[0], "%02x", sha_digest[i]); + ret.push_back(tmp[0]); + ret.push_back(tmp[1]); + } } #endif diff --git a/loginserver/encryption.h b/loginserver/encryption.h index 4f188789d..d1f683d06 100644 --- a/loginserver/encryption.h +++ b/loginserver/encryption.h @@ -48,10 +48,20 @@ namespace CryptoHash { } std::string GetEncryptionByModeId(uint32 mode); + +// DES-CBC with an all-zero key and IV (EQ login protocol obfuscation, not security). +// On encrypt, a trailing partial block is zero-padded to the next 8-byte boundary, so +// buffer_out must be at least ((buffer_in_sz + 7) / 8) * 8 bytes. On decrypt, buffer_in_sz +// must already be a multiple of 8 or the call returns nullptr. const char *eqcrypt_block(const char *buffer_in, size_t buffer_in_sz, char *buffer_out, bool enc); std::string eqcrypt_hash(const std::string &username, const std::string &password, int mode); bool eqcrypt_verify_hash(const std::string &username, const std::string &password, const std::string &pwhash, int mode); +// OpenSSL 3.0 moved DES behind the "legacy" provider; these load/unload it +// for the lifetime of the process. No-op when built against mbedtls. +bool eqcrypt_init(); +void eqcrypt_shutdown(); + struct EncryptionResult { std::string password; int mode = 0; diff --git a/loginserver/main.cpp b/loginserver/main.cpp index faa22e955..9b9766223 100644 --- a/loginserver/main.cpp +++ b/loginserver/main.cpp @@ -26,6 +26,7 @@ #include "common/platform.h" #include "common/timer.h" #include "common/types.h" +#include "loginserver/encryption.h" #include "loginserver/login_server.h" #include "loginserver/loginserver_command_handler.h" #include "loginserver/loginserver_webserver.h" @@ -160,6 +161,11 @@ int main(int argc, char **argv) RegisterExecutablePlatform(ExePlatformLogin); set_exception_handler(); + if (!eqcrypt_init()) { + LogError("Failed to initialize crypto providers"); + return 1; + } + LogInfo("Logging System Init"); if (argc == 1) { @@ -280,5 +286,7 @@ int main(int argc, char **argv) LogInfo("Server Manager Shutdown"); delete server.server_manager; + eqcrypt_shutdown(); + return 0; } From a8db0574401b18187396621e6751987a6ccb4e75 Mon Sep 17 00:00:00 2001 From: KimLS Date: Mon, 27 Apr 2026 22:19:15 -0700 Subject: [PATCH 03/10] Add vcpkg cache, hopefully works. --- .github/workflows/build.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index adcdf726a..d68ba4a6d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -25,6 +25,20 @@ jobs: sudo apt-get update sudo apt-get install -y build-essential ninja-build ccache uuid-dev + - name: Restore vcpkg Cache + uses: actions/cache@v5 + with: + path: | + submodules/vcpkg/buildtrees + submodules/vcpkg/downloads + submodules/vcpkg/installed + submodules/vcpkg/packages + submodules/vcpkg/vcpkg.exe + submodules/vcpkg/vcpkg + key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json', 'submodules/vcpkg/.git/HEAD') }} + restore-keys: | + ${{ runner.os }}-vcpkg- + - name: Configure run: | cmake -S . -B build -G Ninja \ @@ -61,6 +75,20 @@ jobs: with: arch: x64 + - name: Restore vcpkg Cache + uses: actions/cache@v5 + with: + path: | + submodules/vcpkg/buildtrees + submodules/vcpkg/downloads + submodules/vcpkg/installed + submodules/vcpkg/packages + submodules/vcpkg/vcpkg.exe + submodules/vcpkg/vcpkg + key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json', 'submodules/vcpkg/.git/HEAD') }} + restore-keys: | + ${{ runner.os }}-vcpkg- + - name: Configure shell: pwsh run: | From 84a90cef2310f5cc45505db4d48b756d7cac7049 Mon Sep 17 00:00:00 2001 From: KimLS Date: Mon, 27 Apr 2026 22:22:54 -0700 Subject: [PATCH 04/10] Linux build doesn't like the way we hash this --- .github/workflows/build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d68ba4a6d..d380349e5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -35,7 +35,7 @@ jobs: submodules/vcpkg/packages submodules/vcpkg/vcpkg.exe submodules/vcpkg/vcpkg - key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json', 'submodules/vcpkg/.git/HEAD') }} + key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }} restore-keys: | ${{ runner.os }}-vcpkg- @@ -85,7 +85,7 @@ jobs: submodules/vcpkg/packages submodules/vcpkg/vcpkg.exe submodules/vcpkg/vcpkg - key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json', 'submodules/vcpkg/.git/HEAD') }} + key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }} restore-keys: | ${{ runner.os }}-vcpkg- From 9647a5b82c815c15c14eb577d104022d6609e317 Mon Sep 17 00:00:00 2001 From: KimLS Date: Mon, 27 Apr 2026 23:20:29 -0700 Subject: [PATCH 05/10] Add develop branch --- .github/workflows/build.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d380349e5..68e0bcb12 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -3,6 +3,7 @@ on: push: branches: - master + - develop pull_request: jobs: From f72bbab0e90dbe42e0ba3f4f94e9cad81c867d1d Mon Sep 17 00:00:00 2001 From: KimLS Date: Tue, 28 Apr 2026 00:04:40 -0700 Subject: [PATCH 06/10] Change paths to try to get this working --- .github/workflows/build.yaml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 68e0bcb12..c01b67a73 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -30,14 +30,11 @@ jobs: uses: actions/cache@v5 with: path: | - submodules/vcpkg/buildtrees + vcpkg_installed submodules/vcpkg/downloads - submodules/vcpkg/installed - submodules/vcpkg/packages - submodules/vcpkg/vcpkg.exe - submodules/vcpkg/vcpkg key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }} restore-keys: | + ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }}- ${{ runner.os }}-vcpkg- - name: Configure @@ -80,14 +77,11 @@ jobs: uses: actions/cache@v5 with: path: | - submodules/vcpkg/buildtrees + vcpkg_installed submodules/vcpkg/downloads - submodules/vcpkg/installed - submodules/vcpkg/packages - submodules/vcpkg/vcpkg.exe - submodules/vcpkg/vcpkg key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }} restore-keys: | + ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }}- ${{ runner.os }}-vcpkg- - name: Configure From 4abd9c1b40b673b33d68c42ad1e58ea12867cd69 Mon Sep 17 00:00:00 2001 From: KimLS Date: Tue, 28 Apr 2026 18:01:20 -0700 Subject: [PATCH 07/10] Some build changes, may or may not fix cache --- .github/workflows/build.yaml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c01b67a73..72e1a8bcf 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -5,11 +5,13 @@ on: - master - develop pull_request: - jobs: linux: name: Linux runs-on: ubuntu-latest + env: + VCPKG_DOWNLOADS: ${{ github.workspace }}/submodules/vcpkg/downloads + VCPKG_BINARY_SOURCES: 'clear;files,${{ github.workspace }}/vcpkg_archives,readwrite' steps: - name: Checkout source uses: actions/checkout@v5 @@ -30,11 +32,10 @@ jobs: uses: actions/cache@v5 with: path: | - vcpkg_installed - submodules/vcpkg/downloads + ${{ env.VCPKG_DOWNLOADS }} + ${{ github.workspace }}/vcpkg_archives key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }} restore-keys: | - ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }}- ${{ runner.os }}-vcpkg- - name: Configure @@ -59,6 +60,9 @@ jobs: windows: name: Windows runs-on: windows-latest + env: + VCPKG_DOWNLOADS: ${{ github.workspace }}\submodules\vcpkg\downloads + VCPKG_BINARY_SOURCES: 'clear;files,${{ github.workspace }}\vcpkg_archives,readwrite' steps: - name: Checkout source uses: actions/checkout@v5 @@ -77,11 +81,10 @@ jobs: uses: actions/cache@v5 with: path: | - vcpkg_installed - submodules/vcpkg/downloads + ${{ env.VCPKG_DOWNLOADS }} + ${{ github.workspace }}/vcpkg_archives key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }} restore-keys: | - ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }}- ${{ runner.os }}-vcpkg- - name: Configure From cabe06ea92853634dd55d6dcc2fffde256c963c3 Mon Sep 17 00:00:00 2001 From: KimLS Date: Tue, 28 Apr 2026 19:42:26 -0700 Subject: [PATCH 08/10] Revert linux part for now --- .github/workflows/build.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 72e1a8bcf..0bf0acb95 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -9,9 +9,6 @@ jobs: linux: name: Linux runs-on: ubuntu-latest - env: - VCPKG_DOWNLOADS: ${{ github.workspace }}/submodules/vcpkg/downloads - VCPKG_BINARY_SOURCES: 'clear;files,${{ github.workspace }}/vcpkg_archives,readwrite' steps: - name: Checkout source uses: actions/checkout@v5 @@ -32,10 +29,11 @@ jobs: uses: actions/cache@v5 with: path: | - ${{ env.VCPKG_DOWNLOADS }} - ${{ github.workspace }}/vcpkg_archives + vcpkg_installed + submodules/vcpkg/downloads key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }} restore-keys: | + ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }}- ${{ runner.os }}-vcpkg- - name: Configure From 42d600446731eebf741bbdce4c73b492b297061c Mon Sep 17 00:00:00 2001 From: KimLS Date: Tue, 28 Apr 2026 20:00:01 -0700 Subject: [PATCH 09/10] Remove step i think isn't required for windows, change linux path --- .github/workflows/build.yaml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0bf0acb95..890becf75 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -29,7 +29,7 @@ jobs: uses: actions/cache@v5 with: path: | - vcpkg_installed + build/vcpkg_installed submodules/vcpkg/downloads key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }} restore-keys: | @@ -70,11 +70,6 @@ jobs: - name: Enable long paths run: git config --global core.longpaths true - - name: Setup MSVC environment - uses: ilammy/msvc-dev-cmd@v1 - with: - arch: x64 - - name: Restore vcpkg Cache uses: actions/cache@v5 with: From c6ddf300a4e2badf5ef284b630b25a3bb6a246c0 Mon Sep 17 00:00:00 2001 From: KimLS Date: Tue, 28 Apr 2026 20:15:06 -0700 Subject: [PATCH 10/10] Add back msvc step with a maintained fork --- .github/workflows/build.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 890becf75..7c1882292 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -69,6 +69,11 @@ jobs: - name: Enable long paths run: git config --global core.longpaths true + + - name: Setup MSVC environment + uses: TheMrMilchmann/setup-msvc-dev@v4 + with: + arch: x64 - name: Restore vcpkg Cache uses: actions/cache@v5