diff --git a/include/aoapplication.h b/include/aoapplication.h index 60d945e..dccc85e 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -63,9 +63,6 @@ public: /////////////////server metadata////////////////// - unsigned int s_decryptor = 5; - bool encryption_needed = true; - bool yellow_text_enabled = false; bool prezoom_enabled = false; bool flipping_enabled = false; diff --git a/include/aopacket.h b/include/aopacket.h index 4097be8..e636998 100644 --- a/include/aopacket.h +++ b/include/aopacket.h @@ -15,14 +15,10 @@ public: QStringList &get_contents() { return m_contents; } QString to_string(); - void encrypt_header(unsigned int p_key); - void decrypt_header(unsigned int p_key); - void net_encode(); void net_decode(); private: - bool encrypted = false; QString m_header; QStringList m_contents; diff --git a/src/aopacket.cpp b/src/aopacket.cpp index 6afd39e..1cb5428 100644 --- a/src/aopacket.cpp +++ b/src/aopacket.cpp @@ -31,24 +31,8 @@ QString AOPacket::to_string() f_string += "#%"; - if (encrypted) - return "#" + f_string; - else - return f_string; -} -void AOPacket::encrypt_header(unsigned int p_key) -{ - m_header = fanta_encrypt(m_header, p_key); - - encrypted = true; -} - -void AOPacket::decrypt_header(unsigned int p_key) -{ - m_header = fanta_decrypt(m_header, p_key); - - encrypted = false; + return f_string; } void AOPacket::net_encode() diff --git a/src/encryption_functions.cpp b/src/encryption_functions.cpp deleted file mode 100644 index 6669fe1..0000000 --- a/src/encryption_functions.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "encryption_functions.h" - -#include "hex_functions.h" - -QString fanta_encrypt(QString temp_input, unsigned int p_key) -{ - // using standard stdlib types is actually easier here because of implicit - // char<->int conversion which in turn makes encryption arithmetic easier - - unsigned int key = p_key; - unsigned int C1 = 53761; - unsigned int C2 = 32618; - - QVector temp_result; - std::string input = temp_input.toUtf8().constData(); - - for (unsigned int pos = 0; pos < input.size(); ++pos) { - uint_fast8_t output = input.at(pos) ^ (key >> 8) % 256; - temp_result.append(output); - key = (temp_result.at(pos) + key) * C1 + C2; - } - - std::string result = ""; - - for (uint_fast8_t i_int : temp_result) { - result += omni::int_to_hex(i_int); - } - - QString final_result = QString::fromStdString(result); - - return final_result; -} - -QString fanta_decrypt(QString temp_input, unsigned int key) -{ - std::string input = temp_input.toUtf8().constData(); - - QVector unhexed_vector; - - for (unsigned int i = 0; i < input.length(); i += 2) { - std::string byte = input.substr(i, 2); - unsigned int hex_int = strtoul(byte.c_str(), nullptr, 16); - unhexed_vector.append(hex_int); - } - - unsigned int C1 = 53761; - unsigned int C2 = 32618; - - std::string result = ""; - - for (int pos = 0; pos < unhexed_vector.size(); ++pos) { - unsigned char output = unhexed_vector.at(pos) ^ (key >> 8) % 256; - result += output; - key = (unhexed_vector.at(pos) + key) * C1 + C2; - } - - return QString::fromStdString(result); -} diff --git a/src/hex_functions.cpp b/src/hex_functions.cpp deleted file mode 100644 index 1e35718..0000000 --- a/src/hex_functions.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "hex_functions.h" - -namespace omni { -std::string int_to_hex(unsigned int input) -{ - if (input > 255) - return "FF"; - - std::stringstream stream; - stream << std::setfill('0') << std::setw(sizeof(char) * 2) << std::hex - << input; - std::string result(stream.str()); - std::transform(result.begin(), result.end(), result.begin(), ::toupper); - - return result; -} -} // namespace omni diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index e4e5d5c..96d54b5 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -120,11 +120,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) if (f_contents.size() == 0) goto end; - // you may ask where 322 comes from. that would be a good question. - s_decryptor = fanta_decrypt(f_contents.at(0), 322).toUInt(); - // default(legacy) values - encryption_needed = true; yellow_text_enabled = false; prezoom_enabled = false; flipping_enabled = false; @@ -140,10 +136,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet) additive_enabled = false; effects_enabled = false; - // workaround for tsuserver4 - if (f_contents.at(0) == "NOENCRYPT") - encryption_needed = false; - QString f_hdid; f_hdid = get_hdid(); @@ -201,8 +193,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet) custom_objection_enabled = true; if (f_packet.contains("fastloading", Qt::CaseInsensitive)) improved_loading_enabled = true; - if (f_packet.contains("noencryption", Qt::CaseInsensitive)) - encryption_needed = false; if (f_packet.contains("deskmod", Qt::CaseInsensitive)) desk_mod_enabled = true; if (f_packet.contains("evidence", Qt::CaseInsensitive)) @@ -750,19 +740,9 @@ void AOApplication::send_server_packet(AOPacket *p_packet, bool encoded) QString f_packet = p_packet->to_string(); - if (encryption_needed) { -#ifdef DEBUG_NETWORK - qDebug() << "S(e):" << f_packet; -#endif - - p_packet->encrypt_header(s_decryptor); - f_packet = p_packet->to_string(); - } - else { #ifdef DEBUG_NETWORK qDebug() << "S:" << f_packet; #endif - } net_manager->ship_server_packet(f_packet);