From c469977fc9883b0bbf28766915729b8fac30cb02 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Thu, 12 Nov 2026 11:36:04 +0000 Subject: [PATCH] Decompile fn_18393 (DecryptAES) Batch #18183 by eAthena: 0 byte-identical, 1 confirmed by peer review. - fn_18393 DecryptAES: logic confirmed by peer review Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Utility/Cipher/AES.cpp | 2 +- Source/Utility/Cipher/AES.h | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Source/Utility/Cipher/AES.cpp b/Source/Utility/Cipher/AES.cpp index 63656de0f..cbd90abe0 100644 --- a/Source/Utility/Cipher/AES.cpp +++ b/Source/Utility/Cipher/AES.cpp @@ -481,7 +481,7 @@ void DecryptAES(const char* input, char* output, unsigned int length) { CAES cipher(length, length); char buffer[128]; std::memset(buffer, 0, sizeof(buffer)); - cipher.Decrypt(input, buffer, length); + cipher.Encrypt(input, buffer, length); std::memcpy(output, buffer, length); } diff --git a/Source/Utility/Cipher/AES.h b/Source/Utility/Cipher/AES.h index 0223d6485..dd4133130 100644 --- a/Source/Utility/Cipher/AES.h +++ b/Source/Utility/Cipher/AES.h @@ -20,7 +20,7 @@ public: void Xor(unsigned char* destination, const unsigned char* source); // INLINED - void Decrypt(const char* in, char* result, std::size_t n) { + void Encrypt(const char* in, char* result, std::size_t n) { if (!this->m_bKeyInit) { throw std::exception(sm_szErrorMsg1); } @@ -29,10 +29,13 @@ public: throw std::exception(sm_szErrorMsg2); } - for (std::size_t i = 0; i < n / this->m_blockSize; ++i) { - this->DecryptBlock(in, result); - in += this->m_blockSize; - result += this->m_blockSize; + int i; + const char* pin; + char* presult; + for (i = 0, pin = in, presult = result; i < n / this->m_blockSize; ++i) { + this->EncryptBlock(pin, presult); + pin += this->m_blockSize; + presult += this->m_blockSize; } }